How can I change the war name generated by maven assembly plugin

Solution 1:

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.

Solution 2:

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

<build>
    <finalName>something-else</finalName>
    ...
</build>

Solution 3:

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>