196 lines
5.8 KiB
Plaintext
196 lines
5.8 KiB
Plaintext
import com.android.build.gradle.internal.tasks.factory.dependsOn
|
|
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.application)
|
|
alias(libs.plugins.kotlin.android)
|
|
alias(libs.plugins.ktlint)
|
|
alias(libs.plugins.ksp)
|
|
alias(libs.plugins.hilt)
|
|
alias(libs.plugins.kotlin.serialization)
|
|
alias(libs.plugins.kotlin.parcelize)
|
|
}
|
|
|
|
android {
|
|
val latestVersionName = "0.6.5"
|
|
namespace = "com.looker.droidify"
|
|
buildToolsVersion = "35.0.0"
|
|
compileSdk = 35
|
|
defaultConfig {
|
|
minSdk = 23
|
|
targetSdk = 35
|
|
applicationId = "com.looker.droidify"
|
|
versionCode = 650
|
|
versionName = latestVersionName
|
|
vectorDrawables.useSupportLibrary = false
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
isCoreLibraryDesugaringEnabled = true
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
freeCompilerArgs = listOf(
|
|
"-opt-in=kotlin.RequiresOptIn",
|
|
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
|
"-opt-in=kotlinx.coroutines.FlowPreview",
|
|
"-Xcontext-receivers"
|
|
)
|
|
}
|
|
|
|
androidResources {
|
|
generateLocaleConfig = true
|
|
}
|
|
|
|
sourceSets.forEach { source ->
|
|
val javaDir = source.java.srcDirs.find { it.name == "java" }
|
|
source.java {
|
|
srcDir(File(javaDir?.parentFile, "kotlin"))
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
applicationIdSuffix = ".debug"
|
|
resValue("string", "application_name", "Droid-ify-Debug")
|
|
}
|
|
release {
|
|
isMinifyEnabled = true
|
|
isShrinkResources = true
|
|
resValue("string", "application_name", "Droid-ify")
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard.pro"
|
|
)
|
|
}
|
|
create("alpha") {
|
|
initWith(getByName("debug"))
|
|
applicationIdSuffix = ".alpha"
|
|
resValue("string", "application_name", "Droid-ify Alpha")
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard.pro"
|
|
)
|
|
isDebuggable = true
|
|
isMinifyEnabled = true
|
|
}
|
|
all {
|
|
buildConfigField(
|
|
type = "String",
|
|
name = "VERSION_NAME",
|
|
value = "\"v$latestVersionName\""
|
|
)
|
|
}
|
|
}
|
|
packaging {
|
|
resources {
|
|
excludes += listOf(
|
|
"/DebugProbesKt.bin",
|
|
"/kotlin/**.kotlin_builtins",
|
|
"/kotlin/**.kotlin_metadata",
|
|
"/META-INF/**.kotlin_module",
|
|
"/META-INF/**.pro",
|
|
"/META-INF/**.version",
|
|
"/META-INF/{AL2.0,LGPL2.1,LICENSE*}",
|
|
"/META-INF/versions/9/previous-**.bin",
|
|
)
|
|
}
|
|
}
|
|
buildFeatures {
|
|
resValues = true
|
|
viewBinding = true
|
|
buildConfig = true
|
|
}
|
|
dependenciesInfo {
|
|
includeInApk = false
|
|
includeInBundle = false
|
|
}
|
|
}
|
|
|
|
ktlint {
|
|
android.set(true)
|
|
ignoreFailures.set(true)
|
|
debug.set(true)
|
|
reporters {
|
|
reporter(ReporterType.HTML)
|
|
}
|
|
filter {
|
|
exclude("**/generated/**")
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
coreLibraryDesugaring(libs.desugaring)
|
|
|
|
implementation(libs.material)
|
|
implementation(libs.core.ktx)
|
|
implementation(libs.activity)
|
|
implementation(libs.appcompat)
|
|
implementation(libs.fragment.ktx)
|
|
implementation(libs.lifecycle.viewModel)
|
|
implementation(libs.recyclerview)
|
|
implementation(libs.sqlite.ktx)
|
|
|
|
implementation(libs.image.viewer)
|
|
implementation(libs.bundles.coil)
|
|
|
|
implementation(libs.datastore.core)
|
|
implementation(libs.datastore.proto)
|
|
|
|
implementation(libs.kotlin.stdlib)
|
|
implementation(libs.datetime)
|
|
|
|
implementation(libs.coroutines.core)
|
|
implementation(libs.coroutines.android)
|
|
implementation(libs.coroutines.guava)
|
|
|
|
implementation(libs.libsu.core)
|
|
implementation(libs.shizuku.api)
|
|
api(libs.shizuku.provider)
|
|
|
|
implementation(libs.jackson.core)
|
|
implementation(libs.serialization)
|
|
|
|
implementation(libs.ktor.core)
|
|
implementation(libs.ktor.okhttp)
|
|
|
|
implementation(libs.work.ktx)
|
|
|
|
implementation(libs.hilt.core)
|
|
implementation(libs.hilt.android)
|
|
implementation(libs.hilt.ext.work)
|
|
ksp(libs.hilt.compiler)
|
|
ksp(libs.hilt.ext.compiler)
|
|
|
|
testImplementation(platform(libs.junit.bom))
|
|
testImplementation(libs.bundles.test.unit)
|
|
testRuntimeOnly(libs.junit.platform)
|
|
androidTestImplementation(platform(libs.junit.bom))
|
|
androidTestImplementation(libs.bundles.test.android)
|
|
|
|
// debugImplementation(libs.leakcanary)
|
|
}
|
|
|
|
// using a task as a preBuild dependency instead of a function that takes some time insures that it runs
|
|
task("detectAndroidLocals") {
|
|
val langsList: MutableSet<String> = HashSet()
|
|
|
|
// in /res are (almost) all languages that have a translated string is saved. this is safer and saves some time
|
|
fileTree("src/main/res").visit {
|
|
if (this.file.path.endsWith("strings.xml") &&
|
|
this.file.canonicalFile.readText().contains("<string")
|
|
) {
|
|
var languageCode = this.file.parentFile.name.replace("values-", "")
|
|
languageCode = if (languageCode == "values") "en" else languageCode
|
|
langsList.add(languageCode)
|
|
}
|
|
}
|
|
val langsListString = "{${langsList.sorted().joinToString(",") { "\"${it}\"" }}}"
|
|
android.defaultConfig.buildConfigField("String[]", "DETECTED_LOCALES", langsListString)
|
|
}
|
|
tasks.preBuild.dependsOn("detectAndroidLocals")
|