In Gradle, associating task with a dependency conf

2019-09-05 22:01发布

问题:

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.

回答1:

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) }