/
build.gradle.kts
103 lines (96 loc) · 3.42 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("rustPlugin")
{{~#each android-app-plugins}}
id("{{this}}"){{/each}}
}
android {
compileSdk = 33
defaultConfig {
manifestPlaceholders["usesCleartextTraffic"] = "false"
applicationId = "{{reverse-domain app.domain}}.{{snake-case app.name}}"
minSdk = {{android.min-sdk-version}}
targetSdk = 33
versionCode = 1
versionName = "1.0"
}
sourceSets.getByName("main") {
{{#if android.vulkan-validation}}// Vulkan validation layers
val ndkHome = System.getenv("NDK_HOME")
jniLibs.srcDir("${ndkHome}/sources/third_party/vulkan/src/build-android/jniLibs")
{{/if}}
}
buildTypes {
getByName("debug") {
manifestPlaceholders["usesCleartextTraffic"] = "true"
isDebuggable = true
isJniDebuggable = true
isMinifyEnabled = false
packagingOptions {
{{~#each targets}}
jniLibs.keepDebugSymbols.add("*/{{this.abi}}/*.so")
{{/each}}
}
}
getByName("release") {
isMinifyEnabled = true
val proguards = fileTree(".") {
include("*.pro")
}
proguardFiles(*proguards.toList().toTypedArray())
}
}
flavorDimensions.add("abi")
productFlavors {
create("universal") {
dimension = "abi"
ndk {
abiFilters += (findProperty("abiList") as? String)?.split(",") ?: listOf(
{{~#each targets}}
"{{this.abi}}",{{/each}}
)
}
}
{{~#each targets}}
create("{{this.arch}}") {
dimension = "abi"
ndk {
abiFilters += listOf("{{this.abi}}")
}
}
{{/each}}
}
assetPacks += mutableSetOf({{quote-and-join-colon-prefix asset-packs}})
namespace = "{{reverse-domain app.domain}}.{{snake-case app.name}}"
}
rust {
rootDirRel = "{{root-dir-rel}}"
targets = (findProperty("targetList") as? String)?.split(",") ?: listOf({{quote-and-join target-names}})
arches = (findProperty("archList") as? String)?.split(",") ?: listOf({{quote-and-join arches}})
}
dependencies {
{{~#each android-app-dependencies-platform}}
implementation(platform("{{this}}")){{/each}}
{{~#each android-app-dependencies}}
implementation("{{this}}"){{/each}}
implementation("androidx.webkit:webkit:1.5.0")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("com.google.android.material:material:1.7.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.4")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
}
apply(from = "tauri.build.gradle.kts")
afterEvaluate {
android.applicationVariants.all {
tasks["mergeUniversalReleaseJniLibFolders"].dependsOn(tasks["rustBuildRelease"])
tasks["mergeUniversalDebugJniLibFolders"].dependsOn(tasks["rustBuildDebug"])
if (findProperty("targetList") == null) {
productFlavors.filter{ it.name != "universal" }.forEach { _ ->
val archAndBuildType = name.capitalize()
tasks["merge${archAndBuildType}JniLibFolders"].dependsOn(tasks["rustBuild${archAndBuildType}"])
}
}
}
}