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 3, 2024
1 parent f9f2624 commit f452f7d
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 61 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
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
102 changes: 53 additions & 49 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,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")
}
}
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 f452f7d

Please sign in to comment.