SEC-2009: Support ./gradlew eclipse

Previously there were problems when importing with ./gradlew eclipse. For
example GRADLE-1116 and GRADLE-1422.

The changes provide workarounds that are compatible with Gradle 1.0. Note
when importing after using ./gradlew eclipse users may get errors stating
"Element not found". This is only at the time of import and can be ignored.
This is an Eclipse bug logged as
https://bugs.eclipse.org/bugs/show_bug.cgi?id=244315
This commit is contained in:
Rob Winch 2012-07-19 17:42:36 -05:00
parent 24c3bdfd90
commit 23ef7dac48
1 changed files with 22 additions and 0 deletions

View File

@ -6,6 +6,28 @@ configure(javaProjects) {
eclipse.classpath.downloadSources = true
// GRADLE-1116
project.eclipse.classpath.file.whenMerged { classpath ->
classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
}
// GRADLE-1422
project.eclipseClasspath.doFirst {
// delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
project.eclipse.classpath.file.whenMerged { classpath ->
def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
classpath.entries.each { cp ->
if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
def include = includeDeps.contains(cp.path)
def attr = 'org.eclipse.jst.component.dependency'
if(!include) {
cp.entryAttributes.remove(attr)
}
}
}
}
}
tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
project.eclipse.classpath.file.whenMerged { classpath->
project.eclipse.wtp.component.file.whenMerged { wtpComponent ->