59 lines
1.9 KiB
Plaintext
59 lines
1.9 KiB
Plaintext
|
import com.android.build.gradle.internal.tasks.factory.dependsOn
|
||
|
|
||
|
plugins {
|
||
|
alias(libs.plugins.looker.android.library)
|
||
|
alias(libs.plugins.looker.lint)
|
||
|
}
|
||
|
|
||
|
android {
|
||
|
namespace = "com.leos.core.common"
|
||
|
defaultConfig {
|
||
|
vectorDrawables.useSupportLibrary = true
|
||
|
}
|
||
|
|
||
|
buildTypes {
|
||
|
release {
|
||
|
isMinifyEnabled = true
|
||
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||
|
}
|
||
|
create("alpha") {
|
||
|
initWith(getByName("debug"))
|
||
|
isMinifyEnabled = true
|
||
|
}
|
||
|
}
|
||
|
buildFeatures {
|
||
|
buildConfig = true
|
||
|
}
|
||
|
}
|
||
|
|
||
|
dependencies {
|
||
|
implementation(libs.kotlinx.coroutines.android)
|
||
|
implementation(libs.android.material)
|
||
|
implementation(libs.androidx.activity.ktx)
|
||
|
implementation(libs.androidx.fragment.ktx)
|
||
|
implementation(libs.androidx.core.ktx)
|
||
|
implementation(libs.androidx.lifecycle.viewModel.ktx)
|
||
|
implementation(libs.androidx.recyclerview)
|
||
|
implementation(libs.coil.kt)
|
||
|
implementation(libs.jackson.core)
|
||
|
}
|
||
|
|
||
|
// 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.joinToString(",") { "\"${it}\"" }}}"
|
||
|
android.defaultConfig.buildConfigField("String[]", "DETECTED_LOCALES", langsListString)
|
||
|
}
|
||
|
tasks.preBuild.dependsOn("detectAndroidLocals")
|