Reputation: 5316
I current have an existing eclipse multi-module project. The project are all siblings from the file system perspective but have the following project dependency tree:
eclipseProject1 eclipseProject2 eclipseProject3
I would now like to add a new parent project gradleProject1 that has eclipseProject1 (and therefor eclipseProject2 and eclipseProject3) as sub-projects. I would like the new project to be a gradle project using gradle eclipse plugin which allows generating eclipse .project and classpath files as well as tweeking them if they already exist all from gradle DSL for the gradle eclipse plugin.
Here is what my DSL looks like:
eclipse {
//Generates .project file with following in <projects> node
project {
referencedProjects 'eclipseProject1', 'eclipseProject2', 'eclipseProject3'
}
//Generates .classpath with following jars from sub-projects as classpath entries
classpath {
file {
withXml {
def node = it.asNode()
node.appendNode('classpathentry', [kind: 'src', path: '../eclipseProject1/output/gradleProject1.jar'])
node.appendNode('classpathentry', [kind: 'src', path: '../eclipseProject2/output/gradleProject2.jar'])
node.appendNode('classpathentry', [kind: 'src', path: '../eclipseProject3/output/gradleProject3.jar'])
}
}
}
}
This all work pretty nicely but when I run the assemble task I get errors indicating that my subprojects are not included as dependencies in the gradleProject1. How can I fix this?
Upvotes: 0
Views: 813
Reputation: 5316
This worked for me....
First add the folder(s) where eclipse subprojects produce their jar outputs:
repositories {
mavenCentral()
//Pickup dependencies from subprojects
flatDir {
dirs '../eclipseProject1/output', '../eclipseProject2/output', '../eclipseProject3/output'
}
}
Next add the jars in dependency section as follows:
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile group: 'log4j', name: 'log4j', version: '1.2.14'
compile name: 'eclipseProject1'
compile name: 'eclipseProject2'
compile name: 'eclipseProject3'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
Upvotes: 0