I have a maven project which runs on command line by running a script. I want to distribute it on both Windows and Linux. I have searched all the related posts but I didn't fully understood how I can create a .bat file for windows.
All my dependencies are copied to a folder named mavenLib and a jar file gets created in the target folder in ubuntu using:
export CLASSPATH=`ls -1 target/mavenLib/* | tr '\n' ':'`target/ClientPortfolioCreator-0.0.1-SNAPSHOT.jar
What is the alternative in windows?
I suggest you use a maven plugin called the appassembler-maven-plugin . This plugin generates Unix and Windows scripts and also copies all necessary dependencies in a local folder.
The plugin's basic usage is as follows:
In the build section of the pom.xml
, add the following configuration according to your requirements.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<configuration>
<programs>
<program>
<mainClass>your.package.YourMainClass</mainClass>
<name>TheScriptName</name>
</program>
</programs>
</configuration>
</plugin>
</plugins>
Then execute:
mvn package appassembler:assemble
And that's all, the plugin output is located by default in target/appassembler
For more detailed information, go to the plugin homepage .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.