Maven: Set name of final packaged artifacts
Published:
Here's how to set the final name of the artifact generated by Maven.
<build>
<!-- Sets name of regular artifact -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<!-- Name of assembled jar with all dependencies -->
<finalName>${project.artifactId}</finalName>
<!-- Set to false to prevent '-jar-with-dependencies' to be appended to the file name -->
<appendAssemblyId>true</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Note that we use a variable here so that the name will be the same as the artifactId
. It could of course also be just a regular hard coded string. Also note that since we're using the same name for both packaged artifacts, the latter (the one with dependencies) will overwrite the first.