diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1c59b50..a425e65 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,11 +38,11 @@ jobs: - name: Build & Publish to Maven env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} run: | chmod +x ./gradlew ./gradlew :lib:publishToMavenLocal :lib:publish --stacktrace --no-daemon diff --git a/build.gradle.kts b/build.gradle.kts index d74d949..b2d3656 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ plugins { alias(libs.plugins.android.library) apply false + alias(libs.plugins.publish) apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dc46f4a..94c399e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,9 @@ [versions] agp = "8.8.1" +publish = "0.30.0" [libraries] [plugins] android-library = { id = "com.android.library", version.ref = "agp" } +publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index b6a5a0a..9fcf060 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,9 +1,11 @@ @file:Suppress("UnstableApiUsage") +import com.vanniktech.maven.publish.SonatypeHost + + plugins { - id("signing") - id("maven-publish") alias(libs.plugins.android.library) + alias(libs.plugins.publish) } android { @@ -55,72 +57,32 @@ android { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } - - publishing { - singleVariant("release") { - withSourcesJar() - withJavadocJar() - } - } } -publishing { - publications { - register("libunbound") { - artifactId = "libunbound" - group = "dev.rushii" - version = "1.0.0" - - pom { - name.set("LibUnbound") - description.set("Android native library for interfacing with compiled hermes dynamically ") - url.set("https://github.com/unbound-app/libunbound-android") - licenses { - license { - name.set("GNU Lesser General Public License v3.0") - url.set("https://github.com/unbound-app/libunbound-android/LICENSE") - } - } - developers { - developer { - name = "rushii" - url = "https://github.com/rushiiMachine" - } - } - scm { - connection.set("scm:git:https://github.com/unbound-app/libunbound-android.git") - url.set("https://github.com/unbound-app/libunbound-android") - } - } +mavenPublishing { + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + coordinates("dev.rushii", "libunbound", "1.0.0") - afterEvaluate { - from(components.getByName("release")) + pom { + name = "LibUnbound" + description = "Android native library for interfacing with compiled hermes dynamically" + inceptionYear = "2025" + url = "https://github.com/unbound-app/libunbound-android" + licenses { + license { + name = "GNU Lesser General Public License v3.0" + url = "https://github.com/unbound-app/libunbound-android/blob/master/LICENSE" } } - } - repositories { - val sonatypeUsername = System.getenv("SONATYPE_USERNAME") - val sonatypePassword = System.getenv("SONATYPE_PASSWORD") - - if (sonatypeUsername == null || sonatypePassword == null) - mavenLocal() - else { - signing { - useInMemoryPgpKeys( - System.getenv("SIGNING_KEY_ID"), - System.getenv("SIGNING_KEY"), - System.getenv("SIGNING_PASSWORD"), - ) - sign(publishing.publications) - } - - maven { - credentials { - username = sonatypeUsername - password = sonatypePassword - } - setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + developers { + developer { + name = "rushii" + url = "https://github.com/rushiiMachine" } } + scm { + url = "https://github.com/unbound-app/libunbound-android" + connection = "scm:git:https://github.com/unbound-app/libunbound-android.git" + } } } diff --git a/lib/src/main/java/dev/rushii/libunbound/LibUnbound.java b/lib/src/main/java/dev/rushii/libunbound/LibUnbound.java index 870d037..1c6c9ac 100644 --- a/lib/src/main/java/dev/rushii/libunbound/LibUnbound.java +++ b/lib/src/main/java/dev/rushii/libunbound/LibUnbound.java @@ -4,6 +4,8 @@ /** * JNI interface to the native side of this library. + * This class can only be loaded after the Hermes native library ({@code libhermes.so}) has been loaded into the process. + * If Hermes has not yet been loaded, a {@link RuntimeException} will be thrown upon loading this class. */ @SuppressWarnings("unused") public class LibUnbound { @@ -15,10 +17,8 @@ public class LibUnbound { /** * Obtains the Hermes Bytecode (HBC) version that the Hermes runtime supports. - * This method can only be called after the Hermes native lib has been loaded into the process. * * @throws IllegalStateException If Hermes has not yet been loaded. - * @throws RuntimeException If failing to find the required native symbol. */ public static int getHermesRuntimeBytecodeVersion() { if (cachedBytecodeVersion > 0)