Reputation: 627
I'm working in a multiproject system (with 40+ subprojects). Each subproject has its own layout (most follows a common layout, but some differ). Among the subprojects I have these two:
- testjunit
- sourceSets
- lptfExperimental
- other source sets
- basicservices
- sourceSets
- testacceptance
- other source sets
I need to make the source set basicservices-testacceptance
depend on the output of source set testjunit-lptfExperimental
.
I tried to do:
dependencies{
testacceptanceCompile project(':testjunit').sourceSets.lptfExperimental.output
}
And
dependencies{
project.parent.subprojects.each{prj ->
if(prj.name == "testjunit")
testacceptanceCompile prj.sourceSets.findByName('lptfExperimental').output
}
But in both cases I receive the following error:
FAILURE: Build failed with an exception.
Where: Script 'C:\Development\defaults.gradle' line: 144
What went wrong: A problem occurred evaluating script. Could not find property 'lptfExperimental' on SourceSet container.
Just an extra info: this dependency is declared in a file named defaults.gradle
that is applied in build.gradle
of project basicservices
.
apply plugin: 'java'
apply plugin: 'eclipse'
...
sourceSets {
...
// test acceptance
testacceptance{
java{
srcDir 'test/acceptance/src/java'
}
resources {
srcDir 'test/acceptance/src/java'
}
}
...
}
// default dependencies
dependencies{
testacceptanceCompile project(':testjunit')
testacceptanceCompile project(':testjunit').sourceSets.lptfExperimental.output
}
...
...
sourceSets{
...
lptfExperimental{
java {
srcDir 'lptf-experimental/src/java'
}
resources {
srcDir 'lptf-experimental/src/java'
}
}
...
apply plugin: 'java'
apply plugin: 'eclipse'
apply from: '../defaults.gradle'
dependencies{
...
compile project(':testjunit')
...
}
Upvotes: 5
Views: 2941
Reputation: 627
I could solve the problem with the solution mentioned in this question.
Basically, I added a directive evaluationDependsOn(':testjunit')
in defaults.gradle
. It solved the problem. The reference for this directive is here.
Upvotes: 2