I have a Java command-line application, and would like to create an Ant* build script that will create all the required batch/shell scripts to run the application successfully including all the classpath variables. I need it to do the following:
I found only a partial answer here.
But I haven't found anything that does this basic and trivial task that every build involves.
Disclaimer - the original question was Ant/Maven, but I would prefer to see if it can be done in Ant.
In Maven the best solution for this is the maven-appassembler-plugin which handles the creation of a shell script / batch file. In combination with maven-assembly you can create a tar.gz or zip archive which contains everything which is needed.
Maven knows the dependency:build-classpath
goal, which does most of the dirty work:
mvn dependency:build-classpath -DoutputFile=cp.txt
You can use this generated file in a shell script to create the java classpath (I know, it ain't much, but it'll get you started).
Or you can use the exec-maven-plugin to launch a main class from the current maven context. Something like this will do:
mvn compile org.codehaus.mojo:exec-maven-plugin:1.2:java \
-Dexec.mainClass=com.yourcompany.YourClass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With