我使用Gradle发布到本地Artifactory存储库。我在构建过程中生成了3个jar:一个带有.class的经典jar,一个带有javadoc(-javadoc.jar),另一个带有sources(-sources)。
我将我的二进制jar和javadoc jar发布到一个特定的存储库(一个公共存储库),并将源jar发布到一个私有存储库。
如何配置maven-publish插件来执行此操作?我已经能够定义多个存储库,但Gradle尝试将所有jar都推送到所有存储库:
task sourcesJar(type: Zip, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Zip, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
publishing {
repositories {
maven {
name "binary"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
url "http://192.168.2.167:8081/artifactory/libs-snapshot-local"
}
maven {
name "sources"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
url "http://192.168.2.167:8081/artifactory/sources-snapshot-local"
}
}
publications {
binary(MavenPublication) {
// *** I WANT TO USE THE "binary" REPOSITORY HERE ****
from components.java
artifact javadocJar
}
sources(MavenPublication) {
// *** I WANT TO USE THE "sources" REPOSITORY HERE ***
artifact sourcesJar
}
}
}
也许我错过了什么,但似乎不可能。