Gradle multiproject doesn't add projects to classpath


(Eric) #1

I have some projects that depend on others. I also have a project that depends on two projects that each one depends on the same project. Something like this:

Root project 'ProjectA'
+--- Project ':ProjectB'
|    \--- Project ':ProjectB:Project1'
|         +--- Project ':ProjectB:Project1:Project2'
|         \--- Project ':ProjectB:Project1:Project3'
\--- Project ':ProjectC'
     \--- Project ':ProjectC:Project1'
          +--- Project ':ProjectC:Project1:Project2'
          \--- Project ':ProjectC:Project1:Project3'

And the structure of the workspace is like this:

-ProjectA
-ProjectC
-Project1
-Project2
[...]

All the projects are at the same level.

So in the settings.gradle in my ProjectB I have:

include ':Project1',':Project1:Project2',[...]
project(':Project1') = new File('../Project1')
project(':Project2') = new File('../Project2')
project(':Project1:Project2') = new File('../Project2')
project(':Project1:Project3') = new File('../Project3')

And in the build.gradle of ProjectA I do:

dependencies{ compile project('ProjectB'),project('ProjectC') }

The problem is that it is not correctly added to the classpath. I think since both ProjectB and ProjectC depends on Project1 and Project2 it is overwritten somehow. Any ideas?

Thanks.


(Eric) #2

What I finally did is change in the classpath the paths that where wrong like this:

build.gradle

eclipse{
classpath{
    file{
         whenMerged { classpath ->

            classpath.entries.find { entry -> 
                entry.kind == 'src' && entry.path.contains('ProjectC')
            }.each{ entry ->
                entry.path=file("/ProjectC")
            }



        }
    }
}