Can not set the final jar name with maven-assembly-plugin

JavaMavenMaven 3

Java Problem Overview


This is how I configured maven-assembly-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <finalName>myapp</finalName>
        <archive>
            <manifest>
                <mainClass>com.myapp.Main</mainClass>
            </manifest>
        </archive>
        <!--
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        -->
    </configuration>
</plugin>

and I expect the final jar file should be myapp.jar but it ends up with myapp-jar-with-dependencies.jar

Can you tell me how to configure to exclude "jar-with-dependencies" out of the final name?

Java Solutions


Solution 1 - Java

You can specify the finalName property to give the jar the name you want, and specify that appendAssemblyId should be false to avoid the jar-with-dependencies suffix. The configuration below will output a jar called test.jar

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <finalName>test</finalName>
                <archive>
                    <manifest>
                        <mainClass>com.myapp.Main</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
               <appendAssemblyId>false</appendAssemblyId>
            </configuration>
         </plugin>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTruong HaView Question on Stackoverflow
Solution 1 - JavasasankadView Answer on Stackoverflow