mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 00:57:02 +05:30
build: refactor for configuration cache compatibility
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
7d1b36c7fb
commit
7c2528f4a7
4 changed files with 47 additions and 28 deletions
|
@ -1,5 +1,3 @@
|
||||||
import java.util.Properties
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
|
@ -10,10 +8,7 @@ plugins {
|
||||||
`core-library-desugaring`
|
`core-library-desugaring`
|
||||||
}
|
}
|
||||||
|
|
||||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
adbOptions.installOptions("--user 0")
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "dev.msfjarvis.lobsters"
|
applicationId = "dev.msfjarvis.lobsters"
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
|
@ -24,35 +19,12 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
named("release") {
|
|
||||||
isMinifyEnabled = true
|
|
||||||
setProguardFiles(listOf("proguard-android-optimize.txt", "proguard-rules.pro"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildFeatures.compose = true
|
buildFeatures.compose = true
|
||||||
|
|
||||||
composeOptions {
|
composeOptions {
|
||||||
kotlinCompilerVersion = "1.4.21"
|
kotlinCompilerVersion = "1.4.21"
|
||||||
kotlinCompilerExtensionVersion = Dependencies.COMPOSE_VERSION
|
kotlinCompilerExtensionVersion = Dependencies.COMPOSE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
val keystoreProperties = Properties()
|
|
||||||
keystoreProperties.load(keystorePropertiesFile.inputStream())
|
|
||||||
signingConfigs {
|
|
||||||
register("release") {
|
|
||||||
keyAlias = keystoreProperties["keyAlias"] as String
|
|
||||||
keyPassword = keystoreProperties["keyPassword"] as String
|
|
||||||
storeFile = rootProject.file(keystoreProperties["storeFile"] as String)
|
|
||||||
storePassword = keystoreProperties["storePassword"] as String
|
|
||||||
}
|
|
||||||
}
|
|
||||||
listOf("release", "debug").map {
|
|
||||||
buildTypes.getByName(it).signingConfig = signingConfigs.getByName(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -59,6 +59,7 @@ internal fun Project.configureForAllProjects() {
|
||||||
*/
|
*/
|
||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
internal fun BaseAppModuleExtension.configureAndroidApplicationOptions(project: Project) {
|
internal fun BaseAppModuleExtension.configureAndroidApplicationOptions(project: Project) {
|
||||||
|
val minifySwitch = project.providers.environmentVariable("DISABLE_MINIFY").forUseAtConfigurationTime()
|
||||||
project.tasks.withType<KotlinCompile> {
|
project.tasks.withType<KotlinCompile> {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs = freeCompilerArgs + listOf(
|
freeCompilerArgs = freeCompilerArgs + listOf(
|
||||||
|
@ -68,6 +69,17 @@ internal fun BaseAppModuleExtension.configureAndroidApplicationOptions(project:
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
adbOptions.installOptions("--user 0")
|
||||||
|
buildTypes {
|
||||||
|
named("release") {
|
||||||
|
isMinifyEnabled = !minifySwitch.isPresent
|
||||||
|
setProguardFiles(listOf("proguard-android-optimize.txt", "proguard-rules.pro"))
|
||||||
|
}
|
||||||
|
named("debug") {
|
||||||
|
versionNameSuffix = "-debug"
|
||||||
|
isMinifyEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,6 +39,7 @@ class LobstersPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
is AppPlugin -> {
|
is AppPlugin -> {
|
||||||
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
|
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
|
||||||
|
project.extensions.getByType<BaseAppModuleExtension>().configureBuildSigning(project)
|
||||||
project.extensions.getByType<BaseAppModuleExtension>().configureAndroidApplicationOptions(project)
|
project.extensions.getByType<BaseAppModuleExtension>().configureAndroidApplicationOptions(project)
|
||||||
}
|
}
|
||||||
is Kapt3GradleSubplugin -> {
|
is Kapt3GradleSubplugin -> {
|
||||||
|
|
34
buildSrc/src/main/java/SigningConfig.kt
Normal file
34
buildSrc/src/main/java/SigningConfig.kt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
||||||
|
import java.util.Properties
|
||||||
|
import org.gradle.api.Project
|
||||||
|
|
||||||
|
private const val KEYSTORE_CONFIG_PATH = "keystore.properties"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure signing for all build types.
|
||||||
|
*/
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
internal fun BaseAppModuleExtension.configureBuildSigning(project: Project) {
|
||||||
|
with(project) {
|
||||||
|
val keystoreConfigFile = rootProject.layout.projectDirectory.file(KEYSTORE_CONFIG_PATH)
|
||||||
|
if (!keystoreConfigFile.asFile.exists()) return
|
||||||
|
val contents = providers.fileContents(keystoreConfigFile).asText.forUseAtConfigurationTime()
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
keystoreProperties.load(contents.get().byteInputStream())
|
||||||
|
signingConfigs {
|
||||||
|
register("release") {
|
||||||
|
keyAlias = keystoreProperties["keyAlias"] as String
|
||||||
|
keyPassword = keystoreProperties["keyPassword"] as String
|
||||||
|
storeFile = rootProject.file(keystoreProperties["storeFile"] as String)
|
||||||
|
storePassword = keystoreProperties["storePassword"] as String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val signingConfig = signingConfigs.getByName("release")
|
||||||
|
buildTypes.all { setSigningConfig(signingConfig) }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue