I created a maven project and i'm trying to run an external script. In this external script, i use read command to ask a question and get an answer.
It works if i do a sudo mvn package with exec-maven-plugin
But, but, but :
- If i do a sudo mvn package, my script doesn't stop at read command.
- If i do a sudo mvn release:prepare with exec-maven-plugin, my script doesn't stop at read command.
- If i do a sudo mvn release:prepare with maven-antrun-plugin, my script doesn't stop at read command.
And obviously, i need to do a release :)
I tried to to change the first line of my script (#/usr/bin/bash, sh, ...) with other syntaxes for read command...
Is anyone have a solution to help me ???
Here the concerned part of my pom.xml
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>initialisation</id>
<phase>initialize</phase>
<configuration>
<tasks>
<exec dir="${project.basedir}" executable="${project.basedir}/livraison/outils/0_init_livraison.ksh" failonerror="true">
<arg line="${project.name} ${project.version} ${ancienneVersion}" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Here the concerned part of my 0_init_livraison.ksh
#!/bin/ksh
echo -e "| EXECUTION DU SCIPT generation_livrable.ksh \n"
echo "SHELL : $SHELL"
boucle="boucler"
while [ $boucle -eq "boucler" ]
do
echo -ne " Souhaitez-vous forcer la procedure (oui/non)? "
read rep1
case "$rep1" in
o|O|y|Y|oui|Oui|OUI|yes|Yes|YES)
echo ""
break
;;
n|N|non|Non|NON|no|No|NO)
echo -e " Abandon de la procedure..."
boucle=""
exit 1
;;
*)
echo -e " Reponse incomprehensible.\c"
esac
done
The last lines of my console when i do a sudo mvn package ( And then, nothing happens. It seems blocked because of an infinite while loop)
[INFO] --- maven-antrun-plugin:1.8:run (initialisation) @ MyProject---
[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks
main:
[exec] | EXECUTION DU SCIPT generation_livrable.ksh
[exec]
[exec] SHELL : /bin/bash
Thanks for the reading :)
EDIT :
I tried to use property with maven-antrun-plugin. But i have a similar problem: antrun input task doesn't work during mvn release:prepare operation
EITHER
Set environment variable ANT_HOME, add a property to you Maven:
<property name="ant.home" value="${env.ANT_HOME}" />
and add a parametervmlauncher="true"
to your Ant Exec part.OR
Exec
ksh
instead of script name with a script as a parameter. I mean:I tried to use Exec ksh instead of script name with a script as a parameterthose but it didn't work. I tried to set ANT_HOME variable but it didn't work.
But i changed my way of thinking : Having a build that depends on the console is extremely problematic, most integration tools around Maven will not work with it because they assume autonomous runs. This kind of maven project would encounter problems with Jenkins , Netbeans,... They cannot wait for manual answer.
The best way is to set an option and run a command with a parameter :
mvn clean packge -Dforcer=oui or mvn release:prepare -Darguments=-Dforcer=oui
Here a part of my pom.xml :
Here a function which is called in my 0_init_livraison.ksh script when a problem is detected :
So my problem is solved.
Anyway, thank's for your suggestions :)