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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user