Skip to content

Commit

Permalink
Merge pull request #51 from stslex/ci/refactor
Browse files Browse the repository at this point in the history
CI refactor
  • Loading branch information
stslex authored Sep 17, 2023
2 parents 60a9a26 + 80b3b7d commit 5752235
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 72 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
.externalNativeBuild
.cxx
local.properties
play_config.json
keystore.jks
keystore.properties
play_config.*
keystore.*
58 changes: 0 additions & 58 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,45 +1,8 @@
import java.io.FileInputStream
import java.io.InputStreamReader
import java.util.Properties

plugins {
id("csplashscreen.android.application")
id("csplashscreen.android.application.compose")
}

android {
signingConfigs {
val keystoreProperties = gradleKeystoreProperties(project.rootProject.projectDir)
create("release") {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = getFile(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
with(get("debug")) {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = getFile(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
isDebuggable = false
}
getByName("debug") {
signingConfig = signingConfigs.getByName("debug")
isDebuggable = true
}
}
}

dependencies {
implementation(project(":core:core"))
implementation(project(":core:ui"))
Expand All @@ -55,25 +18,4 @@ dependencies {
implementation(project(":feature:photo-detail"))
implementation(project(":feature:search"))
implementation(project(":feature:favourite"))
}

fun getFile(path: String): File {
val file = File(project.rootProject.projectDir, path)
if (file.isFile) {
return file
} else {
throw IllegalStateException("${file.name} is inValid")
}
}

fun gradleKeystoreProperties(projectRootDir: File): Properties {
val properties = Properties()
val localProperties = File(projectRootDir, "keystore.properties")

if (localProperties.isFile) {
InputStreamReader(FileInputStream(localProperties), Charsets.UTF_8).use { reader ->
properties.load(reader)
}
}
return properties
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import st.slex.csplashscreen.configureKotlinAndroid
import java.io.File
import java.io.FileInputStream
import java.io.InputStreamReader
import java.util.Properties

class AndroidApplicationConventionPlugin : Plugin<Project> {

Expand All @@ -21,19 +25,69 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
defaultConfig.apply {
applicationId = "st.slex.csplashscreen"
targetSdk = 34
versionName = "1.6"
versionCode = 6
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
versionName = AppVersions.versionName
versionCode = AppVersions.versionCode

configureSigning(target)
}
}
}
}
}

fun ApplicationExtension.configureSigning(
project: Project
) {
signingConfigs {
val keystoreProperties = gradleKeystoreProperties(project.rootProject.projectDir)
create("release") {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = project.getFile(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
with(getByName("debug")) {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = project.getFile(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
isDebuggable = false
}
getByName("debug") {
signingConfig = signingConfigs.getByName("debug")
isDebuggable = true
}
}
}


fun Project.getFile(path: String): File {
val file = File(project.rootProject.projectDir, path)
if (file.isFile) {
return file
} else {
throw IllegalStateException("${file.name} is inValid")
}
}

fun gradleKeystoreProperties(projectRootDir: File): Properties {
val properties = Properties()
val localProperties = File(projectRootDir, "keystore.properties")

if (localProperties.isFile) {
InputStreamReader(FileInputStream(localProperties), Charsets.UTF_8).use { reader ->
properties.load(reader)
}
}
return properties
}
4 changes: 4 additions & 0 deletions build-logic/dependencies/src/main/kotlin/AppVersions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object AppVersions {
const val versionName = "1.61"
const val versionCode = 7
}

0 comments on commit 5752235

Please sign in to comment.