Search code examples
javagradlesubproject

Gradle subproject not included in classpath


We have a set up with 2 project, 1 main and 1 subproject, they are Java projects. They are all under the same directory.

Here is how the directory structure looks like :

 ./dev
   ./Project_A
     build.gradle
     settings.gradle
   ./Project_B
     build.gradle

Project_A includes Project_B.

Project_A settings.gradle looks like :

includeFlat 'Project_B'

Project_A build.gradle contains :

compile project(':Project_B')   

The issue Project_A misses the classes from Project_B when compiling from command line (gradlew clean build). It looks like Project_B does not belong to Project-A's classpath.

Here is (a part of the ouput) from gradlew clean build ran in Project_A directory (after that it is all "package project_b.x.y missing" and "cannot find symbol" (from Project_B) :

:clean
:Project_B:clean
:Project_B:compileJava
:Project_B:processResources
:Project_B:classes
:Project_B:jar UP-TO-DATE
:compileJava
...Starts erroring out here...

I would guess it is a classpath issue, but I just cannot figure out how to fix it.

Thanks in advance, JM

PS : edited question as I was able to reproduce the issue with a 2 projects build (from 3 initally)


Solution

  • Ok, in case this is useful to someone, I finally got this working with actually removing (git rm) the .claspath file. It was in the .gitignore, but for some reason, it seems it had been comitted at some point and was playing around.

    After doing this and re-importing the projects in Eclipse everything went back to normal.

    Thanks to the ones who tried to help.