From d03e6e586b8ead93782c44a4fad72a4bb39f70bd Mon Sep 17 00:00:00 2001 From: Jared Burrows Date: Tue, 26 Apr 2022 07:42:42 -0400 Subject: [PATCH] Support more POM properties (#345) --- .../fixtures/full_pom_project/build.gradle | 22 +++++++++ .../expected/test-artifact-1.0.0.pom | 47 +++++++++++++++++++ .../full_pom_project/gradle.properties | 28 +++++++++++ .../maven/publish/test/TestClass.java | 15 ++++++ .../MavenPublishPluginIntegrationTest.kt | 10 ++++ .../publish/MavenPublishBaseExtension.kt | 11 +++++ 6 files changed, 133 insertions(+) create mode 100644 plugin/src/integrationTest/fixtures/full_pom_project/build.gradle create mode 100644 plugin/src/integrationTest/fixtures/full_pom_project/expected/test-artifact-1.0.0.pom create mode 100644 plugin/src/integrationTest/fixtures/full_pom_project/gradle.properties create mode 100644 plugin/src/integrationTest/fixtures/full_pom_project/src/main/java/com/vanniktech/maven/publish/test/TestClass.java diff --git a/plugin/src/integrationTest/fixtures/full_pom_project/build.gradle b/plugin/src/integrationTest/fixtures/full_pom_project/build.gradle new file mode 100644 index 00000000..b51c2bb2 --- /dev/null +++ b/plugin/src/integrationTest/fixtures/full_pom_project/build.gradle @@ -0,0 +1,22 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + google() + } + + dependencies { + classpath "com.vanniktech:gradle-maven-publish-plugin:${System.getProperty("com.vanniktech.publish.version")}" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" + } +} + +apply plugin: "java" +apply plugin: "org.jetbrains.kotlin.jvm" +apply plugin: "com.vanniktech.maven.publish" + +apply from: "maven-publish.gradle" + +dependencies { + api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10" +} diff --git a/plugin/src/integrationTest/fixtures/full_pom_project/expected/test-artifact-1.0.0.pom b/plugin/src/integrationTest/fixtures/full_pom_project/expected/test-artifact-1.0.0.pom new file mode 100644 index 00000000..5b931b6f --- /dev/null +++ b/plugin/src/integrationTest/fixtures/full_pom_project/expected/test-artifact-1.0.0.pom @@ -0,0 +1,47 @@ + + + + + + + + 4.0.0 + com.example + test-artifact + 1.0.0 + Best Dependency + This is the best dependency ever. + https://github.com/vanniktech/gradle-maven-publish-plugin + 20xx + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + jaredsburrows + Jared Burrows + jaredsburrows@gmail.com + + + + scm:git:git://github.com/vanniktech/gradle-maven-publish-plugin.git + scm:git:ssh://git@github.com/vanniktech/gradle-maven-publish-plugin.git + https://github.com/vanniktech/gradle-maven-publish-plugin + + + github + https://github.com/vanniktech/gradle-maven-publish-plugin/issues + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + 1.6.10 + compile + + + diff --git a/plugin/src/integrationTest/fixtures/full_pom_project/gradle.properties b/plugin/src/integrationTest/fixtures/full_pom_project/gradle.properties new file mode 100644 index 00000000..8985b1e8 --- /dev/null +++ b/plugin/src/integrationTest/fixtures/full_pom_project/gradle.properties @@ -0,0 +1,28 @@ +GROUP=com.example +VERSION_NAME=1.0.0 +POM_ARTIFACT_ID=test-artifact + +POM_NAME=Best Dependency +POM_DESCRIPTION=This is the best dependency ever. +POM_INCEPTION_YEAR=20xx +POM_PACKAGING=jar +POM_URL=https://github.com/vanniktech/gradle-maven-publish-plugin + +POM_ISSUE_SYSTEM=github +POM_ISSUE_URL=https://github.com/vanniktech/gradle-maven-publish-plugin/issues + +POM_SCM_URL=https://github.com/vanniktech/gradle-maven-publish-plugin +POM_SCM_CONNECTION=scm:git:git://github.com/vanniktech/gradle-maven-publish-plugin.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/vanniktech/gradle-maven-publish-plugin.git + +POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENSE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENSE_DIST=repo + +POM_DEVELOPER_ID=jaredsburrows +POM_DEVELOPER_NAME=Jared Burrows +POM_DEVELOPER_EMAIL=jaredsburrows@gmail.com + +signing.keyId=B89C4055 +signing.password=test +signing.secretKeyRingFile=test-secring.gpg diff --git a/plugin/src/integrationTest/fixtures/full_pom_project/src/main/java/com/vanniktech/maven/publish/test/TestClass.java b/plugin/src/integrationTest/fixtures/full_pom_project/src/main/java/com/vanniktech/maven/publish/test/TestClass.java new file mode 100644 index 00000000..8e98f928 --- /dev/null +++ b/plugin/src/integrationTest/fixtures/full_pom_project/src/main/java/com/vanniktech/maven/publish/test/TestClass.java @@ -0,0 +1,15 @@ +package com.vanniktech.maven.publish.test; + +/** + * Just a test class with Javadoc. + */ +public final class TestClass { + /** + * Main method which does something. + * + * @param args Command-line arguments passed to the program. + */ + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt index 0c9b7506..1e2bf351 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt @@ -282,6 +282,16 @@ class MavenPublishPluginIntegrationTest { assertPomContentMatches() } + @Test fun generatesArtifactsAndDocumentationOnFullPomProject() { + setupFixture("full_pom_project") + + val result = executeGradleCommands(TEST_TASK, "--stacktrace") + + assertExpectedTasksRanSuccessfully(result) + assertExpectedCommonArtifactsGenerated() + assertPomContentMatches() + } + @Test fun generatesArtifactsAndDocumentationOnOverrideVersionGroupProject() { setupFixture("override_version_group_project") diff --git a/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt b/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt index 0bf4624f..2f7247d2 100644 --- a/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt +++ b/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt @@ -168,6 +168,15 @@ abstract class MavenPublishBaseExtension( pom.inceptionYear.set(inceptionYear) } + val issueManagementSystem = project.findOptionalProperty("POM_ISSUE_SYSTEM") + val issueManagementUrl = project.findOptionalProperty("POM_ISSUE_URL") + if (issueManagementSystem != null || issueManagementUrl != null) { + pom.issueManagement { + it.system.set(issueManagementSystem) + it.url.set(issueManagementUrl) + } + } + val scmUrl = project.findOptionalProperty("POM_SCM_URL") val scmConnection = project.findOptionalProperty("POM_SCM_CONNECTION") val scmDeveloperConnection = project.findOptionalProperty("POM_SCM_DEV_CONNECTION") @@ -208,12 +217,14 @@ abstract class MavenPublishBaseExtension( val developerId = project.findOptionalProperty("POM_DEVELOPER_ID") val developerName = project.findOptionalProperty("POM_DEVELOPER_NAME") val developerUrl = project.findOptionalProperty("POM_DEVELOPER_URL") + val developerEmail = project.findOptionalProperty("POM_DEVELOPER_EMAIL") if (developerId != null || developerName != null || developerUrl != null) { pom.developers { developers -> developers.developer { it.id.set(developerId) it.name.set(developerName) it.url.set(developerUrl) + it.email.set(developerEmail) } } }