如何将名称从1.0.snapshot-jar-with-dependencies
更改为其他名称,以下是我的POM的内容:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<archive>
<manifest>
<mainClass>com.package.example.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:155)
在maven-assembly-plugin
:
<configuration>
<finalName>custom-name</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
assembly:assembly
mojo的官方文档中的完整详细信息。
答案 1 :(得分:88)
您可以通过在pom中指定finalName
属性来实现此目的,例如
<build>
<finalName>something-else</finalName>
...
</build>
答案 2 :(得分:5)
在使用依赖项打包JAR的情况下,将无效。您将使用依赖项插件修复它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>project.group.id</groupId>
<artifactId>artifact-id</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${basedir}/some/dir</outputDirectory>
<destFileName>custom-name.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>