提交 0751b2cb 编写于 作者: P Phillip Webb

Convert Gradle build to use new propdeps-plugin

Replace existing 'optional' and 'provided' Spring specific build
extensions with a new Gradle propdeps-plugin. Optional and Provided
dependencies are now defined use dependency configurations.

The new plugin does not currently support the notion of optional
runtime dependencies. All optional dependencies are implicitly
part of the 'compile' scope. This is an intentional design decision
that aims to keep both the plugin and the build simple. Since optional
dependencies are non-transitive this restriction should not cause
any real problems for existing users. The only existing dependency
affected is 'commons-io' in the 'spring-beans' project, however, this
was an optional compile scope dependency in the previous Spring 3.1
release.

Both provided and optional dependencies are no longer exported from
generated eclipse .classpath files. This fixes several tests that
would previously fail when running within eclipse. The servlet-api
specific elements of ide.gradle are also no longer required.

Issue: SPR-9656, SPR-10070
上级 7cc406ff
此差异已折叠。
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 }
......
......@@ -57,8 +57,6 @@ gradle.taskGraph.whenReady {
configure(mergeIntoProject.install.repositories.mavenInstaller.pom.scopeMappings) {
addMapping(mapping.priority + 100, mergeIntoProject.configurations."$newConfigName", mapping.scope)
}
mergeIntoProject.optionalDeps += mergeFromProject.optionalDeps
mergeIntoProject.providedDeps += mergeFromProject.providedDeps
}
}
}
apply plugin: "maven"
ext.optionalDeps = []
ext.providedDeps = []
ext.optional = { optionalDeps << it }
ext.provided = { providedDeps << it }
apply plugin: "propdeps-maven"
install {
repositories.mavenInstaller {
......@@ -14,14 +8,6 @@ install {
def customizePom(pom, gradleProject) {
pom.whenConfigured { generatedPom ->
// respect "optional" and "provided" dependencies
gradleProject.optionalDeps.each { dep ->
generatedPom.dependencies.findAll { it.artifactId == dep.name }*.optional = true
}
gradleProject.providedDeps.each { dep ->
generatedPom.dependencies.findAll { it.artifactId == dep.name }*.scope = "provided"
}
// eliminate test-scoped dependencies (no need in maven central poms)
generatedPom.dependencies.removeAll { dep ->
dep.scope == "test"
......
......@@ -26,7 +26,7 @@ task compileJava(overwrite: true) {
aspectPath: configurations.aspects.asPath,
inpath: configurations.ajInpath.asPath,
sourceRootCopyFilter: "**/*.java",
classpath: configurations.compile.asPath) {
classpath: sourceSets.main.runtimeClasspath.asPath) {
sourceroots {
sourceSets.main.java.srcDirs.each {
pathelement(location:it.absolutePath)
......@@ -55,7 +55,7 @@ task compileTestJava(overwrite: true) {
destDir: outputDir.absolutePath,
aspectPath: jar.archivePath,
inpath: configurations.ajInpath.asPath,
classpath: configurations.testRuntime.asPath + configurations.compile.asPath + jar.archivePath) {
classpath: sourceSets.test.runtimeClasspath.asPath + jar.archivePath) {
sourceroots {
sourceSets.test.java.srcDirs.each {
pathelement(location:it.absolutePath)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册