Files
SlimeVR-Server/server/android/build.gradle.kts

190 lines
5.2 KiB
Kotlin

/*
* This file was generated by the Gradle "init" task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.3/userguide/java_library_plugin.html
*/
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.util.Properties
plugins {
kotlin("android")
kotlin("plugin.serialization")
id("com.github.gmazzo.buildconfig")
id("com.android.application")
id("org.ajoberstar.grgit")
id("rust")
}
val tauriProperties = Properties().apply {
val propFile = file("tauri.properties")
if (propFile.exists()) {
propFile.inputStream().use { load(it) }
}
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs.set(listOf("-Xvalue-classes"))
}
}
// Set compiler to use UTF-8
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<Test> {
systemProperty("file.encoding", "UTF-8")
}
tasks.withType<Javadoc> {
options.encoding = "UTF-8"
}
repositories {
google()
}
rust {
rootDirRel = if (projectDir.absolutePath.contains("gen/android")) {
"../../../../../"
} else {
"../../gui/src-tauri"
}
}
dependencies {
implementation(project(":server:core"))
implementation("commons-cli:commons-cli:1.8.0")
implementation("org.apache.commons:commons-lang3:3.15.0")
// Android stuff
implementation("androidx.webkit:webkit:1.14.0")
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("androidx.activity:activity-ktx:1.10.1")
implementation("androidx.core:core-ktx:1.13.1")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
// Serial
implementation("com.github.mik3y:usb-serial-for-android:3.7.0")
}
// The android block is where you configure all your Android-specific build options.
extra.apply {
set("gitVersionCode", grgit.tag.list().size)
set("gitVersionName", grgit.describe(mapOf("tags" to true, "always" to true)))
}
android {
namespace = "dev.slimevr.android"
compileSdk = 35
packaging {
resources.excludes.add("META-INF/*")
}
defaultConfig {
manifestPlaceholders["usesCleartextTraffic"] = "false"
applicationId = "dev.slimevr.server.android"
minSdk = 26
targetSdk = 35
// adds an offset of the version code as we might do apk releases in the middle of actual
// releases if we failed on bundling or stuff
val versionCodeOffset = 1
// Defines the version number of your app.
versionCode = (extra["gitVersionCode"] as? Int)?.plus(versionCodeOffset) ?: 0
// Defines a user-friendly version name for your app.
versionName = extra["gitVersionName"] as? String ?: "v0.0.0"
setProperty("archivesBaseName", "app")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters += listOf("x86", "x86_64", "arm64-v8a", "armeabi-v7a")
}
}
signingConfigs {
create("release") {
val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
keyAlias = keystoreProperties["keyAlias"] as String?
keyPassword = keystoreProperties["password"] as String?
storeFile = keystoreProperties["storeFile"]?.let { file(it) }
storePassword = keystoreProperties["password"] as String?
}
}
/* The buildTypes block is where you can configure multiple build types.
By default, the build system defines two build types: debug and release. The
debug build type is not explicitly shown in the default build configuration,
but it includes debugging tools and is signed with the debug key. The release
build type applies ProGuard settings and is not signed by default. */
buildTypes {
getByName("debug") {
manifestPlaceholders["usesCleartextTraffic"] = "true"
isDebuggable = true
isJniDebuggable = true
isMinifyEnabled = false
packaging {
jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
jniLibs.keepDebugSymbols.add("*/x86/*.so")
jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
}
}
getByName("release") {
isMinifyEnabled = true
signingConfig = signingConfigs.getByName("release")
proguardFiles(
*fileTree(".") { include("**/*.pro") }
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
.toList().toTypedArray(),
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
buildConfig = true
}
}
try {
apply(from = "tauri.build.gradle.kts")
} catch (e: Exception) {
println("Couldn't enable tauri stuff")
}