【发布时间】:2012-11-16 22:15:41
【问题描述】:
我有独立的 java 应用程序,我想将其打包为:myapp.jar。并将所有依赖的 jar 复制到“备用文件夹”。理想情况下,我希望 maven 更新 META-INF 文件以将所有类路径依赖项 jar 条目添加到其中。
例如,如果我的项目引用 commons.jar,并且当我使用此插件构建程序集时,它将所有 .class 文件和包从 commons.jar 复制到 myappjar-with-dependencies.jar。
maven 程序集插件的问题是将所有依赖项解压缩到 myappjar-with-dependencies.jar 中。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.core.App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
【问题讨论】:
-
“maven 程序集插件的问题将所有依赖项解压缩到 myappjar-with-dependencies.jar。”是什么意思?这句话看不懂。
-
例如,如果我的项目引用了commons.jar,并且当我使用这个插件构建程序集时,它会将commons.jar中的所有.class文件和包复制到myappjar-with-dependencies.jar .