From ef5fdd491757e6b224132b1397528add25ddc737 Mon Sep 17 00:00:00 2001 From: Prem Patel Date: Fri, 7 Jun 2024 14:32:29 +0530 Subject: [PATCH] Add signing and publication --- android/.gitignore | 2 + android/bagel/.gitignore | 2 + android/bagel/build.gradle.kts | 97 +++++++++++++++--------------- android/gradle.defaults.properties | 30 +++++++++ android/gradle/libs.versions.toml | 2 + 5 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 android/gradle.defaults.properties diff --git a/android/.gitignore b/android/.gitignore index d849f4f..c8ee023 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -53,3 +53,5 @@ app/.idea/ # Temporary API docs docs/api + +artifacts \ No newline at end of file diff --git a/android/bagel/.gitignore b/android/bagel/.gitignore index d849f4f..7001498 100644 --- a/android/bagel/.gitignore +++ b/android/bagel/.gitignore @@ -53,3 +53,5 @@ app/.idea/ # Temporary API docs docs/api + +*.gpg diff --git a/android/bagel/build.gradle.kts b/android/bagel/build.gradle.kts index 3cbfc86..c9b646a 100644 --- a/android/bagel/build.gradle.kts +++ b/android/bagel/build.gradle.kts @@ -1,22 +1,63 @@ +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary +import com.vanniktech.maven.publish.SonatypeHost + plugins { alias(libs.plugins.android.library) alias(libs.plugins.jetbrains.kotlin.android) alias(libs.plugins.kotlinx.serialization) - id("maven-publish") + alias(libs.plugins.vanniktechMavenPublish) } -android { - namespace = "com.simform.bagel" - compileSdk = libs.versions.compileSdk.get().toInt() +mavenPublishing { + coordinates("com.simform", "bagel", "1.0.0") + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = false) + configure(AndroidSingleVariantLibrary()) - publishing { - singleVariant("release") { - withSourcesJar() + pom { + packaging = "aar" + name.set("Bagel") + description.set("Bagel is a little native iOS/Android network debugger") + url.set("https://github.com/mobile-simformsolutions/Bagel.git") + inceptionYear.set("2024") + + licenses { + license { + name.set("Apache License Version 2.0, January 2004") + url.set("https://github.com/mobile-simformsolutions/Bagel?tab=License-1-ov-file") + } + } + + developers { + developer { + id.set("simform") + name.set("Simform") + email.set("developer@simform.com") + } + } + + scm { + connection.set("scm:git@github.com:mobile-simformsolutions/Bagel") + developerConnection.set("scm:git@github.com:mobile-simformsolutions/Bagel.git") + url.set("https://github.com/mobile-simformsolutions/Bagel.git") } } + signAllPublications() +} + +android { + namespace = "com.simform.bagel" + compileSdk = libs.versions.compileSdk.get().toInt() + defaultConfig { minSdk = libs.versions.minSdk.get().toInt() + compileSdk = libs.versions.compileSdk.get().toInt() + + aarMetadata { + minCompileSdk = libs.versions.minSdk.get().toInt() + } + + multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -40,48 +81,6 @@ android { } } -afterEvaluate { - publishing { - publications { - create("release") { - from(components["release"]) - groupId = "com.simform" - artifactId = "bagel" - version = "1.0.0" - - pom { - packaging = "aar" - name.set("Bagel") - description.set("Bagel is a little native iOS/Android network debugger") - url.set("https://github.com/mobile-simformsolutions/Bagel.git") - inceptionYear.set("2024") - - licenses { - license { - name.set("Apache License Version 2.0, January 2004") - url.set("https://github.com/mobile-simformsolutions/Bagel?tab=License-1-ov-file") - } - } - - developers { - developer { - id.set("simform") - name.set("Simform") - email.set("developer@simform.com") - } - } - - scm { - connection.set("scm:git@github.com:mobile-simformsolutions/Bagel") - developerConnection.set("scm:git@github.com:mobile-simformsolutions/Bagel.git") - url.set("https://github.com/mobile-simformsolutions/Bagel.git") - } - } - } - } - } -} - dependencies { implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) diff --git a/android/gradle.defaults.properties b/android/gradle.defaults.properties new file mode 100644 index 0000000..4389c66 --- /dev/null +++ b/android/gradle.defaults.properties @@ -0,0 +1,30 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true + +mavenCentralUsername= +mavenCentralPassword= + +signing.keyId=0x00000000 +signing.password= +signing.secretKeyRingFile= \ No newline at end of file diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 2d0c61a..233bc5c 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -26,6 +26,7 @@ appcompat = "1.6.1" material = "1.12.0" hiltNavigationCompose = "1.2.0" socketIoClient = "2.1.0" +vanniktechMavenPublish = "0.28.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -65,3 +66,4 @@ hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } android-library = { id = "com.android.library", version.ref = "agp" } +vanniktechMavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechMavenPublish" }