diff --git a/build.gradle b/build.gradle index 06d80b0b65..3372a1d34b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.gradle.plugins.ide.eclipse.model.ProjectDependency + buildscript { repositories { maven { url 'http://repo.springsource.org/plugins-release' } @@ -8,21 +10,22 @@ buildscript { } configure(allprojects) { - apply plugin: 'java' - apply plugin: 'eclipse' - apply plugin: 'idea' - - group = 'org.springframework' - - sourceCompatibility=1.5 - targetCompatibility=1.5 - ext.aspectjVersion = '1.6.12' ext.hsqldbVersion='1.8.0.10' ext.junitVersion = '4.11.20120805.1225' // temporary use of snapshot; spring-test // still builds against on 4.10 ext.gradleScriptDir = "${rootProject.projectDir}/gradle" + apply plugin: 'java' + apply plugin: 'eclipse' + apply plugin: 'idea' + apply from: "${gradleScriptDir}/ide.gradle" + + group = 'org.springframework' + + sourceCompatibility=1.5 + targetCompatibility=1.5 + [compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:none'] sourceSets.test.resources.srcDirs = ['src/test/resources', 'src/test/java'] @@ -38,13 +41,6 @@ configure(allprojects) { testCompile "org.hamcrest:hamcrest-all:1.3" testCompile "org.easymock:easymock:2.5.1" } - - // servlet-api (2.5) and tomcat-servlet-api (3.0) classpath entries should not be - // exported to dependent projects in Eclipse to avoid false compilation errors due - // to changing APIs across these versions - eclipse.classpath.file.whenMerged { classpath -> - classpath.entries.findAll { entry -> entry.path.contains('servlet-api') }*.exported = false - } } configure(subprojects - project(":spring-test")) { diff --git a/gradle/ide.gradle b/gradle/ide.gradle new file mode 100644 index 0000000000..623c31c004 --- /dev/null +++ b/gradle/ide.gradle @@ -0,0 +1,26 @@ +import org.gradle.plugins.ide.eclipse.model.ProjectDependency + +eclipse.classpath.file.whenMerged { classpath -> + // servlet-api (2.5) and tomcat-servlet-api (3.0) classpath entries should not be + // exported to dependent projects in Eclipse to avoid false compilation errors due + // to changing APIs across these versions + classpath.entries.findAll { entry -> entry.path.contains('servlet-api') }*.exported = false + + // GRADLE-1116 + def regexp = /.*?\/([^\/]+)\/build\/[^\/]+\/(?:main|test)/ // only match those that end in main or test (avoids removing necessary entries like build/classes/jaxb) + def projectOutputDependencies = classpath.entries.findAll { entry -> entry.path =~ regexp } + projectOutputDependencies.each { entry -> + def matcher = (entry.path =~ regexp) + if(matcher) { + def projectName = matcher[0][1] + def path = "/${projectName}" + if(!classpath.entries.find { e -> e instanceof ProjectDependency && e.path == path }) { + def dependency = new ProjectDependency(path, project(":${projectName}").path) + dependency.exported = true + classpath.entries.add(dependency) + } + classpath.entries.remove(entry) + } + } + classpath.entries.removeAll { entry -> (entry.path =~ /(?!.*?repack.*\.jar).*?\/([^\/]+)\/build\/libs\/[^\/]+\.jar/) } +} \ No newline at end of file diff --git a/gradle/merge-artifacts.gradle b/gradle/merge-artifacts.gradle index 911b0af9c6..fd175ea644 100644 --- a/gradle/merge-artifacts.gradle +++ b/gradle/merge-artifacts.gradle @@ -1,5 +1,3 @@ -import org.gradle.plugins.ide.eclipse.model.ProjectDependency - /** * Will merge the artifacts of the current project into mergeIntoProject. For example, to * bundle spring-test-mvc in spring-test's jars. This script will perform the following @@ -43,14 +41,6 @@ mergeIntoProject."javadoc" { classpath += mergeFromProject.javadoc.classpath } -// GRADLE-1116 -mergeFromProject.eclipse.classpath.file.whenMerged { classpath -> - classpath.entries.removeAll { entry -> entry.path.contains("/${mergeIntoProject.name}/build/") } - def dependency = new ProjectDependency("/${mergeIntoProject.name}", mergeIntoProject.path) - dependency.exported = true - classpath.entries.add(dependency) -} - // Update mergeIntoProject to contain additional configurations that contains all the dependencies from mergeFromProject // so that Maven pom generation works gradle.taskGraph.whenReady {