我目前有一个现有的eclipse多模块项目。该项目是文件系统角度的所有兄弟,但具有以下项目依赖关系树:
eclipseProject1 eclipseProject2 eclipseProject3
我现在想添加一个新的父项目gradleProject1,它将eclipseProject1(以及eclipseProject2和eclipseProject3)作为子项目。我希望新项目成为一个使用gradle eclipse plugin的gradle项目,它允许生成eclipse .project和classpath文件,以及如果它们已经存在于gradle DSL中用于gradle eclipse插件,则可以对它们进行tweeking。
以下是我的DSL的样子:
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'])
}
}
}
}
这一切都很好,但是当我运行汇编任务时,我得到错误,表明我的子项目不包含在gradleProject1中作为依赖项。我怎样才能解决这个问题?
答案 0 :(得分:0)
这对我有用....
首先添加eclipse子项目产生jar输出的文件夹:
repositories {
mavenCentral()
//Pickup dependencies from subprojects
flatDir {
dirs '../eclipseProject1/output', '../eclipseProject2/output', '../eclipseProject3/output'
}
}
接下来在依赖项部分添加jar,如下所示:
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.+'
}