I have a project structure as follows:
|-rootProject |------projectA |-----------src/ |-----------config/ |-----------build.gradle |------projectB |-----------src/ |-----------config/ |-----------build.gradle |------projectC |-----------src/ |-----------config/ |-----------build.gradle |------projectD |-----------src/ |------------------build.gradle |-----------config/
All projects have their own classes and tests. projectA, however, depends on B, C and D for its compilation and tests.
The code that needs projects C and D compiles just fine. The code that needs B does not. They are all being imported for compile project and for testCompile project in a similar way.
The failure in A compiling code that depends on B is a funy one, as it does not “like” the reference to a java enum variable reference. if I import the enum only it is fine. But if I import static or just use the enum, that part of the code gets a "cannot find symbol).
Here is my gradle of project B
sourceSets {
main {
java.srcDirs = [ 'src/packages']
resources.srcDirs = [ 'src/packages',
'src/xml', 'src/scripts', 'src/sql', 'src/generic_reports', 'src/config', 'src/asrc'
]
runtimeClasspath = project.sourceSets.main.compileClasspath +
project.sourceSets.test.compileClasspath +
fileTree("${buildDir}/resources/test") + fileTree("${buildDir}/resources/main") + fileTree("${projectDir}") +
project.sourceSets.test.output + project.sourceSets.main.output
compileClasspath = compileClasspath + configurations.legacy
}
test {
java.srcDirs = [
'src/tests/packages']
resources.srcDirs = [ 'src/tests/packages', 'src/packages', 'src/xml', 'src/scripts', 'src/tests', 'src/testsuite', 'src/sql', 'src/generic_reports', 'src/config', 'src/asrc' ]
runtimeClasspath = project.sourceSets.main.compileClasspath +
project.sourceSets.test.compileClasspath +
fileTree("${buildDir}/resources/test") + fileTree("${buildDir}/resources/main") + fileTree("${projectDir}") +
project.sourceSets.test.output + project.sourceSets.main.output
}
}
evaluationDependsOn(':projectB)
evaluationDependsOn(':projectC')
evaluationDependsOn(':projectD')
dependencies {
compile project(':projectC')
testCompile project (':projectC').sourceSets.test.runtimeClasspath
testCompile project (':projectC').sourceSets.main.compileClasspath
compile project (':projectD')
testCompile project (':projectD').sourceSets.test.runtimeClasspath
compile (project(':projectB')) {
exclude group: 'fidev', module: 'jfidcore'
}
//testCompile project (path: ':stsjava', configuration: 'spi')
//tried, but nothing came out of it
testCompile project (':projectB').sourceSets.main.runtimeClasspath
(...
//more on dependencie)
}
task printClasspath(dependsOn:processResources) {
println "<><>projectA test compile classpath is:- "
sourceSets.test.compileClasspath.getFiles().each { file ->
println "<><>projectA damn file: \"" + file + "\""
}
}
I apparently have what I need in the classpath, the annoying enumeration:
21:02:05 17:02:04.289 [QUIET] [system.out] <><>projectA damn file: "/var/tmp/pjenkbld/jenkins/workspace/ird-trend-continuous-alternative/ird/trend/alternative/src/projectB/src/packages/com/msdw/ird/stsjava/sts/enumz/ExternalSource.java"
The sort of errors I get:
16:41:03 12:41:03.138 [ERROR] [system.err] symbol
: variable UTI
16:41:03 12:41:03.138 [ERROR] [system.err] location: class com.msdw.ird.projectA.itm2sts.service.builder.ParameterizedExternalRefFactoriesTest
16:41:03 12:41:03.138 [ERROR] [system.err]
validateReference(references, UTI, uti.getIdentifier(), _enableUtiBackbridge);
16:41:02 12:41:02.171 [ERROR] [system.err] symbol
: static PriorUTIPrefix
16:41:02 12:41:02.171 [ERROR] [system.err] location: class com.msdw.ird.projectB.sts.enumz.ExternalSource
16:41:02 12:41:02.171 [ERROR] [system.err] import static com.msdw.ird.projectB.sts.enumz.ExternalSource.PriorUTIPrefix;
I am failing to understand what works for the correct import of projects C and D, but not B.
Any suggestions?
Thanks! Petula