diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index d59a924175..2da444e54f 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -24,7 +24,7 @@ jobs: - name: Set up NDK uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 with: - ndk-version: r28c + ndk-version: r27d link-to-sdk: true local-cache: true - name: Install Rust diff --git a/.github/workflows/android-debug-artifact-ondemand.yml b/.github/workflows/android-debug-artifact-ondemand.yml index 4dd72ba16b..9fc823c843 100644 --- a/.github/workflows/android-debug-artifact-ondemand.yml +++ b/.github/workflows/android-debug-artifact-ondemand.yml @@ -43,7 +43,7 @@ jobs: - name: Set up NDK uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 with: - ndk-version: r28c + ndk-version: r27d link-to-sdk: true local-cache: true - name: Install Rust diff --git a/.github/workflows/android-debug-artifact-release.yml b/.github/workflows/android-debug-artifact-release.yml index e837df793f..69da331e17 100644 --- a/.github/workflows/android-debug-artifact-release.yml +++ b/.github/workflows/android-debug-artifact-release.yml @@ -17,7 +17,7 @@ jobs: - name: Set up NDK uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 with: - ndk-version: r28c + ndk-version: r27d link-to-sdk: true local-cache: true - name: Install Rust diff --git a/.github/workflows/android-feature.yml b/.github/workflows/android-feature.yml index 23aca0ec1b..01b6fdb71a 100755 --- a/.github/workflows/android-feature.yml +++ b/.github/workflows/android-feature.yml @@ -26,7 +26,7 @@ jobs: id: setup-ndk uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 with: - ndk-version: r28c + ndk-version: r27d link-to-sdk: true local-cache: true - name: Check formatting using spotless diff --git a/.github/workflows/android-main.yml b/.github/workflows/android-main.yml index 16f41e2f07..0abf4f78ac 100644 --- a/.github/workflows/android-main.yml +++ b/.github/workflows/android-main.yml @@ -25,7 +25,7 @@ jobs: - name: Set up NDK uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 with: - ndk-version: r28c + ndk-version: r27d link-to-sdk: true local-cache: true - name: Check formatting using spotless diff --git a/app/build.gradle b/app/build.gradle index c394440b3f..2a485f3dd1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ apply plugin: 'com.google.devtools.ksp' android { namespace "com.amaze.filemanager" - compileSdk libs.versions.compileSdk.get().toInteger() + compileSdk tools.versions.compileSdk.get().toInteger() packagingOptions { resources { excludes += ['proguard-project.txt', 'project.properties', 'META-INF/LICENSE.txt', 'META-INF/LICENSE', 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/DEPENDENCIES.txt', 'META-INF/DEPENDENCIES', 'META-INF/versions/9/OSGI-INF/MANIFEST.MF'] @@ -99,7 +99,7 @@ android { } kotlinOptions { - jvmTarget = '17' + jvmTarget = tools.versions.jvmTarget.get() } testOptions { @@ -338,5 +338,4 @@ repositories { google() mavenCentral() maven { url "https://jitpack.io" } - maven { url "https://jcenter.bintray.com" } } diff --git a/build.gradle b/build.gradle index 379e3c33b2..6e5aad4eb1 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,6 @@ allprojects { google() mavenCentral() maven { url "https://jitpack.io" } - maven { url "https://jcenter.bintray.com" } maven { url "https://repository.liferay.com/nexus/content/repositories/public/"} } tasks.withType(Test).tap { diff --git a/commons_compress_7z/build.gradle b/commons_compress_7z/build.gradle index 74d66012b3..642d5fe926 100644 --- a/commons_compress_7z/build.gradle +++ b/commons_compress_7z/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android' android { namespace "com.amaze.filemanager.filesystem.compressed.sevenz" - compileSdk libs.versions.compileSdk.get().toInteger() + compileSdk tools.versions.compileSdk.get().toInteger() defaultConfig { minSdkVersion libs.versions.minSdk.get().toInteger() diff --git a/file_operations/build.gradle b/file_operations/build.gradle index 5400d64458..0e4e069b05 100644 --- a/file_operations/build.gradle +++ b/file_operations/build.gradle @@ -2,15 +2,16 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'com.google.devtools.ksp' apply plugin: 'org.mozilla.rust-android-gradle.rust-android' +apply from: "../gradle/setupRustAndroidLocal.gradle" android { namespace "com.amaze.filemanager.fileoperations" - compileSdk libs.versions.compileSdk.get().toInteger() - ndkVersion libs.versions.ndk.get() + compileSdk tools.versions.compileSdk.get().toInteger() + ndkVersion tools.versions.ndk.get() defaultConfig { minSdkVersion libs.versions.minSdk.get().toInteger() - ndkVersion libs.versions.ndk.get() + ndkVersion tools.versions.ndk.get() testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -43,7 +44,7 @@ android { } kotlinOptions { - jvmTarget = '17' + jvmTarget = tools.versions.jvmTarget.get() } } @@ -61,7 +62,7 @@ cargo { } kotlin { - jvmToolchain(17) + jvmToolchain(tools.versions.jvmTarget.get().toInteger()) } // Ensure Rust libraries are built before Android tasks @@ -135,4 +136,10 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation libs.androidX.appcompat +} + +tasks.matching { + it.name.startsWith('cargoBuild') +}.configureEach { + it.dependsOn 'setupRustAndroidLocal' } \ No newline at end of file diff --git a/file_operations/setup_rust_android.sh b/file_operations/setup_rust_android.sh index 132c3b9551..f52e6b81d0 100755 --- a/file_operations/setup_rust_android.sh +++ b/file_operations/setup_rust_android.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Setup script for Rust Android development # This script: diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e475d17e45..a2bb14acbe 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,7 @@ [versions] -compileSdk = "34" minSdk = "21" targetSdk = "35" kotlin = "1.9.25" -ndk = "28.2.13676358" #r28c jacocoAndroid = "0.2.1" gradle = "8.5.2" diff --git a/gradle/setupRustAndroidLocal.gradle b/gradle/setupRustAndroidLocal.gradle new file mode 100644 index 0000000000..12304d026c --- /dev/null +++ b/gradle/setupRustAndroidLocal.gradle @@ -0,0 +1,46 @@ +tasks.register("setupRustAndroidLocal") { + + onlyIf { System.getenv("GITHUB_ACTIONS") == null } + + doFirst { + println("Setting up Rust for Android build...") + } + + // Detect existence of rustup. + def rustupExists = { + + // First check common installation path + def isWindows = System.getProperty("os.name").toLowerCase().contains("windows") + def home = System.getProperty("user.home") + def rustupPath = isWindows + ? new File(home, ".cargo/bin/rustup.exe") + : new File(home, ".cargo/bin/rustup") + + if (rustupPath.exists() && rustupPath.canExecute()) { + return true + } + + // If not, check on user $PATH/%PATH% + try { + def process = new ProcessBuilder("rustup") + .redirectErrorStream(true) + .start() + process.waitFor() + return process.exitValue() == 0 + } catch (IOException ignored) { + return false + } + }() + + if (!rustupExists) { + throw new GradleException("rustup is not installed or not found in PATH. Please install rustup from https://rustup.rs/ and ensure it is accessible.") + } + + doLast { + exec { + workingDir file(rootProject.project("file_operations").projectDir) + commandLine("env", "bash", "setup_rust_android.sh") + } + println("Rust targets for Android have been set up successfully.") + } +} \ No newline at end of file diff --git a/gradle/tools.versions.toml b/gradle/tools.versions.toml new file mode 100644 index 0000000000..58bc22ce88 --- /dev/null +++ b/gradle/tools.versions.toml @@ -0,0 +1,4 @@ +[versions] +compileSdk = "34" +jvmTarget = "17" +ndk = "27.3.13750724" #r27d LTS \ No newline at end of file diff --git a/portscanner/build.gradle b/portscanner/build.gradle index ee039f9b63..6a90d132fb 100644 --- a/portscanner/build.gradle +++ b/portscanner/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'kotlin-parcelize' android { namespace 'com.stealthcopter.networktools' - compileSdk libs.versions.compileSdk.get().toInteger() + compileSdk tools.versions.compileSdk.get().toInteger() defaultConfig { minSdk libs.versions.minSdk.get().toInteger() @@ -28,7 +28,7 @@ android { } kotlin { - jvmToolchain(17) + jvmToolchain(tools.versions.jvmTarget.get().toInteger()) } dependencies { diff --git a/settings.gradle b/settings.gradle index 70edc43f9d..4fada0d720 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,11 @@ include ':file_operations' include ':portscanner' include ':app', ':commons_compress_7z' + +dependencyResolutionManagement { + versionCatalogs { + create("tools") { + from(files("gradle/tools.versions.toml")) + } + } +}