'maven jar plugin with specific filename not work

I am trying to use maven jar a file with a specific filename.

<fileName>
     ${project.build.directory}/${project.artifactId}-${project.version}-SAMLGroupAPI.jar
</fileName>

Plugin config:

<artifactId>maven-jar-plugin</artifactId>
   <executions>
    <execution>
        <id>SAMLGroupAPI</id>
        <phase>package</phase>
        <goals>
            <goal>jar</goal>
        </goals>
        <configuration>
            <archive>
                <index>true</index>
                <manifest>
                    <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                </manifest>
            </archive>

            <classifier>SAMLGroupAPI</classifier> 
            <includes>
                <include>com/x/enterprise/webframework/security/api/*</include>
            </includes>
            <fileName>
                    ${project.build.directory}/${project.artifactId}-${project.version}-SAMLGroupAPI.jar
            </fileName>
        </configuration>
    </execution>

   </executions>
 </plugin>

But the generated jar filename doesn't have the version number in it as expected.

[INFO] Building jar: /opt/shared/atlassian/bamboo/xml-data/build-dir/XSTAR-WF75-JOB1/webframeworkWeb/target/webframeworkWeb-SAMLGroupAPI.jar

build   10-Mar-2017 11:56:05    [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar' with basic configurator -->
build   10-Mar-2017 11:56:05    [DEBUG]   (s) index = true
build   10-Mar-2017 11:56:05    [DEBUG]   (s) addDefaultImplementationEntries = true
build   10-Mar-2017 11:56:05    [DEBUG]   (s) manifest = org.apache.maven.archiver.ManifestConfiguration@7286adfd
build   10-Mar-2017 11:56:05    [DEBUG]   (f) archive = org.apache.maven.archiver.MavenArchiveConfiguration@da0da139
build   10-Mar-2017 11:56:05    [DEBUG]   (f) classesDirectory = /opt/shared/atlassian/bamboo/xml-data/build-dir/XSTAR-WF75-JOB1/webframeworkWeb/target/classes
build   10-Mar-2017 11:56:05    [DEBUG]   (f) classifier = SAMLGroupAPI
build   10-Mar-2017 11:56:05    [DEBUG]   (f) finalName = webframeworkWeb
build   10-Mar-2017 11:56:05    [DEBUG]   (f) forceCreation = false
build   10-Mar-2017 11:56:05    [DEBUG]   (f) includes = [com/x/enterprise/webframework/security/api/*]
build   10-Mar-2017 11:56:05    [DEBUG]   (f) outputDirectory = /opt/shared/atlassian/bamboo/xml-data/build-dir/XSTAR-WF75-JOB1/webframeworkWeb/target
build   10-Mar-2017 11:56:05    [DEBUG]   (f) project = MavenProject: com.csx:webframeworkWeb:2.0.1-SNAPSHOT @ /opt/shared/atlassian/bamboo/xml-data/build-dir/XSTAR-WF75-JOB1/webframeworkWeb/pom.xml
build   10-Mar-2017 11:56:05    [DEBUG]   (f) session = org.apache.maven.execution.MavenSession@489efed2
build   10-Mar-2017 11:56:05    [DEBUG]   (f) skipIfEmpty = false
build   10-Mar-2017 11:56:05    [DEBUG]   (f) useDefaultManifestFile = false
build   10-Mar-2017 11:56:05    [DEBUG] -- end configuration --
build   10-Mar-2017 11:56:05    [DEBUG] isUp2date: false (Destination /opt/shared/atlassian/bamboo/xml-data/build-dir/XSTAR-WF75-JOB1/webframeworkWeb/target/webframeworkWeb-SAMLGroupAPI.jar not found.)
build   10-Mar-2017 11:56:05    [INFO] Building jar: /opt/shared/atlassian/bamboo/xml-data/build-dir/XSTAR-WF75-JOB1/webframeworkWeb/target/webframeworkWeb-SAMLGroupAPI.jar
build   10-Mar-2017 11:56:05    [DEBUG] adding directory META-INF/

Any suggestions?



Solution 1:[1]

It's possible, I'm using maven-jar-plugin 3.2.0

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <finalName>${project.artifactId}-${project.version}-SAMLGroupAPI</finalName>
                </configuration>
            </plugin>

Solution 2:[2]

You could try to use the build tag instead. There is an inner tag called finalName and you could put on that the jar's filename.

It would be like this:

<build>
        <finalName>${project.build.directory}/${project.artifactId}-${project.version}-SAMLGroupAPI.jar</finalName>  
</build>

Take on mind to use this at the main scope.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 coinfaces
Solution 2 Eduardo Thomaz