Skip to content

Commit

Permalink
chore: update gradle
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 2, 2024
1 parent f9f2624 commit a6b6fcc
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 56 deletions.
100 changes: 49 additions & 51 deletions anoncred-kmm/anoncreds-kmp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val os: OperatingSystem = OperatingSystem.current()

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

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

fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
Expand All @@ -20,8 +20,7 @@ fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
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 +42,7 @@ fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
.absolutePath
)
}

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

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

else -> {
throw GradleException("Unsupported linking")
}
Expand All @@ -76,14 +78,17 @@ fun KotlinNativeCompilation.anoncredsCinterops(type: String) {
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
kotlinOptions.jvmTarget = "17"
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
androidTarget {
publishAllLibraryVariants()
compilations.all {
kotlinOptions.jvmTarget = "17"
}
}

// if (os.isMacOsX) {
Expand All @@ -101,46 +106,46 @@ kotlin {
// }
// }

/*
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")
/*
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")
}
}
hostOs == "Linux" -> linuxArm64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
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")
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)
}
extraOpts("-libraryPath", crateTargetLibDir.absolutePath)
}
}
}
}
*/
*/

sourceSets {
val commonMain by getting {
val generatedDir = buildDir
val generatedDir = project.layout.buildDirectory.asFile.get()
.resolve("generated")
.resolve("commonMain")
.resolve("kotlin")
Expand All @@ -157,12 +162,12 @@ kotlin {
}
}
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 +178,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 Down Expand Up @@ -241,14 +246,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 +263,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 +290,4 @@ afterEvaluate {
tasks.withType<ProcessResources> {
dependsOn(":anoncred-wrapper-rust:buildRust")
}
tasks.named("lintAnalyzeDebug") {
this.enabled = false
}
tasks.named("lintAnalyzeRelease") {
this.enabled = false
}
}
14 changes: 10 additions & 4 deletions anoncred-kmm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
kotlin("jvm") version "1.8.20"
kotlin("jvm") version "1.9.22"
id("com.android.library") version "8.1.4" apply false
}

buildscript {
Expand All @@ -11,12 +12,17 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21")
classpath("com.android.tools.build:gradle:7.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.21.0")
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

allprojects {
repositories {
mavenLocal()
Expand Down Expand Up @@ -47,7 +53,7 @@ subprojects {
exclude("**/generated/**")
exclude { projectDir.toURI().relativize(it.file.toURI()).path.contains("/generated/") }
exclude { element -> element.file.path.contains("generated/") }
exclude { it.file.path.contains("$buildDir/generated/") }
exclude("${project.layout.buildDirectory.asFile.get()}/generated/")
exclude { it.file.path.contains(layout.buildDirectory.dir("generated").get().toString()) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion anoncred-kmm/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit a6b6fcc

Please sign in to comment.