Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make one source set dependent on another

Tags:

I have an integration test source set in gradle, and it is dependent on my main classes being compiled. I set that up by doing

integrationTestClasses.dependsOn 'classes' 

Is this the way to do it, or is there a way to setup dependencies on source sets so this happens automatically? In my configurations block I already have

integrationTestCompile { extendsFrom testCompile } integrationTestRuntime { extendsFrom integrationTestCompile, testRuntime } 
like image 968
Jeff Storey Avatar asked Aug 09 '13 05:08

Jeff Storey


2 Answers

What's missing is:

dependencies {     integrationTestCompile sourceSets.main.output } 

With this in place, task dependencies should be established automatically.

like image 155
Peter Niederwieser Avatar answered Sep 18 '22 17:09

Peter Niederwieser


It is also possible to establish the dependency chain when defining the sourceSets. This worked to setup the "main" sourceSet to depend on a "generated" sourceSet:

// Default sourceSets already created by the java plugin: src/main and src/test // Default content for each sourceSet: /java and /resources sourceSets {     // Adding src/generated     generated     // Setting src/main to depend on the dependencies and output of src/generated     main {         compileClasspath += generated.compileClasspath + generated.output     } } 

The same principle should work to setup "integrationTest" to depend on "main".

like image 24
Ellesmera Avatar answered Sep 18 '22 17:09

Ellesmera