Multi-project build awkward behaviour (broken build)

Hi there, I think I have fallen into another multi-project hell.

We hade a flat multi-project set up which seemed to cause issues so i decided to go for traditional hierarchical set up like this one.

main
 +-- build.gradle
 +-- settings.gradle
 +-- projectA (web app)
     +-- build.gradle (depends on B and C)
 +-- projectB (lib)
     +-- build.gradle (depends C)
 +-- projectC (another lib)
     +-- build.gradle

Now I am facing something very weird.

When building my projects (gradlew clean ;projectX:build) C compiles fine (and produces a jar) B seems to be comiling fine (but do not produce a jar file) A does not compile and complains it cannot find symbols from B.

If I remove all references to B in A (but kep references to C) it does compile fine.

Regardless of what I do (especially if I do a clean first), ProjectB:jar is always “UP-TO-DATE”…

Here is a typical ouput :

$ gradlew clean :projectA:build
:clean
:projectA:clean
:projectC:clean
:projectB:clean
:projectC:compileJava
:projectC:processResources
:projectC:classes
:projectC:jar
:projectB:compileJava
:projectB:processResources
:projectB:classes
:projectB:jar UP-TO-DATE
         ( <<<< always UP-TO-DATE !)
:projectA:compileJava
:projectA:processResources
:projectA:classes
:projectA:war
:projectA:assemble
:projectA:compileTestJava UP-TO-DATE
:projectA:processTestResources UP-TO-DATE
:projectA:testClasses UP-TO-DATE
:projectA:test UP-TO-DATE
:projectA:check UP-TO-DATE
:projectA:build

I suspect that there is something wrong with project B but I just cannot figure out what…

Any help would be much appreciated, I spent the last 12 hours trying to sort this out and my eyes ache ;).

Many thanks in advance. JM

I would think we’d need to see the build script and structure for projectB.

Here it is :

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
  /***********************************************************************************************/
/*** Project specific section : define project specific properties in the below section only ***/
/***********************************************************************************************/
sourceCompatibility = 1.5
version = '0.0.1'
description = 'Data package for access to database J1'
  project.ext {
    niceName = 'CS Data Access'
 sonarKey = 'cs.data'
 artefactBaseName = 'cs-data'
}
  /***********************************************************************************************/
/***
                         End of project specific section
                             ***/
/***********************************************************************************************/
  jar {
    manifest {
        attributes 'Implementation-Title': project.artefactBaseName, 'Implementation-Version': version
    }
            destinationDir =
new File ("${project.buildDir}/libs")
    baseName = project.artefactBaseName
}
  repositories {
    mavenCentral()
}
  dependencies {
      compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
          compile("org.springframework:spring-orm:4.0.2.RELEASE")
    compile("org.springframework.data:spring-data-jpa:1.5.0.RELEASE")
    compile("org.hibernate:hibernate-entitymanager:4.3.4.Final")
    compile("com.fasterxml.jackson.core:jackson-annotations:2.3.2")
    compile 'org.apache.commons:commons-lang3:3.3.1'
          compile project(':csCommons')
          }
  test {
    systemProperties 'property': 'value'
        ignoreFailures = true
       testLogging {
        // Show that tests are run in the command-line output
        events 'started', 'passed'
        showStandardStreams = true
    }
}
  javadoc {
    title = "${project.niceName}
(${project.artefactBaseName} v${project.version}) "
}
    /*
* The below avoids Jenkins failing the build when no test is run
 * (http://stackoverflow.com/questions/13879667/how-to-fix-test-reports-were-found-but-none-of-them-are-new-did-tests-run-in)
*/
task touchTestResults{
    inputs.files test.outputs.files
    doLast{
        def timestamp = System.currentTimeMillis()
        def reportsDir = file(test.getReports().getJunitXml().getDestination())
        if (reportsDir.exists()) {
            test.getReports().getJunitXml().getDestination().eachFile { it.lastModified = timestamp }
        }
     }
}
    build.dependsOn(touchTestResults)
      task wrapper(type: Wrapper) {
    gradleVersion = '1.12'
}

Ok, I finally got out of this mess by deleting the .gradle directory in the main project.

It seems I have to do this each time I change my project setup/architecture (in gradle).

Not sure if it is a sort of cache, and not sure why, but this leads to looking for issue in the wrong direction.

JM