gradle - 为什么 uploadArchives 没有列在任务列表中?

标签 gradle

我认为uploadArchives是一个由java插件提供的任务。 在我的 build.gradle 中,我使用 java 插件:

apply plugin: 'java'

但是,如果我在命令行上调用 gradle 任务,我将看不到 uploadArchives 任务。

即使不使用 gradle gradletasks --all

uploadArchives 任务在 gradle java 插件文档中列出 请参阅http://www.gradle.org/java_plugin (表11)。

我使用 gradle 版本 1.0-milestone-6。

我可以毫无错误地调用 gradle uploadArchives,但任务未列出。

最佳答案

uploadArchives 任务作为规则添加到您的构建脚本中,而不是按名称显式添加。在“gradletasks”的输出中,您应该看到这一行:

Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.

This means, that for each configuration in your build file, an according uploadTask exist. The java plugin adds an configuration named archives to your build script. By adding the configuration "archives" to your build script explicitly by the java plugin, the uploadArchives task is added implicitly too.

There are scenarios, where gradle can't know what tasks need to be materialized by a rule.

E.g.

tasks.addRule("Pattern: ping<ID>") { String taskName ->
    if (taskName.startsWith("ping")) {
        task(taskName) << {
            println "Pinging: " + (taskName - 'ping')
        }
    }
}

无法确定应该显示哪些 ping 任务,因为它们只是通过“gradle pingServer1 pingServer2 pingServer3”从命令行触发时才实现的

问候, 雷内

关于gradle - 为什么 uploadArchives 没有列在任务列表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8478594/

相关文章:

java - Java : 10. 0.2、Gradle : 4. 7 的 gradle 构建问题

java - 使用 apache CXF 使用 equals/hashCode 方法从 WSDL 生成 POJO

android - Android:gradle中应包含哪个Google Play服务版本

firebase - Gradle:Flutter升级后,assembleDebug任务失败

Android:如何将 AAR 的依赖项构建到 APK 中?

android - 未能解决所有 Google 依赖项

java - 验证使用较新的 JDK 构建的库的 API 级别的向后兼容性

android - AS 3.1.3 gradle-4.1-all.zip找不到com.android.tools.build:gradle:3.0.1

java - 用Maven包装Gradle项目

java - 无法在 Eclipse 中执行 Cucumber jvm 测试