Execute shell script file to launch mvn command

3,486 views
Skip to first unread message

Tanyagorn Benjaprompadung

unread,
Jul 19, 2018, 10:46:53 AM7/19/18
to izpack-user
I already asked this question in stackoverflow via this link https://stackoverflow.com/questions/51424918/izpack-execute-shell-script-file-to-launch-mvn-command
But I think this forum is more active with IzPack users, I decide to post again.

First, I have db_migration.sh with content like this


#!/bin/sh
eval "mvn compile flyway:migrate"

So, simple. Just want to ease users from executing this command in the terminal by themselves. Due to 'mvn', Of course, this command need to be executed with pom file, which I already place them together in the same directory.


Second, I have this code segment in install.xml file. To mark as executable file after the installation, fix permission denied issue in Unix system


 <executable targetfile="$INSTALL_PATH/Database/orchestra-db/db_migration.sh" os="unix" stage="never" failure="warn" keep="true" />

Then, in the ProcessPanel I have this job to run my db_migration.sh


<job name="do xyz">
   
<executeForPack name="Orchestra Runtime"/>
   
<os family="unix" />
   
<executefile name="$INSTALL_PATH/Database/orchestra-db/db_migration.sh">
       
<arg>doit</arg>
   
</executefile>
</job>

However, when I test my installer, I got this error message in the ProcessPanel


[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.300 s
[INFO] Finished at: 2018-07-19T15:51:52+02:00
[INFO] Final Memory: 5M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/tanyagorn/Documents/OrchestraInstaller/installer/target). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

Seem like IzPack is looking for pom file and try to execute .sh file in 'target' directory. But, I need this script to be executed at the user's install path. Can anyone tell me what did I do wrong?

Thank you in advance.


Ron Wheeler

unread,
Jul 19, 2018, 11:55:09 AM7/19/18
to izpac...@googlegroups.com
You probably have to pass the INSTALL_PATH to your sh script as an argument and in the sh script use the argument to CD to the "right" directory before starting mavens


--
You received this message because you are subscribed to the Google Groups "izpack-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to izpack-user...@googlegroups.com.
To post to this group, send email to izpac...@googlegroups.com.
Visit this group at https://groups.google.com/group/izpack-user.
For more options, visit https://groups.google.com/d/optout.

René Krell

unread,
Jul 19, 2018, 1:07:18 PM7/19/18
to izpac...@googlegroups.com
Exactly like Ron mentioned, you probably launched the installer from the target/ directory which has been taken as working directory, and the pom.xml cannot be found there. This is better then launching it from the directory with the POM just accidentally and call the installer working, and the next call somewhere else fails :-)

You will need to set the execution directory before calling Maven, see also https://izpack.atlassian.net/wiki/x/1oAH.

Approaches:
  • Using the workingDir attribute in the ProcessPanel descriptor:
    <executefile name="$INSTALL_PATH/scripts/xyz.bat" workingDir="...">
  • In Bash, use $(dirname $0) for getting the directory where the script is actually located
  • Use %INSTALL_PATH in your shell script and additionally mark it <parsable> in install.xml
    See https://izpack.atlassian.net/wiki/x/tIAH
Maybe there are more ways, but there should on of the above will be a way to go.

René


čt 19. 7. 2018 v 17:55 odesílatel Ron Wheeler <rwhee...@gmail.com> napsal:

Tanyagorn Benjaprompadung

unread,
Jul 19, 2018, 4:21:27 PM7/19/18
to izpack-user
Thanks for your help Ron and Rene.
Especially for describing steps I need to follow in details, and now it works!
Really appreciated.

เมื่อ วันพฤหัสบดีที่ 19 กรกฎาคม ค.ศ. 2018 16 นาฬิกา 46 นาที 53 วินาที UTC+2, Tanyagorn Benjaprompadung เขียนว่า:
Reply all
Reply to author
Forward
0 new messages