gradle:如何找到实现特定任务的插件?

时间:2017-04-04 00:03:00

标签: gradle

我的构建中使用了一堆gradle插件。反过来,这些插件中的许多都使用其他插件。我想弄清楚实现特定任务的插件。是否有一个核心的gradle任务来找到它?感谢。

2 个答案:

答案 0 :(得分:0)

没有核心任务会告诉您哪个插件负责哪个任务。您可以通过运行来查看所有可用任务:

gradle tasks

但是日志中有一些提示。如果使用--debug开关运行构建,则可以在解决插件依赖关系后看到正在注册的任务:

10:20:25.847 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Found artifact 'gradle-release.jar (net.researchgate:gradle-release:2.3.5)' in resolver cache: C:\g\caches\modules-2\files-2.1\net.researchgate\gradle-release\2.3.5\8045af5040f3efa88abbc5879fd51cf1634a2536\gradle-release-2.3.5.jar
10:20:26.041 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.release' (hidden = false)
10:20:26.076 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.createScmAdapter' (hidden = false)
10:20:26.086 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.initScmAdapter' (hidden = false)
10:20:26.086 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.checkCommitNeeded' (hidden = false)
10:20:26.087 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.checkUpdateNeeded' (hidden = false)
10:20:26.088 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.unSnapshotVersion' (hidden = false)
10:20:26.088 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.confirmReleaseVersion' (hidden = false)
10:20:26.089 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.checkSnapshotDependencies' (hidden = false)
10:20:26.091 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.runBuildTasks' (hidden = false)
10:20:26.093 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.preTagCommit' (hidden = false)
10:20:26.094 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.createReleaseTag' (hidden = false)
10:20:26.094 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.updateVersion' (hidden = false)
10:20:26.095 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.commitNewVersion' (hidden = false)
10:20:26.127 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.beforeReleaseBuild' (hidden = false)
10:20:26.128 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project : - Registering model element 'tasks.afterReleaseBuild' (hidden = false)

这将告诉您此插件(gradle release)依赖项注册的任务。

答案 1 :(得分:0)

你可以打印每个插件和每个任务的类名,希望包能给你一个提示

例如:

task printStuff {
    doLast {
        plugins.all { Plugin plugin ->
            println "Plugin: ${plugin.class.name}"
        }
        tasks.all { Task task ->
            println "Task: ${task.class.name} (name=${task.name})"
        }
    }
}