具有特定文件名的maven jar插件不起作用

时间:2017-03-10 18:41:51

标签: java maven jar filenames

我正在尝试使用maven jar一个具有特定文件名的文件。

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

插件配置:

<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>

但生成的jar文件名没有预期的版本号。

[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/

有什么建议吗?

1 个答案:

答案 0 :(得分:-1)

您可以尝试使用build标记。有一个名为finalName的内部标记,你可以把jar文件名放在那里。

就像这样:

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

请记住在主要范围内使用它。