I had quite good gradle configuration, that built everything just fine. But one of the projects of my multi-project build derived from the rest of them so much, that I would gladly move it to another git repo and configure submodules to handle it.
First, I moved Project and its resources to subfolder Libraries/MovedProject
. After altering some lines in gradle configurations it worked fine. But then I decided to write a new build.gradle just for this project, and move all configurations there from the main one.
And this is where everything stopped working. When I try to call any task it always ends
with Could not find property 'sourceSets' on project ':Libraries/MovedProject'
. Line which is responsible for it is:
dependencies {
...
if (noEclipseTask) {
testCompile project(':Libraries/MovedLibrary').sourceSets.test.output
}
}
which I use for running tests in which I use classes from other projects. If I remove that line, the build fails only when it reaches compileTestJava task of projects that make use of MovedProject. If I remove that line and call gradle :Libraries/MovedLibrary:properties
I can see :
...
sourceCompatibility: 1.7
sourceSets: [source set main, source set test]
standardOutputCapture: org.gradle.logging.internal.DefaultLoggingManager@1e263938
...
while gradle :Libraries/MovedLibrary:build
builds correctly.
Currently I've got everything set up as following:
directories:
- /SomeMainProject1
- /SomeMainProject2
- /SomeMainProject3
- /Libraries
- /MovedProject
- build.gradle
- dependencies.gradle
- project.gradle
- tasks.gradle
- /MovedProject
- /Builder
- dependencies.gradle
- project.gradle
- tasks.gradle
- build.gradle
- settings.gradle
settings.gradle
include Libraries/MovedProject, SomeMainProject1, SomeMainProject2, SomeMainProject3
sourceSets for MovedProject are defined in
Libraries/MovedProject/project.gradle
:sourceSets { main { java { srcDir 'src' srcDir 'resources' } resources { srcDir 'resources' } } test { java { srcDir 'test/unit' } } }
dependencies that makes use of sourceSets.test.output are stored in
Builder/dependancies.gradle
, and set for each project that needs MovedProject to run tests:project(':SomeMainProject1') { dependencies { ... if (noEclipseTask) { testCompile project(':Libraries/net.jsdpu').sourceSets.test.output } } }
What would be the easiest way to get rid of that error and make gradle build projects with current directory structure? I would like to understand why gradle cannot see that property.
project.evaluationDependsOn()
property. I guess that solution is dirty, but I have to stick to it for a while. – Rea