From 1a2eb99300e5a8a3e6a082097f1fc0abb7085d7e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 13 May 2014 11:14:58 +0100 Subject: [PATCH] Make full use of the propdeps plugin Use the optional and provided configurations provided by the propdeps plugin and remove specific handling of optional and provided dependencies in pom customisation logic in favour of the propdeps-maven plugin. --- publish-maven.gradle | 19 +++++-------------- spring-service-connector/build.gradle | 24 ++++++++++-------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/publish-maven.gradle b/publish-maven.gradle index 98c813c..44c6719 100644 --- a/publish-maven.gradle +++ b/publish-maven.gradle @@ -1,11 +1,5 @@ apply plugin: 'maven' -ext.optionalDeps = [] -ext.providedDeps = [] - -ext.optional = { optionalDeps << it } -ext.provided = { providedDeps << it } - install { repositories.mavenInstaller { customizePom(pom, project) @@ -14,19 +8,16 @@ install { def customizePom(pom, gradleProject) { pom.whenConfigured { generatedPom -> - // respect 'optional' and 'provided' dependencies - gradleProject.optionalDeps.each { dep -> - generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true - } - gradleProject.providedDeps.each { dep -> - generatedPom.dependencies.find { it.artifactId == dep.name }?.scope = 'provided' - } - // eliminate test-scoped dependencies (no need in maven central poms) generatedPom.dependencies.removeAll { dep -> dep.scope == 'test' } + // Ensure consistent ordering of dependencies to ease comparison with older poms + generatedPom.dependencies = generatedPom.dependencies.sort { dep -> + "$dep.scope:$dep.groupId:$dep.artifactId" + } + // add all items necessary for maven central publication generatedPom.project { name = gradleProject.description diff --git a/spring-service-connector/build.gradle b/spring-service-connector/build.gradle index a59327f..3148e21 100644 --- a/spring-service-connector/build.gradle +++ b/spring-service-connector/build.gradle @@ -15,33 +15,29 @@ dependencies { testRuntime("javax.mail:javax.mail-api:$javaxMailVersion") - compile("org.springframework:spring-jdbc:$springVersion", optional) - compile("org.springframework:spring-context-support:$springVersion", optional) - compile("org.apache.tomcat:tomcat-jdbc:$tomcatVersion", optional) - compile("org.apache.tomcat:tomcat-dbcp:$tomcatVersion", optional) - compile("org.apache.commons:commons-dbcp2:$commonDbcp2Version") { - optional + optional("org.springframework:spring-jdbc:$springVersion") + optional("org.springframework:spring-context-support:$springVersion") + optional("org.apache.tomcat:tomcat-jdbc:$tomcatVersion") + optional("org.apache.tomcat:tomcat-dbcp:$tomcatVersion") + optional("org.apache.commons:commons-dbcp2:$commonDbcp2Version") { exclude(module: 'commons-logging') exclude(module: 'xerces') exclude(module: 'xercesImpl') exclude(module: 'xml-apis') } - compile("commons-dbcp:commons-dbcp:$commonDbcpVersion") { - optional + optional("commons-dbcp:commons-dbcp:$commonDbcpVersion") { exclude(module: 'commons-logging') exclude(module: 'xerces') exclude(module: 'xercesImpl') exclude(module: 'xml-apis') } - compile("org.springframework.amqp:spring-rabbit:$springAmqpVersion", optional) - compile("org.springframework.data:spring-data-redis:$springDataRedisVersion") { - optional + optional("org.springframework.amqp:spring-rabbit:$springAmqpVersion") + optional("org.springframework.data:spring-data-redis:$springDataRedisVersion") { exclude(module: 'spring-context-support') } - compile("redis.clients:jedis:$jedisVersion", optional) + optional("redis.clients:jedis:$jedisVersion") - compile("org.springframework.data:spring-data-mongodb:$springDataMongoVersion") { - optional + optional("org.springframework.data:spring-data-mongodb:$springDataMongoVersion") { exclude(module: 'spring-beans') exclude(module: 'spring-expression') exclude(module: 'spring-tx')