Skip to content

Commit

Permalink
build: Migrate to Kotlin DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed May 1, 2024
1 parent ed4b96e commit e848397
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 137 deletions.
106 changes: 0 additions & 106 deletions app/build.gradle

This file was deleted.

111 changes: 111 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import java.util.Properties

plugins {
id("com.android.application")
id("kotlin-android")
id("org.jmailen.kotlinter") version "4.2.0" // lintKotlin, formatKotlin
id("com.getkeepsafe.dexcount") version "4.0.0" // :app:countReleaseDexMethods
}

android {
namespace = "com.cyb3rko.flashdim"
compileSdk = 34
defaultConfig {
applicationId = "com.cyb3rko.flashdim"
minSdk = 33
targetSdk = 34
versionCode = 25
versionName = "2.3.3"
resValue("string", "app_name", "FlashDim Dev")
resourceConfigurations.add("en")
signingConfig = signingConfigs.getByName("debug")
}
buildTypes {
debug {
isMinifyEnabled = false
applicationIdSuffix = ".dev"
}
release {
resValue("string", "app_name", "FlashDim")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
create("benchmark") {
initWith(getByName("release"))
matchingFallbacks.add("release")
isDebuggable = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
viewBinding = true
buildConfig = true
}
bundle {
storeArchive {
enable = false
}
}
packaging {
resources {
excludes.add("META-INF/*.version")
excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
}
}

if (project.hasProperty("sign")) {
android {
signingConfigs {
getByName("release") {
storeFile = file(System.getenv("KEYSTORE_FILE"))
storePassword = System.getenv("KEYSTORE_PASSWD")
keyAlias = System.getenv("KEYSTORE_KEY_ALIAS")
keyPassword = System.getenv("KEYSTORE_KEY_PASSWD")
}
}
}
android.buildTypes.getByName("release").signingConfig =
android.signingConfigs.getByName("release")
}

if (project.hasProperty("gplay_upload")) {
android {
signingConfigs {
getByName("upload") {
val properties = Properties()
properties.load(project.rootProject.file("local.properties").inputStream())
storeFile = file(properties.getProperty("uploadsigning.file"))
storePassword = properties.getProperty("uploadsigning.password")
keyAlias = properties.getProperty("uploadsigning.key.alias")
keyPassword = properties.getProperty("uploadsigning.key.password")
}
}
}
android.buildTypes.getByName("release").signingConfig = android.signingConfigs.getByName("upload")
}

dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.profileinstaller:profileinstaller:1.3.1")
}

configurations {
configureEach {
exclude("androidx.lifecycle", "lifecycle-viewmodel-ktx")
}
}
40 changes: 20 additions & 20 deletions benchmark/build.gradle → benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import com.android.build.api.dsl.ManagedVirtualDevice
@file:Suppress("UnstableApiUsage")

plugins {
id 'com.android.test'
id 'org.jetbrains.kotlin.android'
id("com.android.test")
id("org.jetbrains.kotlin.android")
}

android {
namespace 'com.cyb3rko.flashdim.benchmark'
compileSdk 34
namespace = "com.cyb3rko.flashdim.benchmark"
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -19,28 +19,28 @@ android {
}

defaultConfig {
minSdk 33
targetSdk 34
minSdk = 33
targetSdk = 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = "LOW-BATTERY"
}

buildTypes {
create("benchmark") {
resValue 'string', 'app_name', 'FlashDim'
resValue("string", "app_name", "FlashDim")
//minifyEnabled true
//shrinkResources true
proguardFiles 'benchmark-rules.pro'
signingConfig signingConfigs.debug
matchingFallbacks = ['release']
proguardFiles("benchmark-rules.pro")
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks.add("release")
}
}

testOptions {
managedDevices {
devices {
pixel3Api34(ManagedVirtualDevice) {
localDevices {
create("pixel3Api34") {
device = "Pixel 3"
apiLevel = 34
systemImageSource = "aosp"
Expand All @@ -54,14 +54,14 @@ android {
}

dependencies {
implementation 'androidx.test.ext:junit:1.1.5'
implementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
implementation 'androidx.benchmark:benchmark-macro-junit4:1.2.3'
implementation("androidx.test.ext:junit:1.1.5")
implementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("androidx.test.uiautomator:uiautomator:2.2.0")
implementation("androidx.benchmark:benchmark-macro-junit4:1.2.3")
}

androidComponents {
beforeVariants(selector().all()) {
enable = buildType == "benchmark"
it.enable = it.buildType == "benchmark"
}
}
}
9 changes: 0 additions & 9 deletions build.gradle

This file was deleted.

5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plugins {
id("com.android.application") version "8.3.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.23" apply false
id("com.android.test") version "8.3.0" apply false
}
6 changes: 4 additions & 2 deletions settings.gradle → settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UnstableApiUsage")

pluginManagement {
repositories {
gradlePluginPortal()
Expand All @@ -12,5 +14,5 @@ dependencyResolutionManagement {
}
}
rootProject.name = "FlashDim"
include ':app'
include ':benchmark'
include(":app")
include(":benchmark")

0 comments on commit e848397

Please sign in to comment.