Multi projects not building with buildship but ok on command line


(Chryssa Charalambides) #1

I have two projects that I am trying to set up. One project depends on another. I am using eclipse Neon and 2.0.0.v20170111-1029 version of the Buildship plugin. I only get this error when I try to do a refresh gradle project from eclipse. When I build from the command line everything woks fine. The error is:
Project with path ‘:CMF:common-base’ could not be found in project ‘:mag’.

Here is my project structure

CMF
|common-base
|-- build.gradle
|-- settings.gradle
mag
|-- build.gradle
|-- settings.gradle

CMF settings.gradle looks like:
rootProject.name = ‘CMF:common-base’

CMF build.gradle looks like:
apply plugin: 'java’
apply plugin: ‘eclipse’

jar {
baseName = 'CMF:common-base’
version = ‘0.1’
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile fileTree(dir: ‘lib’, include: ‘*.jar’)
compile group: ‘org.jppf’, name: ‘jppf-common’, version: '5.2.1’
compile group: ‘org.jppf’, name: ‘jppf-client’, version: '5.2.1’
compile group: ‘org.jppf’, name: ‘jppf-node’, version: '5.2.1’
compile group: ‘mysql’, name: ‘mysql-connector-java’, version: '5.1.+'
compile group: ‘net.sourceforge.jexcelapi’, name: ‘jxl’, version: '2.6.12’
compile group: ‘log4j’, name: ‘log4j’, version: ‘1.2.9’
}

mag settings.gradle looks like:
rootProject.name = ‘mag’
include ‘:CMF:common-base’
project(’:CMF:common-base’).projectDir = new File(settingsDir, ‘…/CMF/common-base’)

mag build.gradle looks like:
apply plugin: 'java’
apply plugin: ‘eclipse’

jar {
baseName = 'mag’
version = ‘0.1’
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile project(’:CMF:common-base’)
compile fileTree(dir: ‘lib’, include: ‘*.jar’)
compile group: ‘org.jppf’, name: ‘jppf-common’, version: '5.2.1’
compile group: ‘org.jppf’, name: ‘jppf-client’, version: '5.2.1’
compile group: ‘org.jppf’, name: ‘jppf-node’, version: '5.2.1’
compile group: ‘mysql’, name: ‘mysql-connector-java’, version: '5.1.+'
compile group: ‘net.sourceforge.jexcelapi’, name: ‘jxl’, version: '2.6.12’
compile group: ‘log4j’, name: ‘log4j’, version: ‘1.2.9’
}

Both of these projects are Git projects. The odd thing is that I have another project on my workspace and when I switch the dependencies to that project (by only updating the project name in the gradle scripts) everything works fine. What am I missing here? Is it my project structure?


(Stefan Oehme) #2

Every subproject can only be part of one build. If you want to reuse them, either:

  • make it one big project with one root in one repository
  • use binary dependencies for integration and composite builds to combine them locally when needed

(Chryssa Charalambides) #3

I am not sure what you are suggesting here. I am new to Gradle. I am not reusing any of the projects, am I? Just have project B that depends on project A and trying to link them. How is it working from the command line and not from Buildship?


(Stefan Oehme) #4

You have two builds mag and CMF. CMF:common-base is a subproject of the CMF build. You cannot also make it a subproject of the mag build. It happens to work on the command line because Gradle cannot detect this misconfiguration, but it is not a supported usage. You have two options:

Option 1: You can create a root project that contains CMF and mag and everything below them as subprojects. Then you can use a project() dependency.

Option 2: If you want to keep them in separate repositories, then mag should reference common-base as a binary dependency. You can then use the composite build feature to combine those two builds when you want to work with both of them at the same time.

The decision really depends on whether these two belong together or whether they have different release schedules/versions/teams.