我已定义了多个要发布到的存储库,但希望“gradle publish”作业只能部署到其中一些存储库。
E.g。在以下配置中,我希望“gradle publish”将工件部署到repo_a和repo_b但不是repo_c。 只有在激活publishMavenJavaPublicationToRepo_cRepositoryjob时才能部署到repo_c。
这有可能吗?
由于
publishing {
repositories {
maven {
url "https://repo_a/maven-releases/"
credentials {
username 'xxx'
password 'xxx'
}
name "repo_a"
}
maven {
url "https://repo_b/maven-releases/"
credentials {
username 'xxx'
password 'xxx'
}
name "repo_b"
}
maven {
url "https://repo_c/maven-releases/"
credentials {
username 'xxx'
password 'xxx'
}
name "repo_c"
}
}
publications {
mavenJava(MavenPublication) {
....
}
}
}
答案 0 :(得分:0)
您可以尝试使用以下代码段来停用publishMavenJavaPublicationToRepo_cRepository
发布任务(reference):
afterEvaluate {
tasks.withType(PublishToMavenRepository) { task ->
if (task.repository.name == "repo_c") {
task.enabled = false
task.group = null
}
}
}