2

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?

roadrunner66
  • 7,772
  • 4
  • 32
  • 38
user1790894
  • 407
  • 3
  • 9
  • 17

1 Answers1

5

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.

Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
Alejandro
  • 871
  • 8
  • 13
  • I tried this and getting exception generics are not supported in -source 1.3 – user1790894 Nov 15 '12 at 06:48
  • I tried with source 1.5 then got [INFO] Unable to find resource 'org.codehaus.mojo:appassembler-maven-plugin:pom:1.5' in repository sonatype (https://oss.sonatype.org/content/groups/public/) – user1790894 Nov 15 '12 at 06:58
  • Seems like maven cannot find the plugin in that repository, try again adding http://repo.maven.apache.org/maven2/ as a repository directly. – Alejandro Nov 15 '12 at 14:03