java - How do I create a Netbeans style Jar with all dependencies in a lib folder? -


as question says, how package netbeans maven project way netbeans native project packaged:

  • all dependencies in separate lib folder
  • the main project jar manifest includes lib folder on it's classpath

in pom.xml file ...

1) add code project->properties node. define main class in central place use in many plugins.

<properties>         <mainclass>project.main.class</mainclass> </properties> 

2) add code project->build->plugins node. collect jar dependencies lib folder , compile main class jar proper classpath reference:

    <plugin>         <artifactid>maven-dependency-plugin</artifactid>         <executions>             <execution>                 <phase>install</phase>                 <goals>                     <goal>copy-dependencies</goal>                 </goals>                 <configuration>                     <outputdirectory>${project.build.directory}/lib</outputdirectory>                 </configuration>             </execution>         </executions>     </plugin>     <plugin>         <artifactid>maven-jar-plugin</artifactid>         <configuration>             <archive>                 <manifest>                     <addclasspath>true</addclasspath>                     <classpathprefix>lib/</classpathprefix>                     <mainclass>${mainclass}</mainclass>                 </manifest>             </archive>         </configuration>     </plugin> 

Comments