How to set final jar name with maven-assembly-plugin version 3

Viewed 4086

In older versions of the plugin you could use <finalName>, but that does not exist any more. At the moment I am getting projectName-version-jar-with-dependencies.jar and it would be nice to change this.

2 Answers

In a multi-module project, I created the assemblies in each module. To change the name I used a new child module called 'assembly' and I collected all the single module assemblies into a new directory. At that point, you can change the output name. I am following this FAQ https://maven.apache.org/plugins/maven-assembly-plugin/faq.html#module-binaries

My final assembly (collection of all module assemblies look like this):

<assembly>
    <id>final</id>
    <formats>
        <format>dir</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <moduleSets>
      <moduleSet>
        <useAllReactorProjects>true</useAllReactorProjects>
        <binaries>
            <attachmentClassifier>jar-with-dependencies</attachmentClassifier>
            <outputDirectory>dist/${module.artifactId}</outputDirectory>
            <unpack>false</unpack>
            <includeDependencies>false</includeDependencies>
        </binaries>
      </moduleSet>
    </modulesSets>
</assembly>

This should allow you to change the artifact name for the assembly file only.

Related