Skip to content

Commit

Permalink
chore: Update gradle for maven publish
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <[email protected]>
  • Loading branch information
hamada147 committed Mar 7, 2024
1 parent acf023b commit 6062218
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 70 deletions.
148 changes: 79 additions & 69 deletions anoncred-kmm/anoncreds-kmp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
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.net.URL
import java.util.Base64

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 {
Expand Down Expand Up @@ -112,6 +114,7 @@ kotlin {
kotlinOptions.jvmTarget = "17"
}
}
applyDefaultHierarchyTemplate()

sourceSets {
val commonMain by getting {
Expand Down Expand Up @@ -186,74 +189,10 @@ val rustClean by tasks.register("rustClean") {
dependsOn("clean")
}

publishing {
publications {
withType<MavenPublication> {
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("[email protected]")
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 {
Expand Down Expand Up @@ -289,17 +228,88 @@ android {
}
}

// Dokka implementation
tasks.withType<DokkaTask>().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<KotlinCompile> {
dependsOn(":anoncred-wrapper-rust:buildRust")
}
tasks.withType<ProcessResources> {
dependsOn(":anoncred-wrapper-rust:buildRust")
}
tasks.withType<PublishToMavenRepository> {
dependsOn(tasks.withType<Sign>(), ":anoncred-wrapper-rust:copyBindings")
}
tasks.withType<ProcessAndroidResources> {
dependsOn(":anoncred-wrapper-rust:copyBindings")
}
tasks.withType<SourceJarTask> {
dependsOn(":anoncred-wrapper-rust:copyBindings")
}
tasks.withType<org.gradle.jvm.tasks.Jar> {
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")
}
}
74 changes: 74 additions & 0 deletions anoncred-kmm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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")
}
}

Expand Down Expand Up @@ -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<MavenPublication> {
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("[email protected]")
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 {
Expand Down
2 changes: 1 addition & 1 deletion anoncred-kmm/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = "anoncreds-kmm-main"
rootProject.name = "anoncred-kmm"
include(":uniffi-kmm")
include(":anoncred-wrapper-rust")
include(":anoncreds-kmp")
Expand Down

0 comments on commit 6062218

Please sign in to comment.