【问题标题】:Maven artifact version number in jar filejar 文件中的 Maven 工件版本号
【发布时间】:2012-01-03 11:16:30
【问题描述】:

我正在使用 Maven 3 构建 xxx-common 模块

构建应用程序后,我的 jar 文件为 xxx-common-0.0.1.jar

这将被部署到我的工件中

http://localhost:8800/artifactory/core-release/com/xxx/xxx-common/0.0.1/xxx-common-0.0.1.jar

那个部署很好,

在这里,我怎样才能消除附加“ xxx-common-0.0.1.jar ”的版本号并需要它就像“ xxx-common.jar ”

请大家帮忙解决这个问题...


对不起,没有成功

下面是我给的……

<plugins>

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


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin> 

        </plugins>

使用

执行

mvn 包

和

安装 /home/xxx/build-deploy-tools/.jenkins/jobs/workspace/xxx-common/target/xxx-common.jar 到 /home/xxx/.m2/repository/com/xxx/xxx- common/0.0.1/xxx-common-0.0.1.jar

仍然作为 xxx-common-0.0.1.jar 推送

【问题讨论】:

标签: java maven


【解决方案1】:

在您的存储库中,您永远无法摆脱数字。在您的目标目录中,您可以在Maven JAR Plugin 的配置中使用finalName 元素。

【讨论】:

    【解决方案2】:

    您可以在项目的outputFileNameMapping 配置选项中定义它。

    此选项默认为

    ${module.artifactId}-${module.version}${dashClassifier?}.${module.extension}
    

    因此,在您的情况下,您可以将其更改为

    ${module.artifactId}.${module.extension}
    

    参考:http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

    【讨论】:

    • 完全没有理由相信 OP 正在使用程序集插件。
    猜你喜欢
    • 2012-01-29
    • 2011-02-11
    • 2012-03-23
    • 2012-02-08
    • 2017-02-01
    • 2014-08-09
    • 1970-01-01
    • 2020-03-13
    • 2012-02-19
    相关资源
    最近更新 更多