diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2fd7751..5a687b6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,10 +8,10 @@ on: types: [ prereleased, released ] env: - sonatypeUsername: ${{ secrets.SONATYPEUSERNAME }} - sonatypePassword: ${{ secrets.SONATYPEPASSWORD }} - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PASSPHRASE }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPEUSERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPEPASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PASSPHRASE }} jobs: build: diff --git a/build.gradle.kts b/build.gradle.kts index 9948a18..8466b03 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,7 @@ plugins { `java-library` `maven-publish` signing + alias(libs.plugins.publish) alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlinx.serialization) alias(libs.plugins.jlleitschuh.ktlint) @@ -27,8 +28,6 @@ group = "dev.gitlive" version = project.property("version") as String java { - withSourcesJar() - withJavadocJar() sourceCompatibility = JavaVersion.VERSION_17 } @@ -91,55 +90,43 @@ val cleanLibs by tasks.creating(Delete::class) { delete("$${layout.buildDirectory.asFile.get().path}/libs") } -publishing { +mavenPublishing { + publishToMavenCentral(automaticRelease = true) + signAllPublications() - repositories { - maven { - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") - credentials { - username = project.findProperty("sonatypeUsername") as String? ?: System.getenv("sonatypeUsername") - password = project.findProperty("sonatypePassword") as String? ?: System.getenv("sonatypePassword") + coordinates("dev.gitlive", "firebase-java-sdk", project.version.toString()) + + pom { + name.set("Firebase Java SDK") + description.set("A pure Java port of the Firebase Android SDK for client-side Java environments.") + url.set("https://github.com/GitLiveApp/firebase-java-sdk") + inceptionYear.set("2023") + + scm { + url.set("https://github.com/GitLiveApp/firebase-java-sdk") + connection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git") + developerConnection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git") + tag.set("HEAD") + } + + issueManagement { + system.set("GitHub Issues") + url.set("https://github.com/GitLiveApp/firebase-java-sdk/issues") + } + + developers { + developer { + name.set("Nicholas Bransby-Williams") + email.set("nbransby@gmail.com") } } - } - publications { - create("library") { - from(components["java"]) - - pom { - name.set("firebase-java-sdk") - description.set("The Firebase Java SDK is a pure java port of the Firebase Android SDK to run in clientside java environments such as the desktop.") - url.set("https://github.com/GitLiveApp/firebase-java-sdk") - inceptionYear.set("2023") - - scm { - url.set("https://github.com/GitLiveApp/firebase-java-sdk") - connection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git") - developerConnection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git") - tag.set("HEAD") - } - - issueManagement { - system.set("GitHub Issues") - url.set("https://github.com/GitLiveApp/firebase-java-sdk/issues") - } - - developers { - developer { - name.set("Nicholas Bransby-Williams") - email.set("nbransby@gmail.com") - } - } - - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - comments.set("A business-friendly OSS license") - } - } + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + comments.set("A business-friendly OSS license") } } } @@ -190,13 +177,6 @@ ktlint { version.set(libs.versions.ktlint.get()) } -signing { - val signingKey: String? by project - val signingPassword: String? by project - useInMemoryPgpKeys(signingKey, signingPassword) - sign(publishing.publications) -} - tasks.withType { fun isNonStable(version: String): Boolean { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9864c08..1c56371 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,6 +8,7 @@ kotlin = "2.0.20" kotlinx-coroutines = "1.9.0" kotlinx-serialization = "1.7.2" ktlint = "0.47.1" +publish = "0.34.0" [libraries] androidx-collection = { module = "androidx.collection:collection", version = "1.4.3" } @@ -40,3 +41,4 @@ ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "ben- jlleitschuh-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "jlleitschuh-ktlint" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9355b41..37f853b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME