From 2c53cc7e702249742fbd9a9fbe4359ca7f753670 Mon Sep 17 00:00:00 2001 From: Velaron Date: Tue, 21 Jan 2025 18:33:07 +0200 Subject: [PATCH] android: upgrade buildsystem --- android/app/build.gradle.kts | 120 ++++++++---------- android/app/proguard-rules.pro | 22 ++++ android/build.gradle.kts | 6 +- android/gradle.properties | 5 +- android/gradle/libs.versions.toml | 23 ++++ .../gradle/wrapper/gradle-wrapper.properties | 4 +- android/settings.gradle.kts | 26 ++-- 7 files changed, 121 insertions(+), 85 deletions(-) create mode 100644 android/gradle/libs.versions.toml diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 0a17a2f2..0e554546 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -3,46 +3,64 @@ import java.time.Month import java.time.temporal.ChronoUnit plugins { - id("com.android.application") - id("org.jetbrains.kotlin.android") + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) } android { namespace = "su.xash.engine" - ndkVersion = "28.0.13004108" + ndkVersion = "28.0.13004108" + compileSdk = 35 defaultConfig { - applicationId = "su.xash" - applicationIdSuffix = "engine" + applicationId = "su.xash.engine" versionName = "0.21" versionCode = getBuildNum() minSdk = 21 - targetSdk = 34 - compileSdk = 34 - - externalNativeBuild { - cmake { - abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64") - arguments("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF") - } - } - } - - externalNativeBuild { - cmake { - version = "3.22.1" - path = file("CMakeLists.txt") - } + targetSdk = 35 } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } - kotlinOptions { - jvmTarget = "1.8" - } + kotlinOptions { + jvmTarget = "11" + } + + externalNativeBuild { + cmake { + path = file("CMakeLists.txt") + version = "3.22.1" + } + } + + buildFeatures { + viewBinding = true + buildConfig = true + } + + lint { + abortOnError = false + } + + androidResources { + noCompress += "" + } + + sourceSets { + getByName("main") { + assets.srcDirs("../../3rdparty/extras/xash-extras") + java.srcDir("../../3rdparty/SDL/android-project/app/src/main/java") + } + } + + packaging { + jniLibs { + keepDebugSymbols.add("**/*.so") + } + } buildTypes { debug { @@ -72,53 +90,19 @@ android { applicationIdSuffix = ".test" } } - - sourceSets { - getByName("main") { - assets.srcDirs("../../3rdparty/extras/xash-extras", "../moddb") - java.srcDir("../../3rdparty/SDL/android-project/app/src/main/java") - } - } - - lint { - abortOnError = false - } - - buildFeatures { - viewBinding = true - buildConfig = true - } - - androidResources { - noCompress += "" - } - - packaging { - jniLibs { - useLegacyPackaging = true - keepDebugSymbols.add("**/*.so") - } - } } dependencies { - implementation("com.google.android.material:material:1.11.0") - implementation("androidx.appcompat:appcompat:1.6.1") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.navigation:navigation-fragment-ktx:2.7.7") - implementation("androidx.navigation:navigation-ui-ktx:2.7.7") - implementation("androidx.cardview:cardview:1.0.0") - implementation("androidx.annotation:annotation:1.7.1") - implementation("androidx.fragment:fragment-ktx:1.6.2") - implementation("androidx.preference:preference-ktx:1.2.1") - implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") - implementation("androidx.work:work-runtime-ktx:2.9.0") -// implementation "androidx.legacy:legacy-support-v4:1.0.0" + implementation(libs.material) - implementation("com.madgag.spongycastle:prov:1.58.0.0") - implementation("in.dragonbra:javasteam:1.2.0") + implementation(libs.appcompat) + implementation(libs.navigation.runtime.ktx) + implementation(libs.navigation.fragment.ktx) + implementation(libs.navigation.ui.ktx) + implementation(libs.preference.ktx) + implementation(libs.swiperefreshlayout) - implementation("ch.acra:acra-http:5.11.2") + implementation(libs.acra.http) } fun getBuildNum(): Int { diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index 333fbb55..12325afe 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -1,3 +1,25 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + -keep class su.xash.engine.XashActivity { java.lang.String loadAndroidID(); java.lang.String getAndroidID(); diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 7ba28bac..78a9763a 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -1,5 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.5.0" apply false - id("org.jetbrains.kotlin.android") version "1.9.0" apply false -} \ No newline at end of file + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false +} diff --git a/android/gradle.properties b/android/gradle.properties index a346d2c7..1533bac1 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -8,8 +8,8 @@ # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects # org.gradle.parallel=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app's APK @@ -22,5 +22,6 @@ kotlin.code.style=official # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true + # Enable verbose output for CMake android.native.buildOutput=verbose diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml new file mode 100644 index 00000000..74b660b5 --- /dev/null +++ b/android/gradle/libs.versions.toml @@ -0,0 +1,23 @@ +[versions] +acraHttp = "5.12.0" +agp = "8.8.0" +appcompat = "1.7.0" +kotlin = "2.0.0" +material = "1.12.0" +navigationRuntimeKtx = "2.8.5" +preferenceKtx = "1.2.1" +swiperefreshlayout = "1.1.0" + +[libraries] +acra-http = { module = "ch.acra:acra-http", version.ref = "acraHttp" } +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +material = { module = "com.google.android.material:material", version.ref = "material" } +navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigationRuntimeKtx" } +navigation-runtime-ktx = { module = "androidx.navigation:navigation-runtime-ktx", version.ref = "navigationRuntimeKtx" } +navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationRuntimeKtx" } +preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "preferenceKtx" } +swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index ca2729fb..1b8f82b3 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Sep 22 13:23:17 EEST 2023 +#Tue Dec 31 17:33:17 EET 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 0f0c0589..9ae3cf5a 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -1,16 +1,22 @@ pluginManagement { - repositories { - google() - mavenCentral() - gradlePluginPortal() - } + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } } dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } } rootProject.name = "Xash3D FWGS"