在Gradle中,将任务与依赖配置相关联 [英] In Gradle, associating task with a dependency configuration
问题描述
如何将任务关联到特定的依赖配置?
如果我看看 23.5。依赖管理( gradle java插件官方文档)部分,它例如, compileTestJava任务使用 testCompile 配置。
我只是想知道我该如何实现
gradle自动创建这些配置;
如果你定义了一个 sourceSet
,一堆东西会被创建(按照惯例):
sourceSets {
thing
}
定义配置: thingCompile,thingRuntime
任务: compileThingJava,processThingResources,thingClasses
你可能想看看: gradle tasks --all
和 gradle dependencies
如果您想为这些配置添加依赖关系
最好使用生成的配置
你当然可以创建自己的配置并扩展它:配置{thingCompile.extendsFrom(myConfig)}
How can a task be associated to a specific dependency configuration?
If I look the 23.5. Dependency management (gradle java plugin official doc) section part, it states that, for example, compileTestJava task use testCompile configuration.
I just wanted to know how I could achieve that.
gradle is creating these configurations automatically;
if you define a sourceSet
, a bunch of things gets created (by convention):
sourceSets {
thing
}
will define configurations: thingCompile, thingRuntime
tasks: compileThingJava, processThingResources, thingClasses
you might want to look at: gradle tasks --all
and gradle dependencies
if you want to add dependencies to these configurations the most preferable to use the generated ones
you may of course create your own configuration and extend from that: configurations { thingCompile.extendsFrom(myConfig) }
这篇关于在Gradle中,将任务与依赖配置相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!