From d924aec0132b039aeafbf7f3b7386b79abbabf66 Mon Sep 17 00:00:00 2001 From: Ahmed Moussa Date: Thu, 7 Mar 2024 02:12:47 +0200 Subject: [PATCH] chore: Update gradle for maven publish Signed-off-by: Ahmed Moussa --- anoncred-kmm/anoncreds-kmp/build.gradle.kts | 149 +++++++++++--------- anoncred-kmm/build.gradle.kts | 74 ++++++++++ anoncred-kmm/settings.gradle.kts | 2 +- 3 files changed, 154 insertions(+), 71 deletions(-) diff --git a/anoncred-kmm/anoncreds-kmp/build.gradle.kts b/anoncred-kmm/anoncreds-kmp/build.gradle.kts index 2d27717f..5fae5803 100644 --- a/anoncred-kmm/anoncreds-kmp/build.gradle.kts +++ b/anoncred-kmm/anoncreds-kmp/build.gradle.kts @@ -1,22 +1,23 @@ +import com.android.build.gradle.tasks.ProcessAndroidResources +import com.android.build.gradle.tasks.SourceJarTask import org.gradle.internal.os.OperatingSystem +import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.util.Base64 +import java.net.URL val os: OperatingSystem = OperatingSystem.current() -val publishedMavenId: String = "io.iohk.atala.prism.anoncredskmp" plugins { id("com.android.library") kotlin("multiplatform") id("org.jetbrains.dokka") id("maven-publish") - id("signing") } apply(plugin = "kotlinx-atomicfu") -version = "0.4.4" -group = publishedMavenId +version = rootProject.version +group = rootProject.group fun KotlinNativeCompilation.anoncredsCinterops(type: String) { cinterops { @@ -112,6 +113,7 @@ kotlin { kotlinOptions.jvmTarget = "17" } } + applyDefaultHierarchyTemplate() sourceSets { val commonMain by getting { @@ -186,74 +188,10 @@ val rustClean by tasks.register("rustClean") { dependsOn("clean") } -publishing { - publications { - withType { - groupId = publishedMavenId - artifactId = project.name - version = project.version.toString() - pom { - name.set("AnonCred KMP Wrapper") - description.set("The AnonCreds (Anonymous Credentials) specification is based on the open source verifiable credential implementation of AnonCreds that has been in use since 2017, initially as part of the Hyperledger Indy open source project and now in the Hyperledger AnonCreds project. The extensive use of AnonCreds around the world has made it a de facto standard for ZKP-based verifiable credentials, and this specification is the formalization of that implementation.") - url.set("https://docs.atalaprism.io/") - organization { - name.set("IOG") - url.set("https://iog.io/") - } - issueManagement { - system.set("Github") - url.set("https://github.com/input-output-hk/anoncreds-rs") - } - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - developers { - developer { - id.set("hamada147") - name.set("Ahmed Moussa") - email.set("ahmed.moussa@iohk.io") - organization.set("IOG") - roles.add("developer") - url.set("https://github.com/hamada147") - } - } - scm { - connection.set("scm:git:git://input-output-hk/anoncreds-rs.git") - developerConnection.set("scm:git:ssh://input-output-hk/anoncreds-rs.git") - url.set("https://github.com/input-output-hk/anoncreds-rs") - } - } - if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") != null) { - if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN").isNotBlank()) { - signing { - val base64EncodedAsciiArmoredSigningKey: String = System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: "" - val signingKeyPassword: String = System.getenv("SIGNING_KEY_PASSWORD") ?: "" - useInMemoryPgpKeys(String(Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray())), signingKeyPassword) - sign(this@withType) - } - } - } - } - } - repositories { - maven { - this.name = "GitHubPackages" - this.url = uri("https://maven.pkg.github.com/input-output-hk/anoncreds-rs/") - credentials { - this.username = System.getenv("ATALA_GITHUB_ACTOR") - this.password = System.getenv("ATALA_GITHUB_TOKEN") - } - } - } -} - android { ndkVersion = "26.0.10792818" compileSdk = 34 - namespace = "io.iohk.atala.prism.anoncredskmp" + namespace = rootProject.group.toString() sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") sourceSets["main"].jniLibs { @@ -289,6 +227,41 @@ android { } } +// Dokka implementation +tasks.withType().configureEach { + moduleName.set("AnonCred KMP") + moduleVersion.set(rootProject.version.toString()) + description = "This is a Kotlin Multiplatform Library Wrapper for AnonCred Rust" + dokkaSourceSets { + configureEach { + jdkVersion.set(17) + languageVersion.set("1.9.22") + apiVersion.set("2.0") + sourceLink { + localDirectory.set(projectDir.resolve("src")) + remoteUrl.set(URL("https://github.com/input-output-hk/anoncreds-rs/tree/main/src")) + remoteLineSuffix.set("#L") + } + externalDocumentationLink { + url.set(URL("https://kotlinlang.org/api/latest/jvm/stdlib/")) + } + externalDocumentationLink { + url.set(URL("https://kotlinlang.org/api/kotlinx.serialization/")) + } + externalDocumentationLink { + url.set(URL("https://api.ktor.io/")) + } + externalDocumentationLink { + url.set(URL("https://kotlinlang.org/api/kotlinx-datetime/")) + packageListUrl.set(URL("https://kotlinlang.org/api/kotlinx-datetime/")) + } + externalDocumentationLink { + url.set(URL("https://kotlinlang.org/api/kotlinx.coroutines/")) + } + } + } +} + afterEvaluate { tasks.withType { dependsOn(":anoncred-wrapper-rust:buildRust") @@ -296,10 +269,46 @@ afterEvaluate { tasks.withType { dependsOn(":anoncred-wrapper-rust:buildRust") } + tasks.withType { + dependsOn(tasks.withType(), ":anoncred-wrapper-rust:copyBindings") + } + tasks.withType { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } + tasks.withType { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } + tasks.withType { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } tasks.named("packageDebugResources") { dependsOn(":anoncred-wrapper-rust:copyBindings") } tasks.named("packageReleaseResources") { dependsOn(":anoncred-wrapper-rust:copyBindings") } + tasks.named("extractDeepLinksForAarDebug") { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } + tasks.named("extractDeepLinksForAarRelease") { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } + tasks.named("androidReleaseSourcesJar") { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } + tasks.named("androidDebugSourcesJar") { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } + tasks.named("mergeDebugJniLibFolders") { + dependsOn(":anoncred-wrapper-rust:copyGeneratedBinaryForAndroid") + } + tasks.named("mergeReleaseJniLibFolders") { + dependsOn(":anoncred-wrapper-rust:copyGeneratedBinaryForAndroid") + } + tasks.named("jvmSourcesJar") { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } + tasks.named("sourcesJar") { + dependsOn(":anoncred-wrapper-rust:copyBindings") + } } diff --git a/anoncred-kmm/build.gradle.kts b/anoncred-kmm/build.gradle.kts index a4f76209..642034bf 100644 --- a/anoncred-kmm/build.gradle.kts +++ b/anoncred-kmm/build.gradle.kts @@ -1,11 +1,20 @@ +import java.util.Base64 + +val publishedMavenId: String = "io.iohk.atala.prism.anoncredskmp" + plugins { id("org.jlleitschuh.gradle.ktlint") version "11.6.0" kotlin("jvm") version "1.9.22" id("com.android.library") version "8.1.4" apply false id("org.jetbrains.dokka") version "1.9.20" id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1" + id("maven-publish") + id("signing") } +group = publishedMavenId +version = "0.4.4" + buildscript { repositories { mavenLocal() @@ -16,6 +25,7 @@ buildscript { dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22") classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.21.0") + classpath("org.jetbrains.dokka:dokka-base:1.9.20") } } @@ -59,6 +69,70 @@ subprojects { exclude { it.file.path.contains(layout.buildDirectory.dir("generated").get().toString()) } } } + + if (this.name == "anoncreds-kmp") { + apply(plugin = "org.gradle.maven-publish") + apply(plugin = "org.gradle.signing") + publishing { + publications { + withType { + groupId = publishedMavenId + artifactId = project.name + version = project.version.toString() + pom { + name.set("AnonCred KMP Wrapper") + description.set("The AnonCreds (Anonymous Credentials) specification is based on the open source verifiable credential implementation of AnonCreds that has been in use since 2017, initially as part of the Hyperledger Indy open source project and now in the Hyperledger AnonCreds project. The extensive use of AnonCreds around the world has made it a de facto standard for ZKP-based verifiable credentials, and this specification is the formalization of that implementation.") + url.set("https://docs.atalaprism.io/") + organization { + name.set("IOG") + url.set("https://iog.io/") + } + issueManagement { + system.set("Github") + url.set("https://github.com/input-output-hk/anoncreds-rs") + } + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("hamada147") + name.set("Ahmed Moussa") + email.set("ahmed.moussa@iohk.io") + organization.set("IOG") + roles.add("developer") + url.set("https://github.com/hamada147") + } + } + scm { + connection.set("scm:git:git://input-output-hk/anoncreds-rs.git") + developerConnection.set("scm:git:ssh://input-output-hk/anoncreds-rs.git") + url.set("https://github.com/input-output-hk/anoncreds-rs") + } + } + if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") != null) { + if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN").isNotBlank()) { + signing { + val base64EncodedAsciiArmoredSigningKey: String = + System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: "" + val signingKeyPassword: String = System.getenv("SIGNING_KEY_PASSWORD") ?: "" + useInMemoryPgpKeys( + String( + Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray()) + ), + signingKeyPassword + ) + sign(this@withType) + } + } + } + } + } + } + } } nexusPublishing { diff --git a/anoncred-kmm/settings.gradle.kts b/anoncred-kmm/settings.gradle.kts index 99d1ad4f..55ff50d1 100644 --- a/anoncred-kmm/settings.gradle.kts +++ b/anoncred-kmm/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name = "anoncreds-kmm-main" +rootProject.name = "anoncred-kmm" include(":uniffi-kmm") include(":anoncred-wrapper-rust") include(":anoncreds-kmp")