如何脚本摇篮才能发布shadowjar到Artifactory的 [英] How to script Gradle in order to publish shadowjar into Artifactory
问题描述
我在我的Java项目中使用shadowJar。
我想推动的结果为artifactory的。
I am using shadowJar in my java project. I would like to push the outcome into artifactory.
我的剧本的gradle这个样子,我不知道怎么连点:
My gradle script look like this, I am not sure how to connect the dots:
shadowJar {
baseName = 'com.mycompany.myapp'
manifest {
attributes 'Main-Class': 'myapp.starter'
}
}
]
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
// rep for the project
repositories {
mavenCentral()
maven {
url 'http://repo.company:8081/artifactory/libs-release'
credentials {
username = "${repo_user}"
password = "${repo_password}"
}
}
maven {
url 'http://repo.company:8081/artifactory/libs-snapshot'
credentials {
username = "${repo_user}"
password = "${repo_password}"
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
}
我如何code gradle这个拿shadowjar文件?
How do I code gradle to take the shadowjar file?
谢谢,
射线。
thanks, ray.
推荐答案
的发表
部分确定你使用的 Maven的发布发布什么
插件。
The publication
section determines what you're publishing using the maven-publish
plugin.
在当前的配置,从components.java
将要发布项目和工件的默认罐子神器 sourceJar
出版sourceJar。为了发布一个不同的罐子,你需要修改(或添加新)发布。
In your current config, from components.java
is going to publish the default jar artifact of your project and artifact sourceJar
publishes the sourceJar. In order to publish a different jar, you need to modify (or add a new) publication.
shadowJar {
baseName = 'myproject-shadow'
classifier = ''
}
publishing {
publications {
shadow(MavenPublication) {
from components.shadow
artifactId = 'myproject-shadow'
}
}
}
在罐子的名称中使用的版本来自project.version。
The version used in the name of the jar comes from project.version.
这篇关于如何脚本摇篮才能发布shadowjar到Artifactory的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!