Skip to content

Commit

Permalink
chore: update gradle
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <[email protected]>
  • Loading branch information
hamada147 committed Mar 6, 2024
1 parent f9f2624 commit 964b443
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 102 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true

env:
JAVA_VERSION: 11
JAVA_VERSION: 17
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}

Expand All @@ -21,20 +21,20 @@ jobs:
runs-on: macos-latest
steps:
- name: "Checkout the repo"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
fetch-depth: 0

- name: "Install Java ${{ env.JAVA_VERSION }}"
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: "${{ env.JAVA_VERSION }}"
distribution: zulu

- name: "Gradle Build Action"
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3

- name: "Test Kotlin code is properly formatted"
working-directory: ./anoncred-kmm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: "Release Libraries"

env:
JAVA_VERSION: 11
JAVA_VERSION: 17
RUST_VERSION: "1.73.0"
CROSS_VERSION: "0.2.4"

Expand Down
6 changes: 3 additions & 3 deletions anoncred-kmm/anoncred-wrapper-rust/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ val rustClean by tasks.register("rustClean") {
description = "Delete the generated files and folders that is being generated by this Gradle Script"
delete(projectDir.resolve("target"))
delete(rootDir.parentFile.resolve("target"))
delete(buildDir)
delete(project.layout.buildDirectory)
}

tasks.matching { it.name == "clean" }.all {
Expand Down Expand Up @@ -333,7 +333,7 @@ val copyGeneratedBinaryForAndroidX8664 by tasks.register<Copy>("copyGeneratedBin
duplicatesStrategy = DuplicatesStrategy.INCLUDE
include("*.so", "*.a", "*.d", "*.dylib")
from(projectDir.resolve("target").resolve("x86_64-linux-android").resolve("release"))
into(rootDir.resolve("anoncreds-kmp").resolve("build").resolve("generatedResources").resolve("android").resolve("main").resolve("jniLibs").resolve("x86-64"))
into(rootDir.resolve("anoncreds-kmp").resolve("build").resolve("generatedResources").resolve("android").resolve("main").resolve("jniLibs").resolve("x86_64"))
dependsOn(buildAnonCredWrapperForAndroidX8664)
}

Expand Down Expand Up @@ -385,7 +385,7 @@ val copyGeneratedBinariesToCorrectLocation by tasks.register("copyGeneratedBinar
val copyBindings by tasks.register<Copy>("copyBindings") {
group = "rust-compiling"
description = "Copy generated bindings to the `anoncreds-kmm` module"
from(buildDir.resolve("generated"))
from(project.layout.buildDirectory.dir("generated"))
into(rootDir.resolve("anoncreds-kmp").resolve("build").resolve("generated"))
dependsOn(copyGeneratedBinariesToCorrectLocation)
}
Expand Down
187 changes: 98 additions & 89 deletions anoncred-kmm/anoncreds-kmp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.Base64

val os: OperatingSystem = OperatingSystem.current()
val publishedMavenId: String = "io.iohk.atala.prism.anoncredskmp"

plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("multiplatform")
id("org.jetbrains.dokka")
id("maven-publish")
id("signing")
}

apply(plugin = "kotlinx-atomicfu")
version = "0.4.3"
group = "io.iohk.atala.prism.anoncredskmp"
version = "0.4.4"
group = publishedMavenId

fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
cinterops {
val anoncreds_wrapper by creating {
val crate = this.name
packageName("$crate.cinterop")
header(
buildDir
.resolve("generated")
project.layout.buildDirectory.asFile.get()
.resolve("nativeInterop")
.resolve("cinterop")
.resolve("headers")
Expand All @@ -43,6 +46,7 @@ fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
.absolutePath
)
}

"macosArm64" -> {
extraOpts(
"-libraryPath",
Expand All @@ -54,6 +58,7 @@ fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
.absolutePath
)
}

"ios" -> {
extraOpts(
"-libraryPath",
Expand All @@ -65,6 +70,7 @@ fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
.absolutePath
)
}

else -> {
throw GradleException("Unsupported linking")
}
Expand All @@ -73,96 +79,64 @@ fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
}
}

/**
* The `javadocJar` variable is used to register a `Jar` task to generate a Javadoc JAR file.
* The Javadoc JAR file is created with the classifier "javadoc" and it includes the HTML documentation generated
* by the `dokkaHtml` task.
*/
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
kotlinOptions.jvmTarget = "17"
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
androidTarget {
publishAllLibraryVariants()
}

// if (os.isMacOsX) {
// macosX64("native") {
// compilations.getByName("main") {
// this.anoncredsCinterops("macosX64")
// }
// }
// if (System.getProperty("os.arch") != "x86_64") {
// macosArm64 {
// compilations.getByName("main") {
// this.anoncredsCinterops("macosArm64")
// }
// }
// }
// }

/*
val crateTargetLibDir = rootDir.resolve("anoncred-wrapper-rust").resolve("target").resolve("debug")
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> {
if (System.getProperty("os.arch") != "x86_64") {
macosArm64("native")
} else {
macosX64("native")
publishing {
publications {
withType<MavenPublication> {
artifact(javadocJar)
}
}
}
hostOs == "Linux" -> linuxArm64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
compilations.getByName("main") {
println("nativeTarget-only-main")
cinterops {
val anoncreds_wrapper by creating {
val crate = this.name
packageName("$crate.cinterop")
header(
generatedDir.resolve("nativeInterop").resolve("cinterop").resolve("headers")
.resolve(crate).resolve("$crate.h")
)
tasks.named(interopProcessingTaskName) {
dependsOn(":anoncred-wrapper-rust:buildRust")
}
extraOpts("-libraryPath", crateTargetLibDir.absolutePath)
}
}
androidTarget {
publishAllLibraryVariants()
compilations.all {
kotlinOptions.jvmTarget = "17"
}
}
*/

sourceSets {
val commonMain by getting {
val generatedDir = buildDir
val generatedDir = project.layout.buildDirectory.asFile.get()
.resolve("generated")
.resolve("commonMain")
.resolve("kotlin")
kotlin.srcDir(generatedDir)
dependencies {
implementation("com.squareup.okio:okio:3.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
implementation("com.squareup.okio:okio:3.7.0")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.5.0")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0")
}
}
val jvmMain by getting {
val generatedDir = buildDir
val generatedDir = project.layout.buildDirectory.asFile.get()
.resolve("generated")
.resolve("jvmMain")
.resolve("kotlin")
kotlin.srcDir(generatedDir)
val generatedResources = buildDir
val generatedResources = project.layout.buildDirectory.asFile.get()
.resolve("generatedResources")
.resolve("jvm")
.resolve("main")
Expand All @@ -173,12 +147,12 @@ kotlin {
}
val jvmTest by getting
val androidMain by getting {
val generatedDir = buildDir
val generatedDir = project.layout.buildDirectory.asFile.get()
.resolve("generated")
.resolve("androidMain")
.resolve("kotlin")
kotlin.srcDir(generatedDir)
val generatedResources = buildDir
val generatedResources = project.layout.buildDirectory.asFile.get()
.resolve("generatedResources")
.resolve("android")
.resolve("main")
Expand All @@ -193,21 +167,6 @@ kotlin {
implementation("junit:junit:4.13.2")
}
}
// if (os.isMacOsX) {
// val nativeMain by getting { // aka "macosX64"
// val generatedDir = buildDir
// .resolve("generated")
// .resolve("nativeMain")
// .resolve("kotlin")
// kotlin.srcDir(generatedDir)
// }
// val nativeTest by getting
// if (System.getProperty("os.arch") != "x86_64") {
// val macosArm64Main by getting {
// dependsOn(nativeMain)
// }
// }
// }
all {
languageSettings {
optIn("kotlin.RequiresOptIn")
Expand All @@ -227,6 +186,57 @@ val rustClean by tasks.register("rustClean") {
}

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"
Expand All @@ -241,14 +251,14 @@ publishing {

android {
ndkVersion = "26.0.10792818"
compileSdk = 33
compileSdk = 34
namespace = "io.iohk.atala.prism.anoncredskmp"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")

sourceSets["main"].jniLibs {
setSrcDirs(
listOf(
buildDir
project.layout.buildDirectory.asFile.get()
.resolve("generatedResources")
.resolve("android")
.resolve("main")
Expand All @@ -258,11 +268,10 @@ android {
}
defaultConfig {
minSdk = 21
targetSdk = 32
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
/**
* Because Software Components will not be created automatically for Maven publishing from
Expand All @@ -286,10 +295,10 @@ afterEvaluate {
tasks.withType<ProcessResources> {
dependsOn(":anoncred-wrapper-rust:buildRust")
}
tasks.named("lintAnalyzeDebug") {
this.enabled = false
tasks.named("packageDebugResources") {
dependsOn(":anoncred-wrapper-rust:copyBindings")
}
tasks.named("lintAnalyzeRelease") {
this.enabled = false
tasks.named("packageReleaseResources") {
dependsOn(":anoncred-wrapper-rust:copyBindings")
}
}
Loading

0 comments on commit 964b443

Please sign in to comment.