无法使用 maven-Assembly-plugin 设置最终的 jar 名称

这就是我如何配置 maven-assembly-plugin

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>myapp</finalName>
<archive>
<manifest>
<mainClass>com.myapp.Main</mainClass>
</manifest>
</archive>
<!--
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
-->
</configuration>
</plugin>

我期望最后的 jar 文件应该是 myapp.jar,但它最终是 myapp-jar-with-dependencies.jar

您能告诉我如何配置将 "jar-with-dependencies"排除在最终名称之外吗?

53090 次浏览

You can specify the finalName property to give the jar the name you want, and specify that appendAssemblyId should be false to avoid the jar-with-dependencies suffix. The configuration below will output a jar called test.jar

         <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>test</finalName>
<archive>
<manifest>
<mainClass>com.myapp.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>