如何在lib文件夹中创建具有所有依赖项的Netbeans样式的Jar? [英] How do I create a Netbeans style Jar with all dependencies in a lib folder?
本文介绍了如何在lib文件夹中创建具有所有依赖项的Netbeans样式的Jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如问题所述,如何完全按照打包Netbeans本机项目的方式打包Netbeans Maven项目:
As the question says, how to package a Netbeans Maven project exactly the way a Netbeans native project is packaged:
- 所有依赖项都在单独的lib文件夹中
- 带有清单的清单的主项目jar,在清单的类路径上包含lib文件夹
推荐答案
在您的pom.xml文件中...
In your pom.xml file ...
1)将此代码添加到您的project-> properties节点.这将在一个集中位置定义您的主类,以供许多插件使用.
1) Add this code to your project->properties node. This will define your main class in a central place for use in many plugins.
<properties>
<mainClass>project.Main.class</mainClass>
</properties>
2)将此代码添加到您的project-> build-> plugins节点中.它将所有jar依赖项收集到一个lib文件夹中,并使用适当的classpath引用编译您的主类jar:
2) Add this code to your project->build->plugins node. It will collect all your jar dependencies into a lib folder AND compile your main class jar with the 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>
这篇关于如何在lib文件夹中创建具有所有依赖项的Netbeans样式的Jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文