通过gradle上传到artifactory时如何更改jar文件名 [英] How to change the jar filename when upload to artifactory via gradle

查看:64
本文介绍了通过gradle上传到artifactory时如何更改jar文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gradle 将 jar 上传到 artifactory.我设法做到了,但是我正在尝试更改 jar 文件名,但它并没有真正让我这样做.

I am using gradle in order to upload jar to artifactory. I managed to do it however I am trying to change the jar filename but it doesnt really let me.

我正在使用 shadowJar 进行打包.我就是这样做的:

I am using shadowJar to package. this is how I do it:

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow'



    shadowJar {
        classifier = ''
        baseName = 'com.mycompany.app-all'
        manifest {
            attributes 'Main-Class': 'com.mycompany.app.main.starter'
        }
    }


publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.shadow

            groupId 'com.mycompany'
            artifactId "app"
            version "${build_version}"
        }
    }
}

现在,如果 build_version=2.1,那么 artifactory 上的目录将如下所示:

Now if build_version=2.1 than the dirs on artifactory will look like this:

http://repo.address:8081/artifactory/libs-release-local/com/mycompany/app/2.1/app-2.1.jar

我想保留文件夹结构但更改 jar 文件名(如 shadowJar 中定义)

I would like to keep the folder structure but change the jar filename(as defined in shadowJar)

并以这种方式实现:

http://repo.address:8081/artifactory/libs-release-local/com/mycompany/app/2.1/com.mycompany.app-all.jar

有什么想法吗?

推荐答案

Jar 任务默认命名约定是

The Jar task default naming convention is

[baseName]-[appendix]-[version]-[classifier].[extension]

如果您只设置基本名称,其余的值会附加到它上面.要覆盖,请设置 archiveName 而不是 baseName

If you set just the basename, the remaining values get appended to it. To override, set archiveName instead of baseName

shadowJar {
    ...
    archiveName = 'com.mycompany.app-all'
    ...
}

更改对发布的工件的命名:

To change naming on what artifactory is publishing:

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.shadow

            groupId 'com.mycompany'
            artifactId 'com.mycompany.app-all' //<-- changed here
            version ''                         // and here
        }
    }
}

这篇关于通过gradle上传到artifactory时如何更改jar文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆