【问题标题】:Gradle publish repository defaults or ignoresGradle 发布存储库默认值或忽略
【发布时间】:2018-01-05 10:43:36
【问题描述】:

我已经定义了多个要发布到的存储库,但希望“gradle publish”作业仅部署到其中的一些。

例如在以下配置中,我希望“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) {
            ....
        }
    }
}

【问题讨论】:

    标签: gradle publish gradlew


    【解决方案1】:

    您可以尝试以下代码 sn-p 来禁用您的publishMavenJavaPublicationToRepo_cRepository 发布任务(reference):

    afterEvaluate {
      tasks.withType(PublishToMavenRepository) { task ->
        if (task.repository.name == "repo_c") {
            task.enabled = false
            task.group = null
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      • 2013-08-19
      相关资源
      最近更新 更多