build.gradle.kts (5747B) - raw
1 import com.android.build.gradle.internal.api.BaseVariantOutputImpl 2 import kotlinx.coroutines.delay 3 import kotlinx.coroutines.launch 4 import kotlinx.coroutines.runBlocking 5 import org.gradle.configurationcache.extensions.capitalized 6 import java.io.ByteArrayOutputStream 7 8 plugins { 9 alias(libs.plugins.androidApplication) 10 alias(libs.plugins.kotlinAndroid) 11 alias(libs.plugins.compose.compiler) 12 id("kotlin-parcelize") 13 } 14 15 android { 16 namespace = rootProject.ext["applicationId"].toString() 17 compileSdk = 34 18 19 buildFeatures { 20 aidl = true 21 compose = true 22 } 23 24 defaultConfig { 25 applicationId = rootProject.ext["applicationId"].toString() 26 versionCode = rootProject.ext["appVersionCode"].toString().toInt() 27 versionName = rootProject.ext["appVersionName"].toString() 28 minSdk = 28 29 targetSdk = 34 30 multiDexEnabled = true 31 } 32 33 buildTypes { 34 release { 35 isMinifyEnabled = true 36 proguardFiles += file("proguard-rules.pro") 37 } 38 debug { 39 (properties["debug_flavor"] == null).also { 40 isDebuggable = !it 41 isMinifyEnabled = it 42 isShrinkResources = it 43 } 44 proguardFiles += file("proguard-rules.pro") 45 } 46 } 47 48 flavorDimensions += "abi" 49 50 //noinspection ChromeOsAbiSupport 51 productFlavors { 52 packaging { 53 jniLibs { 54 excludes += "**/*_neon.so" 55 } 56 resources { 57 excludes += "DebugProbesKt.bin" 58 excludes += "okhttp3/internal/publicsuffix/**" 59 excludes += "META-INF/*.version" 60 excludes += "META-INF/services/**" 61 excludes += "META-INF/*.kotlin_builtins" 62 excludes += "META-INF/*.kotlin_module" 63 } 64 } 65 66 create("core") { 67 dimension = "abi" 68 } 69 70 create("armv8") { 71 ndk { 72 abiFilters += "arm64-v8a" 73 } 74 dimension = "abi" 75 } 76 77 create("armv7") { 78 ndk { 79 abiFilters += "armeabi-v7a" 80 } 81 dimension = "abi" 82 } 83 84 create("all") { 85 ndk { 86 abiFilters += listOf("arm64-v8a", "armeabi-v7a") 87 } 88 dimension = "abi" 89 } 90 } 91 92 properties["debug_flavor"]?.let { 93 android.productFlavors.find { it.name == it.toString()}?.setIsDefault(true) 94 } 95 96 applicationVariants.all { 97 outputs.map { it as BaseVariantOutputImpl }.forEach { outputVariant -> 98 outputVariant.outputFileName = when { 99 name.startsWith("core") -> "core.apk" 100 else -> "snapenhance_${rootProject.ext["appVersionName"]}-${outputVariant.name}.apk" 101 } 102 } 103 } 104 105 compileOptions { 106 sourceCompatibility = JavaVersion.VERSION_21 107 targetCompatibility = JavaVersion.VERSION_21 108 } 109 110 kotlinOptions { 111 jvmTarget = "21" 112 } 113 } 114 115 androidComponents { 116 onVariants(selector().withFlavor("abi", "core")) { 117 it.packaging.jniLibs.apply { 118 pickFirsts.set(listOf("**/lib${rootProject.ext["buildHash"]}.so")) 119 excludes.set(listOf("**/*.so")) 120 } 121 } 122 } 123 124 dependencies { 125 fun fullImplementation(dependencyNotation: Any) { 126 compileOnly(dependencyNotation) 127 for (flavorName in listOf("armv8", "armv7", "all")) { 128 dependencies.add("${flavorName}Implementation", dependencyNotation) 129 } 130 } 131 132 implementation(project(":core")) 133 implementation(project(":common")) 134 implementation(libs.androidx.documentfile) 135 implementation(libs.gson) 136 implementation(libs.ffmpeg.kit) 137 implementation(libs.osmdroid.android) 138 implementation(libs.rhino) 139 implementation(libs.androidx.activity.ktx) 140 fullImplementation(platform(libs.androidx.compose.bom)) 141 fullImplementation(libs.bcprov.jdk18on) 142 fullImplementation(libs.androidx.navigation.compose) 143 fullImplementation(libs.androidx.material.icons.core) 144 fullImplementation(libs.androidx.material.ripple) 145 fullImplementation(libs.androidx.material.icons.extended) 146 fullImplementation(libs.androidx.material3) 147 fullImplementation(libs.coil.compose) 148 fullImplementation(libs.coil.video) 149 fullImplementation(libs.colorpicker.compose) 150 fullImplementation(libs.androidx.ui.tooling.preview) 151 properties["debug_flavor"]?.let { 152 debugImplementation(libs.androidx.ui.tooling) 153 } 154 } 155 156 afterEvaluate { 157 properties["debug_flavor"]?.toString()?.let { tasks.findByName("install${it.capitalized()}Debug") }?.doLast { 158 runCatching { 159 val devices = ByteArrayOutputStream().also { 160 exec { 161 commandLine("adb", "devices") 162 standardOutput = it 163 } 164 }.toString().lines().drop(1).mapNotNull { 165 line -> line.split("\t").firstOrNull()?.takeIf { it.isNotEmpty() } 166 } 167 168 runBlocking { 169 devices.forEach { device -> 170 launch { 171 exec { 172 commandLine("adb", "-s", device, "shell", "am", "force-stop", properties["debug_package_name"]) 173 } 174 delay(500) 175 exec { 176 commandLine("adb", "-s", device, "shell", "am", "start", properties["debug_package_name"]) 177 } 178 } 179 } 180 } 181 } 182 } 183 } 184 properties["debug_flavor"]?.let { 185 configurations.all { 186 exclude(group = "androidx.profileinstaller", "profileinstaller") 187 } 188 }