我怎样才能改变由Maven Assembly插件生成的战争名称
我怎样才能将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>
在maven-assembly-plugin
的configuration中使用以下内容:
<configuration> <finalName>custom-name</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration>
assembly:assembly
的官方文档中的全部细节assembly:assembly
mojo。
你可以通过在你的pom中指定finalName
属性来达到这个finalName
<build> <finalName>something-else</finalName> ... </build>
在打包依赖的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>