简体   繁体   中英

In Gradle, associating task with a dependency configuration

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM