From 156fb8bbb36c3150be95ed92a789b6fdfd2f2a03 Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Mon, 13 Sep 2021 23:03:17 -0500 Subject: [PATCH] Simplify maven publishing --- .github/workflows/publish.yml | 9 +-- build.gradle.kts | 25 +------ gradle.properties | 19 ++++- vgo-core/build.gradle.kts | 59 +--------------- vgo-core/gradle.properties | 3 + vgo-plugin/build.gradle.kts | 59 +--------------- vgo-plugin/gradle.properties | 6 ++ vgo/build.gradle.kts | 69 ++----------------- vgo/gradle.properties | 3 + .../kotlin/com/jzbrooks/vgo/Application.kt | 2 +- 10 files changed, 45 insertions(+), 209 deletions(-) create mode 100644 vgo-core/gradle.properties create mode 100644 vgo-plugin/gradle.properties create mode 100644 vgo/gradle.properties diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b1193446..e921c3bb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,11 +27,8 @@ jobs: sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_KEY_RING_FILE'" - name: Publish to MavenCentral - run: ./gradlew --max-workers 1 --no-daemon publishReleasePublicationToSonatypeRepository closeAndReleaseRepository + run: ./gradlew -Psigning.keyId=${{ secrets.SIGNING_KEY_ID}} -Psigning.password=${{ secrets.SIGNING_PASSWORD }} -P-Psigning.secretKeyRingFile=${{ secrets.SIGNING_KEY_FILE_PATH }} --no-parallel --no-daemon publishAllPublicationsToMavenCentralRepository closeAndReleaseRepository env: - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} - SIGNING_KEY_FILE_PATH: ${{ secrets.SIGNING_KEY_FILE_PATH }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} SONATYPE_PROFILE_ID: ${{ secrets.SONATYPE_PROFILE_ID }} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 73126d77..1ea65afa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import io.codearte.gradle.nexus.NexusStagingExtension buildscript { repositories { @@ -10,19 +9,11 @@ buildscript { dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30") classpath("org.jlleitschuh.gradle:ktlint-gradle:10.2.0") - classpath("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0") + classpath("com.vanniktech:gradle-maven-publish-plugin:0.18.0") } } subprojects { - plugins.apply("org.jlleitschuh.gradle.ktlint") - extensions.configure { - version.set("0.42.1") - } - - group = "com.jzbrooks" - version = properties["vgo_version"]?.toString() ?: "" - repositories { mavenLocal() mavenCentral() @@ -63,17 +54,3 @@ subprojects { }) } } - -ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID") -ext["signing.password"] = System.getenv("SIGNING_PASSWORD") -ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_KEY_FILE_PATH") - -apply(plugin = "io.codearte.nexus-staging") -configure { - packageGroup = "com.jzbrooks" - stagingProfileId = System.getenv("SONATYPE_PROFILE_ID") - numberOfRetries = 60 - delayBetweenRetriesInMillis = 30_000 - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") -} diff --git a/gradle.properties b/gradle.properties index c262926a..229554f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,18 @@ -vgo_version=2.0.2 - org.gradle.jvmargs=-Xmx2g -XX:+UseParallelGC + +GROUP=com.jzbrooks +VERSION_NAME=2.0.2 + +POM_URL=https://github.com/jzbrooks/vgo/ + +POM_LICENSE_NAME=MIT License +POM_LICENSE_URL=https://github.com/jzbrooks/vgo/blob/master/LICENSE + +POM_SCM_URL=https://github.com/jzbrooks/vgo/tree/master +POM_SCM_CONNECTION=scm:git:git:github.com/jzbrooks/vgo.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/jzbrooks/vgo.git + +POM_DEVELOPER_ID=jzbrooks +POM_DEVELOPER_NAME=Justin Brooks +POM_DEVELOPER_URL=https://github.com/jzbrooks +POM_DEVELOPER_EMAIL=justin@jzbrooks.com diff --git a/vgo-core/build.gradle.kts b/vgo-core/build.gradle.kts index 771c6e59..3ecfad60 100644 --- a/vgo-core/build.gradle.kts +++ b/vgo-core/build.gradle.kts @@ -1,7 +1,7 @@ plugins { + id("org.jlleitschuh.gradle.ktlint") id("org.jetbrains.kotlin.jvm") - id("maven-publish") - id("signing") + id("com.vanniktech.maven.publish") } dependencies { @@ -22,58 +22,3 @@ tasks { from(this@tasks["javadoc"]) } } - -publishing { - publications { - create("release") { - artifactId = "vgo-core" - - artifact(tasks["sourcesJar"]) - artifact(tasks["javadocJar"]) - from(components["kotlin"]) - - @Suppress("UnstableApiUsage") - pom { - name.set("vgo-core") - description.set("vgo-core is a library for optimizing vector artwork files.") - url.set("https://github.com/jzbrooks/vgo/") - - licenses { - license { - name.set("MIT License") - url.set("https://github.com/jzbrooks/vgo/blob/master/LICENSE") - } - } - - developers { - developer { - id.set("jzbrooks") - name.set("Justin Brooks") - email.set("justin@jzbrooks.com") - } - } - - scm { - connection.set("scm:git:github.com/jzbrooks/vgo.git") - developerConnection.set("scm:git:ssh://github.com/jzbrooks/vgo.git") - url.set("https://github.com/jzbrooks/vgo/tree/master") - } - } - } - } - - repositories { - maven { - name = "sonatype" - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } - } -} - -signing { - sign(publishing.publications) -} diff --git a/vgo-core/gradle.properties b/vgo-core/gradle.properties new file mode 100644 index 00000000..bd26b4df --- /dev/null +++ b/vgo-core/gradle.properties @@ -0,0 +1,3 @@ +POM_ARTIFACT_ID=vgo-core +POM_NAME=vgo-core +POM_DESCRIPTION=vgo-core is a library for optimizing vector artwork files. \ No newline at end of file diff --git a/vgo-plugin/build.gradle.kts b/vgo-plugin/build.gradle.kts index aa80203b..09bfddcc 100644 --- a/vgo-plugin/build.gradle.kts +++ b/vgo-plugin/build.gradle.kts @@ -1,8 +1,8 @@ plugins { + id("org.jlleitschuh.gradle.ktlint") id("org.jetbrains.kotlin.jvm") id("java-gradle-plugin") - id("maven-publish") - id("signing") + id("com.vanniktech.maven.publish") id("org.gradle.kotlin.kotlin-dsl") version "2.1.4" } @@ -35,58 +35,3 @@ tasks { from(this@tasks["javadoc"]) } } - -publishing { - publications { - create("release") { - artifactId = "vgo-plugin" - - artifact(tasks["sourcesJar"]) - artifact(tasks["javadocJar"]) - from(components["kotlin"]) - - @Suppress("UnstableApiUsage") - pom { - name.set("vgo-plugin") - description.set("vgo is a gradle plugin for optimizing vector artwork files that helps ensure a compact representation without compromising quality.") - url.set("https://github.com/jzbrooks/vgo/") - - licenses { - license { - name.set("MIT License") - url.set("https://github.com/jzbrooks/vgo/blob/master/LICENSE") - } - } - - developers { - developer { - id.set("jzbrooks") - name.set("Justin Brooks") - email.set("justin@jzbrooks.com") - } - } - - scm { - connection.set("scm:git:github.com/jzbrooks/vgo.git") - developerConnection.set("scm:git:ssh://github.com/jzbrooks/vgo.git") - url.set("https://github.com/jzbrooks/vgo/tree/master") - } - } - } - } - - repositories { - maven { - name = "sonatype" - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } - } -} - -signing { - sign(publishing.publications) -} diff --git a/vgo-plugin/gradle.properties b/vgo-plugin/gradle.properties new file mode 100644 index 00000000..9e3190d9 --- /dev/null +++ b/vgo-plugin/gradle.properties @@ -0,0 +1,6 @@ +POM_ARTIFACT_ID=vgo-plugin +POM_NAME=vgo-plugin +POM_DESCRIPTION=vgo is a gradle plugin for optimizing vector artwork files that helps ensure a compact representation without compromising quality. + + + diff --git a/vgo/build.gradle.kts b/vgo/build.gradle.kts index 092945f9..ffb0b9d5 100644 --- a/vgo/build.gradle.kts +++ b/vgo/build.gradle.kts @@ -4,9 +4,9 @@ import java.nio.file.Files import java.nio.file.Paths plugins { + id("org.jlleitschuh.gradle.ktlint") id("org.jetbrains.kotlin.jvm") - id("maven-publish") - id("signing") + id("com.vanniktech.maven.publish") } sourceSets { @@ -33,10 +33,9 @@ tasks { jar { dependsOn(configurations.runtimeClasspath) - manifest { attributes["Main-Class"] = "com.jzbrooks.vgo.Application" - attributes["Bundle-Version"] = project.version + attributes["Bundle-Version"] = project.properties["VERSION_NAME"] } val sourceClasses = sourceSets.main.get().output.classesDirs @@ -59,6 +58,8 @@ tasks { } val generateConstants by registering { + finalizedBy("compileKotlin") + outputs.files("$projectDir/src/generated/kotlin/com/jzbrooks/BuildConstants.kt") doLast { @@ -72,13 +73,12 @@ tasks { """ |package com.jzbrooks | - |object BuildConstants { + |internal object BuildConstants { """.trimMargin() ) val vgoProperties = project.properties - .filter { it.key.startsWith("vgo_") } - .mapKeys { it.key.removePrefix("vgo_") } + .filterKeys { it == "VERSION_NAME" } for (property in vgoProperties) { append(" const val ") @@ -159,58 +159,3 @@ tasks { from(this@tasks["javadoc"]) } } - -publishing { - publications { - create("release") { - artifactId = "vgo" - - artifact(tasks["sourcesJar"]) - artifact(tasks["javadocJar"]) - from(components["kotlin"]) - - @Suppress("UnstableApiUsage") - pom { - name.set("vgo") - description.set("vgo is a tool for optimizing vector artwork files that helps ensure your vector artwork is represented compactly without compromising quality.") - url.set("https://github.com/jzbrooks/vgo/") - - licenses { - license { - name.set("MIT License") - url.set("https://github.com/jzbrooks/vgo/blob/master/LICENSE") - } - } - - developers { - developer { - id.set("jzbrooks") - name.set("Justin Brooks") - email.set("justin@jzbrooks.com") - } - } - - scm { - connection.set("scm:git:github.com/jzbrooks/vgo.git") - developerConnection.set("scm:git:ssh://github.com/jzbrooks/vgo.git") - url.set("https://github.com/jzbrooks/vgo/tree/master") - } - } - } - } - - repositories { - maven { - name = "sonatype" - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } - } -} - -signing { - sign(publishing.publications) -} diff --git a/vgo/gradle.properties b/vgo/gradle.properties new file mode 100644 index 00000000..1b54b974 --- /dev/null +++ b/vgo/gradle.properties @@ -0,0 +1,3 @@ +POM_ARTIFACT_ID=vgo +POM_NAME=vgo +POM_DESCRIPTION=vgo is a tool for optimizing vector artwork files that helps ensure your vector artwork is represented compactly without compromising quality. \ No newline at end of file diff --git a/vgo/src/main/kotlin/com/jzbrooks/vgo/Application.kt b/vgo/src/main/kotlin/com/jzbrooks/vgo/Application.kt index d19f25be..28b07389 100644 --- a/vgo/src/main/kotlin/com/jzbrooks/vgo/Application.kt +++ b/vgo/src/main/kotlin/com/jzbrooks/vgo/Application.kt @@ -35,7 +35,7 @@ class Application { } if (argReader.readFlag("version|v")) { - println(BuildConstants.VERSION) + println(BuildConstants.VERSION_NAME) return 0 }