我正在使用maven assembly-plugin,我想创建一个ZIP文件,其中包含一个胖jar(jar-with-dependencies)。我无法使用mvn package
在一次运行中创建此项。我可以取消注释descriptor
的配置或取消注释jar-with-dependencies
部分。
build
的{{1}}部分如下:
pom.xml
而<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/dist.xml</descriptor>
</descriptors>
<finalName>sample-documentum-downloader</finalName>
</configuration>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.foo.DownloadDocuments</mainClass>
</manifest>
</archive>
</configuration>
</execution>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
是:
dist.xml
我如何重组以在一次运行中创建包含远JAR的ZIP。
感谢您的支持。
答案 0 :(得分:2)
感谢Tunaki,我的build
部分现在看起来像这样:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.foo.DownloadDocuments</mainClass>
</manifest>
</archive>
</configuration>
</execution>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/dist.xml</descriptor>
</descriptors>
<finalName>sample-documentum-downloader</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
答案 1 :(得分:1)
问题在于您将(function() {
// define and subscribe here
})();
元素声明为插件的全局元素。这意味着所有执行都将继承该配置:<configuration>
,但assemble-all
。因此,继承的jar-with-dependencies
可能会弄乱<descriptors>
。
您需要将<descriptorRefs>
元素移动到特定的<configuration>
执行,就像执行assemble-all
一样。