From 316ac5d9424435f6c09c4baa4f3109f840f93cf1 Mon Sep 17 00:00:00 2001 From: Jon Brisbin Date: Mon, 15 Oct 2012 12:33:37 -0400 Subject: [PATCH] Updated the build to use a separate maven pom file alteration script to make the resulting pom maven central-compliant. --- build.gradle | 1 + maven.gradle | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 maven.gradle diff --git a/build.gradle b/build.gradle index 4fec77dce..dd9ec7d2e 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,7 @@ allprojects { configure(subprojects) { subproject -> apply plugin: "java" apply plugin: "groovy" + apply from: "${rootProject.projectDir}/maven.gradle" configurations { compile.extendsFrom providedCompile diff --git a/maven.gradle b/maven.gradle new file mode 100644 index 000000000..e49b1b710 --- /dev/null +++ b/maven.gradle @@ -0,0 +1,60 @@ +apply plugin: 'maven' + +ext.optionalDeps = [] +ext.providedDeps = [] + +ext.optional = { optionalDeps << it } +ext.provided = { providedDeps << it } + +install { + repositories.mavenInstaller { + customizePom(pom, project) + } +} + +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' + } + + // add all items necessary for maven central publication + generatedPom.project { + name = gradleProject.description + description = gradleProject.description + url = 'http://github.com/SpringSource/spring-data-rest' + organization { + name = 'SpringSource' + url = 'http://www.springsource.org/spring-data/rest' + } + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution 'repo' + } + } + scm { + url = 'http://github.com/SpringSource/spring-data-rest' + connection = 'scm:git:git://github.com/SpringSource/spring-data-rest' + developerConnection = 'scm:git:git://github.com/SpringSource/spring-data-rest' + } + developers { + developer { + id = 'jbrisbin' + name = 'Jon Brisbin' + email = 'jbrisbin@vmware.com' + } + } + } + } +} \ No newline at end of file