Merge pull requests #183 and #190

# By Rob Winch
# Via Rob Winch
* gradle-1116:
  Make GRADLE-1116 workaround more generic

# By Rob Winch
* spring-test-mvc-classpath:
  Fix spring-test-mvc Eclipse classpath
This commit is contained in:
Chris Beams 2012-11-27 09:09:16 +01:00
commit 2deeb54a9b
4 changed files with 51 additions and 28 deletions

View File

@ -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")) {
@ -532,14 +528,17 @@ project('spring-webmvc-tiles3') {
compile("javax.servlet:jstl:1.1.2", provided)
compile("javax.servlet.jsp:jsp-api:2.1", provided)
compile("org.apache.tiles:tiles-request-api:1.0.1", optional)
compile("org.apache.tiles:tiles-request-servlet-wildcard:1.0.1", optional)
compile("org.apache.tiles:tiles-request-servlet-wildcard:1.0.1") { dep->
optional dep
exclude group: 'org.springframework', module: 'spring-web'
}
compile("org.apache.tiles:tiles-api:3.0.1", optional)
compile("org.apache.tiles:tiles-core:3.0.1", optional)
compile("org.apache.tiles:tiles-servlet:3.0.1", optional)
compile("org.apache.tiles:tiles-jsp:3.0.1", optional)
compile("org.apache.tiles:tiles-el:3.0.1", optional)
compile("org.apache.tomcat:tomcat-servlet-api:7.0.32", provided) // servlet-api 3.0
testCompile project(":spring-web").sourceSets*.output // mock request & response
compile project(":spring-web").sourceSets*.output // mock request & response
}
}
@ -593,6 +592,7 @@ project('spring-test-mvc') {
description = 'Spring Test MVC Framework'
ext.mergeIntoProject = project(':spring-test')
apply from: "${gradleScriptDir}/merge-artifacts.gradle"
apply from: "ide.gradle"
dependencies {
compile project(":spring-context")
compile project(":spring-webmvc")

26
gradle/ide.gradle Normal file
View File

@ -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/) }
}

View File

@ -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 {

View File

@ -0,0 +1,7 @@
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
// SPR-10042
eclipse.classpath.file.whenMerged { classpath ->
def projectName = 'spring-webmvc-tiles3'
classpath.entries.add(0, new ProjectDependency("/${projectName}", project(":${projectName}").path))
}