gpt4 book ai didi

gradle - 将依赖项添加到gradle任务组

转载 作者:行者123 更新时间:2023-12-03 03:09:05 27 4
gpt4 key购买 nike

我有一个项目,其中包含许多发布任务:

Publishing tasks
----------------
generatePomFileForMavenJavaPublication - Generates the Maven POM file for publication 'mavenJava'.
generatePomFileForMavenPublication - Generates the Maven POM file for publication 'maven'.
publish - Publishes all publications produced by this project.
publishMavenJavaPublicationToMavenLocal - Publishes Maven publication 'mavenJava' to the local Maven repository.
publishMavenJavaPublicationToMavenRepository - Publishes Maven publication 'mavenJava' to Maven repository 'maven'.
publishMavenPublicationToMavenLocal - Publishes Maven publication 'maven' to the local Maven repository.
publishMavenPublicationToMavenRepository - Publishes Maven publication 'maven' to Maven repository 'maven'.
publishToMavenLocal - Publishes all Maven publications produced by this project to the local Maven cache.

现在,我希望所有这些任务都依赖于 build,以确保在发布任何内容之前运行测试和检查(默认情况下,发布任务取决于 assemble)。

当然,以下作品:
publish.dependsOn(build)
publishToMavenLocal.dependsOn(build)

但是维护起来很麻烦,并且不适用于任何生成的任务,例如 publishMavenPublicationToMavenRepository是否可以向所有发布任务添加依赖项? 当然,我尝试了 publishing.dependsOn(build),但是它只是说:
Could not find method dependsOn() for arguments [task ':build'] on org.gradle.api.publish.internal.DefaultPublishingExtension_Decorated@5b5f8cd6.

最佳答案

无法定义组依赖关系,但是您可以尝试:

tasks.findAll { it.name.startsWith('publish') }*.dependsOn(DA_TASK)

关于gradle - 将依赖项添加到gradle任务组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31560078/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com