From 741d2efc8b01680036645bd46b192f1ebb5f247b Mon Sep 17 00:00:00 2001 From: rtcall Date: Mon, 17 Mar 2025 08:44:26 +0100 Subject: [PATCH 1/5] add dependabot for gradle --- .github/dependabot.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index e00f28d2..b49aa381 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -9,3 +9,11 @@ updates: ignore: - dependency-name: "*" update-types: ["version-update:semver-patch"] # ignore patch updates + + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "daily" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-patch"] # ignore patch updates From 5b2db5d3ec207ccce676531de9fed14e4e605e9d Mon Sep 17 00:00:00 2001 From: rtcall Date: Mon, 24 Mar 2025 09:20:08 +0100 Subject: [PATCH 2/5] add liveview-native-core-host dependency for native library fetching --- .gitignore | 4 +++ buildSrc/src/main/kotlin/Util.kt | 59 ++++++++++++++++++++++---------- client-addons/build.gradle.kts | 4 ++- gradle/libs.versions.toml | 4 ++- 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 00b88e78..66391ad6 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,7 @@ live_view_native_jetpack-*.tar # compiled static assets from test suites priv/static + +# host libs +core-jetpack-desktop-libs/jniLibs/**/*.so +core-jetpack-desktop-libs/jniLibs/**/*.dylib diff --git a/buildSrc/src/main/kotlin/Util.kt b/buildSrc/src/main/kotlin/Util.kt index 29a865d3..515864fa 100644 --- a/buildSrc/src/main/kotlin/Util.kt +++ b/buildSrc/src/main/kotlin/Util.kt @@ -1,26 +1,47 @@ import org.gradle.api.tasks.testing.Test import java.io.File +import java.util.zip.ZipFile -// TODO The Core-Jetpack project only generates the native platform library files for the -// following architectures (arm, arm64, x86, and x86_64). In order to run the tests in the local -// machine, we need the library for the host machine. For now, this file is being generated by -// adding the "darwin-aarch64" (or "darwin-x86-64" for Intel Macbooks) target, and running the -// following command in the Core-Jetpack project: `./gradlew assembleRelease`. -// The library files are generated at "core/build/rustJniLibs/desktop" directory. The ideal -// solution is release a dependency just for unit tests and declare at the `dependencies` section -// above like: -// `testImplementation "com.github.liveview-native:liveview-native-core-jetpack-host:"` fun copyDesktopJniLibs(rootDir: File, test: Test) { + val classpath = test.classpath.files + val hostJar = classpath.find { it.name.contains("liveview-native-core-host") } + val jniLibsForDesktopDir = File("$rootDir/core-jetpack-desktop-libs/jniLibs") - val archTypesSubdirs = jniLibsForDesktopDir.listFiles() ?: emptyArray() - for (dir in archTypesSubdirs) { - // Selecting the proper JNI lib file for run the unit tests - // in according to the architecture. e.g.: darwin-aarch64, darwin-x86-64 - val arch = System.getProperty("os.arch").replace("_", "-") - if (dir.isDirectory && dir.name.contains(arch)) { - test.systemProperty("java.library.path", dir.absolutePath) - test.systemProperty("jna.library.path", dir.absolutePath) - break + test.systemProperty("java.library.path", jniLibsForDesktopDir.absolutePath) + test.systemProperty("jna.library.path", jniLibsForDesktopDir.absolutePath) + test.classpath = test.classpath.plus(test.project.files(jniLibsForDesktopDir.absolutePath)) + + if (hostJar != null && hostJar.exists()) { + println("found host jar: ${hostJar.absolutePath}") + + // Create destination directories + val darwinDir = File("${rootDir}/core-jetpack-desktop-libs/jniLibs/darwin-aarch64") + val linuxDir = File("${rootDir}/core-jetpack-desktop-libs/jniLibs/linux-x86-64") + val windowsDir = File("${rootDir}/core-jetpack-desktop-libs/jniLibs/windows-x86-64") + + ZipFile(hostJar).use { zip -> + zip.entries().asSequence().forEach { entry -> + if (!entry.isDirectory) { + val destDir = when { + entry.name.endsWith(".dylib") -> darwinDir + entry.name.endsWith(".so") -> linuxDir + entry.name.endsWith(".dll") -> windowsDir + else -> null + } + + destDir?.let { dir -> + val destFile = File(dir, File(entry.name).name) + println("extracting: ${destFile.absolutePath}") + zip.getInputStream(entry).use { input -> + destFile.outputStream().use { output -> + input.copyTo(output) + } + } + } + } + } } + } else { + println("host jar not found in test classpath") } -} \ No newline at end of file +} diff --git a/client-addons/build.gradle.kts b/client-addons/build.gradle.kts index c8a094f4..cf52175a 100644 --- a/client-addons/build.gradle.kts +++ b/client-addons/build.gradle.kts @@ -61,6 +61,8 @@ dependencies { testImplementation(libs.androidx.compose.ui.test.junit4) testImplementation(libs.io.coil.kt.coil.test) testImplementation(libs.junit) + + testImplementation(libs.liveview.native.core.host) } // Configuring Java Lib Path in order to find the native library before running the Unit Tests @@ -82,4 +84,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8138b68f..6744e83a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,8 @@ koin-bom= "4.0.0-RC1" kotlin = "1.9.21" kotlin-immutable-collections = "0.3.7" kotlinx-serialization-json = "1.6.0" -live-form = "main-SNAPSHOT" +live-form = "0.4.0-rc.1" +liveview-native-core-host = "0.4.1-rc-2" liveview-native-core-jetpack = "0.4.0-alpha-4" okhttp = "4.12.0" org-jsoup = "1.17.2" @@ -58,6 +59,7 @@ koin-core = { module = "io.insert-koin:koin-core" } koin-test = { module = "io.insert-koin:koin-test" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } live-form = { module = "com.github.liveview-native:liveview-native-live-form", version.ref = "live-form" } +liveview-native-core-host = { module = "org.phoenixframework:liveview-native-core-host", version.ref = "liveview-native-core-host" } net-java-dev-jna = { group = "net.java.dev.jna", name = "jna", version.ref = "jna" } okhttp = { module = "com.squareup.okhttp3:okhttp" } okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttp" } From 90d392603f862a6aa9c71b1cd2a17e4ad69fd2f0 Mon Sep 17 00:00:00 2001 From: rtcall Date: Sun, 6 Apr 2025 22:09:15 +0200 Subject: [PATCH 3/5] use release jar for native lib fetching --- buildSrc/src/main/kotlin/Util.kt | 82 ++++++++++++++++---------------- client-addons/build.gradle.kts | 9 ++-- client/build.gradle.kts | 7 ++- gradle/libs.versions.toml | 2 - 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/buildSrc/src/main/kotlin/Util.kt b/buildSrc/src/main/kotlin/Util.kt index 515864fa..783ab518 100644 --- a/buildSrc/src/main/kotlin/Util.kt +++ b/buildSrc/src/main/kotlin/Util.kt @@ -1,47 +1,47 @@ import org.gradle.api.tasks.testing.Test +import org.gradle.api.GradleException +import org.gradle.kotlin.dsl.withGroovyBuilder import java.io.File -import java.util.zip.ZipFile - -fun copyDesktopJniLibs(rootDir: File, test: Test) { - val classpath = test.classpath.files - val hostJar = classpath.find { it.name.contains("liveview-native-core-host") } - - val jniLibsForDesktopDir = File("$rootDir/core-jetpack-desktop-libs/jniLibs") - test.systemProperty("java.library.path", jniLibsForDesktopDir.absolutePath) - test.systemProperty("jna.library.path", jniLibsForDesktopDir.absolutePath) - test.classpath = test.classpath.plus(test.project.files(jniLibsForDesktopDir.absolutePath)) - - if (hostJar != null && hostJar.exists()) { - println("found host jar: ${hostJar.absolutePath}") - - // Create destination directories - val darwinDir = File("${rootDir}/core-jetpack-desktop-libs/jniLibs/darwin-aarch64") - val linuxDir = File("${rootDir}/core-jetpack-desktop-libs/jniLibs/linux-x86-64") - val windowsDir = File("${rootDir}/core-jetpack-desktop-libs/jniLibs/windows-x86-64") - - ZipFile(hostJar).use { zip -> - zip.entries().asSequence().forEach { entry -> - if (!entry.isDirectory) { - val destDir = when { - entry.name.endsWith(".dylib") -> darwinDir - entry.name.endsWith(".so") -> linuxDir - entry.name.endsWith(".dll") -> windowsDir - else -> null - } - - destDir?.let { dir -> - val destFile = File(dir, File(entry.name).name) - println("extracting: ${destFile.absolutePath}") - zip.getInputStream(entry).use { input -> - destFile.outputStream().use { output -> - input.copyTo(output) - } - } - } - } - } + +fun copyDesktopJniLibs(rootDir: File, test: Test, coreVersion: String) { + val currentArch = when { + org.gradle.internal.os.OperatingSystem.current().isMacOsX -> "darwin-aarch64" + org.gradle.internal.os.OperatingSystem.current().isLinux -> "linux-x86-64" + else -> throw GradleException("unsupported OS") + } + + val libsDir = File("${rootDir}/build/nativeLibs/$currentArch") + val outputFile = File("${libsDir}/liveview-native-core-$currentArch.jar") + + libsDir.mkdirs() + + val url = "https://github.com/liveview-native/liveview-native-core/releases/download/$coreVersion/liveview-native-core-$currentArch.jar" + + test.ant.withGroovyBuilder { + "get"( + "src" to url, + "dest" to outputFile.absolutePath, + "verbose" to true + ) + } + + println(outputFile.absolutePath) + + if (outputFile.exists()) { + test.classpath += test.project.files(outputFile) + + val jniLibsDir = File("${rootDir}/core-jetpack-desktop-libs/jniLibs/$currentArch") + jniLibsDir.mkdirs() + + test.project.copy { + from(test.project.zipTree(outputFile)) + into(jniLibsDir) + include("*.so", "*.dylib", "*.dll") } + + test.systemProperty("java.library.path", jniLibsDir.absolutePath) + test.systemProperty("jna.library.path", jniLibsDir.absolutePath) } else { - println("host jar not found in test classpath") + println("native library JAR not found at ${outputFile.absolutePath}") } } diff --git a/client-addons/build.gradle.kts b/client-addons/build.gradle.kts index cf52175a..57611bdf 100644 --- a/client-addons/build.gradle.kts +++ b/client-addons/build.gradle.kts @@ -61,14 +61,17 @@ dependencies { testImplementation(libs.androidx.compose.ui.test.junit4) testImplementation(libs.io.coil.kt.coil.test) testImplementation(libs.junit) - - testImplementation(libs.liveview.native.core.host) } // Configuring Java Lib Path in order to find the native library before running the Unit Tests tasks.withType().configureEach { doFirst { - copyDesktopJniLibs(rootDir, this@configureEach) + val coreVersion = project.extensions.getByType() + .named("libs") + .findVersion("liveview-native-core-jetpack") + .get() + .toString() + copyDesktopJniLibs(rootDir, this@configureEach, coreVersion) } } diff --git a/client/build.gradle.kts b/client/build.gradle.kts index 7173dfed..89a8e7fb 100755 --- a/client/build.gradle.kts +++ b/client/build.gradle.kts @@ -158,7 +158,12 @@ tasks.withType().configureEach // Configuring Java Lib Path in order to find the native library before running the Unit Tests tasks.withType().configureEach { doFirst { - copyDesktopJniLibs(rootDir, this@configureEach) + val coreVersion = project.extensions.getByType() + .named("libs") + .findVersion("liveview-native-core-jetpack") + .get() + .toString() + copyDesktopJniLibs(rootDir, this@configureEach, coreVersion) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6744e83a..585f374c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,6 @@ kotlin = "1.9.21" kotlin-immutable-collections = "0.3.7" kotlinx-serialization-json = "1.6.0" live-form = "0.4.0-rc.1" -liveview-native-core-host = "0.4.1-rc-2" liveview-native-core-jetpack = "0.4.0-alpha-4" okhttp = "4.12.0" org-jsoup = "1.17.2" @@ -59,7 +58,6 @@ koin-core = { module = "io.insert-koin:koin-core" } koin-test = { module = "io.insert-koin:koin-test" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } live-form = { module = "com.github.liveview-native:liveview-native-live-form", version.ref = "live-form" } -liveview-native-core-host = { module = "org.phoenixframework:liveview-native-core-host", version.ref = "liveview-native-core-host" } net-java-dev-jna = { group = "net.java.dev.jna", name = "jna", version.ref = "jna" } okhttp = { module = "com.squareup.okhttp3:okhttp" } okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttp" } From 6a5b0e8d1586bc62d40567597406f4441b979444 Mon Sep 17 00:00:00 2001 From: rtcall Date: Mon, 7 Apr 2025 08:44:32 +0200 Subject: [PATCH 4/5] revert dependabot --- .github/dependabot.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index b49aa381..e00f28d2 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -9,11 +9,3 @@ updates: ignore: - dependency-name: "*" update-types: ["version-update:semver-patch"] # ignore patch updates - - - package-ecosystem: "gradle" - directory: "/" - schedule: - interval: "daily" - ignore: - - dependency-name: "*" - update-types: ["version-update:semver-patch"] # ignore patch updates From 25ca1fa15368ed256dbedc4e450ee46f56111225 Mon Sep 17 00:00:00 2001 From: rtcall Date: Mon, 7 Apr 2025 08:58:36 +0200 Subject: [PATCH 5/5] gradle versions --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 585f374c..3a7a0824 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,9 +19,9 @@ jna = "5.14.0" # remember to update the jniLibs folder with updated *.so files koin-bom= "4.0.0-RC1" kotlin = "1.9.21" kotlin-immutable-collections = "0.3.7" -kotlinx-serialization-json = "1.6.0" +kotlinx-serialization-json = "1.6.3" live-form = "0.4.0-rc.1" -liveview-native-core-jetpack = "0.4.0-alpha-4" +liveview-native-core-jetpack = "0.4.1-rc-2" okhttp = "4.12.0" org-jsoup = "1.17.2" roborazzi = "1.25.0"