From 51051de4c4664f133f144bbd70d6979f2d24e5dc Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 3 Sep 2015 15:07:59 +0100 Subject: [PATCH] Improve contents of generated pom files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the generated pom files were uncustomised and relied on Gradle’s default output. Such pom files are problematic for a couple of reasons: they include test dependencies and they don’t include the metadata that’s required for publishing to Maven Central. This commit customises the generated pom files to include the required metadata and to remove any test dependencies. --- build.gradle | 1 + gradle/publish-maven.gradle | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 gradle/publish-maven.gradle diff --git a/build.gradle b/build.gradle index d2fb8d36..338df543 100644 --- a/build.gradle +++ b/build.gradle @@ -47,6 +47,7 @@ subprojects { apply plugin: 'propdeps-eclipse' apply plugin: 'propdeps-maven' apply plugin: 'maven' + apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle" sourceCompatibility = 1.7 targetCompatibility = 1.7 diff --git a/gradle/publish-maven.gradle b/gradle/publish-maven.gradle new file mode 100644 index 00000000..ad2d7505 --- /dev/null +++ b/gradle/publish-maven.gradle @@ -0,0 +1,45 @@ +install { + repositories.mavenInstaller { + customizePom(pom, project) + } +} + +def customizePom(pom, gradleProject) { + pom.whenConfigured { generatedPom -> + generatedPom.dependencies.removeAll { dep -> + dep.scope == "test" + } + generatedPom.project { + name = gradleProject.description + description = gradleProject.description + url = "https://github.com/spring-projects/spring-restdocs" + organization { + name = "Spring IO" + url = "http://projects.spring.io/spring-restdocs" + } + licenses { + license { + name "The Apache Software License, Version 2.0" + url "http://www.apache.org/licenses/LICENSE-2.0.txt" + distribution "repo" + } + } + scm { + url = "https://github.com/spring-projects/spring-restdocs" + connection = "scm:git:git://github.com/spring-projects/spring-restdocs" + developerConnection = "scm:git:git://github.com/spring-projects/spring-restdocs" + } + developers { + developer { + id = "awilkinson" + name = "Andy Wilkinson" + email = "awilkinson@pivotal.io" + } + } + issueManagement { + system = "GitHub" + url = "https://github.com/spring-projects/spring-restdocs/issues" + } + } + } +} \ No newline at end of file