问题描述
我的gradle使用,以便上传罐子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:
的app-2.1.jar
我想保留的文件夹结构,但改变的jar文件名(如shadowJar定义)
I would like to keep the folder structure but change the jar filename(as defined in shadowJar)
和有这样说道:
的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'
...
}
要更改命名什么artifactory的是出版:
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的罐子文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!