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 <ahmed.moussa@iohk.io>
  • Loading branch information
hamada147 committed Mar 7, 2024
1 parent acf023b commit 54b44d6
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 17 deletions.
10 changes: 8 additions & 2 deletions anoncred-kmm/anoncred-wrapper-rust/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ val buildAnonCredWrapperForMacOSArch64 by tasks.register<Exec>("buildAnonCredWra
commandLine("cargo", "build", "--release", "--target", "aarch64-apple-darwin", "--target-dir", "${projectDir.resolve("target")}")
}

/**
* Disabled for no longer needed to support a macOS with arch x86-64 (Intel Based)
*/
val buildAnonCredWrapperForMacOSX8664 by tasks.register<Exec>("buildAnonCredWrapperForMacOSX86_64") {
group = "rust-compiling"
description = "Build and compile AnonCred Wrapper for macOS x86_64"
Expand All @@ -108,7 +111,7 @@ val buildAnonCredWrapperForMacOSX8664 by tasks.register<Exec>("buildAnonCredWrap
val buildAnonCredWrapperForMacOSUniversal by tasks.register("buildAnonCredWrapperForMacOSUniversal") {
group = "rust-compiling"
description = "Build and compile AnonCred Wrapper for macOS"
dependsOn(buildAnonCredWrapperForMacOSArch64, buildAnonCredWrapperForMacOSX8664)
dependsOn(buildAnonCredWrapperForMacOSArch64)
}

val buildAnonCredWrapperForiOSArch64 by tasks.register<Exec>("buildAnonCredWrapperForiOSArch64") {
Expand Down Expand Up @@ -265,6 +268,9 @@ val buildAnonCredWrapper by tasks.register("buildAnonCredWrapper") {

// Copy Bindings Tasks

/**
* Disabled for no longer needed to support a macOS with arch x86-64 (Intel Based)
*/
val copyGeneratedBinaryForMacOSX8664 by tasks.register<Copy>("copyGeneratedBinaryForMacOSX86_64") {
group = "rust-compiling"
description = "Copy all generated macOS x86_64 binaries to generated resources folder"
Expand All @@ -288,7 +294,7 @@ val copyGeneratedBinaryForMacOSArch64 by tasks.register<Copy>("copyGeneratedBina
val copyGeneratedBinaryForMacOS by tasks.register("copyGeneratedBinaryForMacOS") {
group = "rust-compiling"
description = "Copy all generated macOS binaries to generated resources folder"
dependsOn(copyGeneratedBinaryForMacOSX8664, copyGeneratedBinaryForMacOSArch64)
dependsOn(copyGeneratedBinaryForMacOSArch64)
}

val copyGeneratedBinaryForLinuxX8664 by tasks.register<Copy>("copyGeneratedBinaryForLinuxX86_64") {
Expand Down
103 changes: 88 additions & 15 deletions anoncred-kmm/anoncreds-kmp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
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"
val publishedMavenId: String = rootProject.group.toString()

plugins {
id("com.android.library")
Expand All @@ -15,7 +19,9 @@ plugins {
}

apply(plugin = "kotlinx-atomicfu")
version = "0.4.4"
apply(plugin = "org.gradle.maven-publish")
apply(plugin = "org.gradle.signing")
version = rootProject.version
group = publishedMavenId

fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
Expand Down Expand Up @@ -112,6 +118,7 @@ kotlin {
kotlinOptions.jvmTarget = "17"
}
}
applyDefaultHierarchyTemplate()

sourceSets {
val commonMain by getting {
Expand Down Expand Up @@ -229,31 +236,26 @@ publishing {
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 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)
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 = publishedMavenId
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")

sourceSets["main"].jniLibs {
Expand Down Expand Up @@ -289,17 +291,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")
}
}
6 changes: 6 additions & 0 deletions anoncred-kmm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ plugins {
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 = "io.iohk.atala.prism.anoncredskmp"
version = "0.4.4"

buildscript {
repositories {
mavenLocal()
Expand All @@ -16,6 +21,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

0 comments on commit 54b44d6

Please sign in to comment.