How can I change the war name generated by maven a

2020-02-16 08:03发布

How can I change the name from 1.0.snapshot-jar-with-dependencies to something else, below are contents of my 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-2
3条回答
Evening l夕情丶
2楼-- · 2020-02-16 08:43

Use the following in the configuration of the maven-assembly-plugin:

<configuration>
  <finalName>custom-name</finalName>
  <appendAssemblyId>false</appendAssemblyId>
</configuration>

Full details in the official documentation of the assembly:single mojo.

查看更多
狗以群分
3楼-- · 2020-02-16 08:48

In the case of packaging a JAR with dependencies, the won't work. You will fix it by using the dependency plugin:

        <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>
查看更多
淡お忘
4楼-- · 2020-02-16 08:53

You can achieve this by specifying the finalName property in your pom, e.g.

<build>
    <finalName>something-else</finalName>
    ...
</build>
查看更多
登录 后发表回答