Skip to content

Commit

Permalink
Chore: minor gradle changes (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr328 authored May 3, 2022
1 parent ac5dae9 commit 930d9a4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 59 deletions.
6 changes: 0 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ plugins {
id("com.android.application")
}

androidComponents {
onVariants {
extra["apk${it.name}"] = it.artifacts.get(SingleArtifact.APK)
}
}

dependencies {
compileOnly(project(":hideapi"))

Expand Down
95 changes: 43 additions & 52 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import java.io.FileNotFoundException
import java.util.*

plugins {
val agp = "7.1.2"
val zygote = "2.6"
val refine = "3.1.0"
val refine = "3.1.1"

id("com.android.application") version agp apply false
id("com.android.library") version agp apply false
Expand All @@ -14,67 +14,58 @@ plugins {
}

subprojects {
val configureBaseExtension: BaseExtension.(isApp: Boolean) -> Unit = { isApp: Boolean ->
compileSdkVersion(31)
plugins.withId("com.android.base") {
extensions.configure<BaseExtension> {
val isApp = this is AppExtension

defaultConfig {
if (isApp) {
applicationId = "com.github.kr328.clipboard"
}
println("Configure $name: isApp = $isApp")

minSdk = 29
targetSdk = 31
compileSdkVersion(31)

versionName = "v23"
versionCode = 23
defaultConfig {
if (isApp) {
applicationId = "com.github.kr328.clipboard"
}

if (!isApp) {
consumerProguardFiles("consumer-rules.pro")
}
}
minSdk = 29
targetSdk = 31

signingConfigs {
val file = rootProject.file("signing.properties")
if (!file.exists()) {
throw GradleScriptException(
"signing.properties required",
FileNotFoundException("signing.properties not found")
)
}
versionName = "v23"
versionCode = 23

create("release") {
val prop = Properties().apply {
file.reader().use(this::load)
if (!isApp) {
consumerProguardFiles("consumer-rules.pro")
}

storeFile = rootProject.file(prop.getProperty("keystore.path"))
storePassword = prop.getProperty("keystore.password")
keyAlias = prop.getProperty("key.alias")
keyPassword = prop.getProperty("key.password")
}
}

buildTypes {
named("release") {
isMinifyEnabled = isApp
isShrinkResources = isApp
signingConfig = signingConfigs.getByName("release")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
if (isApp) {
signingConfigs {
create("release") {
val prop = Properties().apply {
rootProject.file("signing.properties").reader().use(this::load)
}

storeFile = rootProject.file(prop.getProperty("keystore.path"))
storePassword = prop.getProperty("keystore.password")
keyAlias = prop.getProperty("key.alias")
keyPassword = prop.getProperty("key.password")
}
}
}
}
}

plugins.withId("com.android.application") {
extensions.configure<BaseExtension> {
configureBaseExtension(true)
}
}
plugins.withId("com.android.library") {
extensions.configure<BaseExtension> {
configureBaseExtension(false)
buildTypes {
named("release") {
isMinifyEnabled = isApp
isShrinkResources = isApp
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
if (isApp) {
signingConfig = signingConfigs.getByName("release")
}
}
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion module/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ dependencies {

implementation(libs.refine.runtime)
implementation(libs.magic.library)
}
}

evaluationDependsOn(":app")

0 comments on commit 930d9a4

Please sign in to comment.