Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save milis92/4ed5b9413f1ef5ec0db476955a9aaffa to your computer and use it in GitHub Desktop.

Select an option

Save milis92/4ed5b9413f1ef5ec0db476955a9aaffa to your computer and use it in GitHub Desktop.
//Put this into buildSrc/src/android-applicaiton-convention.gradle.kts
@file:Suppress("UnstableApiUsage")
import com.android.build.api.dsl.ApplicationDefaultConfig
plugins {
id("com.android.application")
id("org.gradle.android.cache-fix")
kotlin("android")
kotlin("kapt")
id("dagger.hilt.android.plugin")
}
android {
//We don't have type safety here because https://github.com/gradle/gradle/issues/15383
//For actual configuration of these version see configuration/buildLibs.versions.toml
val buildCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
compileSdk = buildCatalog.getVersion("android_compile_sdk").toInt()
defaultConfig {
minSdk = buildCatalog.getVersion("android_min_sdk").toInt()
targetSdk = buildCatalog.getVersion("android_target_sdk").toInt()
versionCode = extra.get("VERSION_CODE") as Int // This will be autoresolved from playstore
versionName = extra.get("VERSION_NAME") as String
buildConfigInteger("VERSION_CODE", versionCode!!)
buildConfigString("VERSION_NAME", versionName!!)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
val shardsNo = System.getenv("NUM_SHARDS")
val shardIndex = System.getenv("SHARD_INDEX")
//Local sharding
if (shardsNo != null) {
testInstrumentationRunnerArguments["numShards"] = shardsNo
}
//Remote sharding
if (shardIndex != null) {
testInstrumentationRunnerArguments["shardIndex"] = shardIndex
}
//https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
ndkVersion = "23.2.8568313"
packagingOptions {
jniLibs.pickFirsts.addAll(
listOf(
"lib/x86/libc++_shared.so",
"lib/x86_64/libjsc.so",
"lib/arm64-v8a/libjsc.so",
"lib/arm64-v8a/libc++_shared.so",
"lib/x86_64/libc++_shared.so",
"lib/armeabi-v7a/libc++_shared.so"
)
)
resources.excludes.add("lib/armeabi/**")
resources.excludes.add("META-INF/**")
}
}
dataBinding {
isEnabled = false
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
buildTypes {
named("debug") {
isDebuggable = true
isMinifyEnabled = false
isShrinkResources = false
extra["alwaysUpdateBuildId"] = false
}
named("release") {
isDebuggable = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
flavorDimensions.add("configuration")
productFlavors {
register(stagingFlavor) {
dimension = "configuration"
isDefault = true
resourceConfigurations.add("en")
}
register(productionFlavor) {
dimension = "configuration"
}
}
}
plugins {
`android-applicaiton-convention`
}
android {
}
dependencies {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment