Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sub-sub-projects with same name in does not work for eclipse

Tags:

eclipse

gradle

I have the following structure

root
|- foo    
|  |- implementation
|  |   \- build.gradle
|  \- interface
|      \- build.gradle
|
|- bar
|  |- implementation
|  |   \- build.gradle
|  \- interface
|      \- build.gradle
|
|- build.gradle
\- settings.gradle

in settings.gradle I have the following:

include ':foo:implementation', ':foo:interface'
include ':bar:implementation', ':bar:interface'

in my build.gradle on the root folder I put all of them as a dependency

dependencies { 
    compile project(':foo:implementation')
    compile project(':foo:interface')
    compile project(':bar:implementation')
    compile project(':bar:interface')
}

Eclipse needs each project to have distinct names. Gradle by default uses the project name to name these in eclipse. Thus eclipse is unable to distinguish between ':foo:implementation' and ':bar:implementation:' as they both will be named 'implementation' inside Eclipse. In my mind this should have been solvable by setting the eclipse project name to something more specific, e.g.:

allprojects {
    eclipse.project {
        if (project == rootProject) {
            name = rootProject.name
        } else {
            name = rootProject.name + project.path.replace(":", "-")
        }
    }
}

With this I get unique project names, but when I look at the .classpath xml only one of the implementation projects and one of the interface projects are present.

Any idea?

like image 863
Knut Saua Mathiesen Avatar asked Oct 16 '14 14:10

Knut Saua Mathiesen


1 Answers

So far, I've only been working with "single dir level" multiprojects; For that scenario, there are several ways to fix it:

  • If you want to fix it for eclipse only and if you're using the "import gradle project" wizard, you might want to set the "Use hierarchical project names" check box. Not sure how it behaves in your case (double dir level)
  • Next one can hopefully help you out: how to rename the project in gradle instead of using folder name?. Probably with some extra investigation for your double dir level. It will also change the gradle project names BTW
  • And indeed, The eclipse plugin also provides means to change project names, haven't used it myself though...
like image 177
roomsg Avatar answered Oct 17 '22 18:10

roomsg