general: moved more configs to convention plugin
- Commit
06ffcbb257e8fc30f76795f5b3b079dd7e0b5d1b- Author
- Vayun Mathur <[email protected]>
- When
- 2026-03-20 10:26 UTC (8 months ago)
- Parents
8196696
Diff
build-logic/build.gradle.kts
diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.ktsindex 690daad926..5721eb8605 100644--- a/build-logic/build.gradle.kts+++ b/build-logic/build.gradle.kts@@ -2,11 +2,6 @@ plugins { `kotlin-dsl` } -repositories {- google()- mavenCentral()-}- dependencies { implementation("com.android.tools.build:gradle:9.1.0") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.20")
build-logic/settings.gradle.kts
diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.ktsindex 3719235998..97b4980846 100644--- a/build-logic/settings.gradle.kts+++ b/build-logic/settings.gradle.kts@@ -1,3 +1,10 @@+pluginManagement {+ repositories {+ google()+ mavenCentral()+ gradlePluginPortal()+ }+} dependencyResolutionManagement { versionCatalogs { create("libs") {@@ -5,4 +12,9 @@ dependencyResolutionManagement { from(files("../gradle/libs.versions.toml")) } }+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)+ repositories {+ google()+ mavenCentral()+ } }\ No newline at end of file
build-logic/src/main/kotlin/common-conventions-app.gradle.kts
diff --git a/build-logic/src/main/kotlin/common-conventions-app.gradle.kts b/build-logic/src/main/kotlin/common-conventions-app.gradle.ktsindex f371b07725..eb3c72a378 100644--- a/build-logic/src/main/kotlin/common-conventions-app.gradle.kts+++ b/build-logic/src/main/kotlin/common-conventions-app.gradle.kts@@ -1,10 +1,81 @@-// build-logic/src/main/kotlin/common-conventions.gradle.kts plugins { id("com.android.application") } val libs = the<org.gradle.accessors.dm.LibrariesForLibs>() +fun readVersionInfo(): Pair<Int, String> {+ val versionFile = File(rootDir, "version.txt")++ return if (versionFile.exists()) {+ val lines = versionFile.readLines()+ if (lines.size >= 2) {+ val code = lines[0].trim().toIntOrNull() ?: 1+ val name = lines[1].trim()+ code to name+ } else throw IllegalStateException("Invalid version.txt format")+ } else throw IllegalStateException("version.txt not found")+}++val proguardFile+ get() = File(rootDir, "proguard-rules.pro")++val (appVersionCode, appVersionName) = readVersionInfo()++configure<com.android.build.api.dsl.ApplicationExtension> {+ dependenciesInfo {+ includeInApk = false+ includeInBundle = false+ }+ buildFeatures {+ compose = true+ }++ namespace = "com.vayunmathur${path.replace(":", ".")}"+ compileSdk {+ version = release(36)+ }++ ndkVersion = "29.0.14206865"++ defaultConfig {+ minSdk = 31+ versionCode = appVersionCode+ versionName = appVersionName+ }++ signingConfigs {+ val isSigningConfigAvailable = project.hasProperty("RELEASE_STORE_FILE")++ if (isSigningConfigAvailable) {+ create("release") {+ storeFile = file(project.property("RELEASE_STORE_FILE") as String)+ storePassword = project.property("RELEASE_STORE_PASSWORD") as String+ keyAlias = project.property("RELEASE_KEY_ALIAS") as String+ keyPassword = project.property("RELEASE_KEY_PASSWORD") as String++ enableV1Signing = true+ enableV2Signing = true+ enableV3Signing = true+ enableV4Signing = false+ }+ }+ }++ buildTypes {+ release {+ isMinifyEnabled = true+ isShrinkResources = true+ if (signingConfigs.findByName("release") != null) {+ signingConfig = signingConfigs.getByName("release")+ }+ proguardFiles(+ getDefaultProguardFile("proguard-android-optimize.txt"), proguardFile.absolutePath,+ )+ }+ }+}+ dependencies { // AndroidX Core & Lifecycle implementation(libs.okio)@@ -24,4 +95,6 @@ dependencies { // Kotlin Serialization implementation(libs.kotlinx.serialization.json)++ implementation(project(":library")) }
build-logic/src/main/kotlin/common-conventions-library.gradle.kts
diff --git a/build-logic/src/main/kotlin/common-conventions-library.gradle.kts b/build-logic/src/main/kotlin/common-conventions-library.gradle.ktsindex 27af1e2816..6a8d160bba 100644--- a/build-logic/src/main/kotlin/common-conventions-library.gradle.kts+++ b/build-logic/src/main/kotlin/common-conventions-library.gradle.kts@@ -1,10 +1,24 @@-// build-logic/src/main/kotlin/common-conventions.gradle.kts plugins { id("com.android.library") } val libs = the<org.gradle.accessors.dm.LibrariesForLibs>() +configure<com.android.build.api.dsl.LibraryExtension> {+ buildFeatures {+ compose = true+ }++ namespace = "com.vayunmathur.$name"+ compileSdk {+ version = release(36)+ }++ defaultConfig {+ minSdk = 31+ }+}+ dependencies { // AndroidX Core & Lifecycle implementation(libs.okio)
build.gradle.kts
diff --git a/build.gradle.kts b/build.gradle.ktsindex 5f2d176c00..5626aaf220 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -7,114 +7,16 @@ plugins { alias(libs.plugins.ksp) apply false } -fun readVersionInfo(): Pair<Int, String> {- val versionFile = File(projectDir, "version.txt")-- return if (versionFile.exists()) {- val lines = versionFile.readLines()- if (lines.size >= 2) {- val code = lines[0].trim().toIntOrNull() ?: 1- val name = lines[1].trim()- code to name- } else throw IllegalStateException("Invalid version.txt format")- } else throw IllegalStateException("version.txt not found")-}--val proguardFile = File(projectDir, "proguard-rules.pro")--val (appVersionCode, appVersionName) = readVersionInfo()- subprojects { if(name == "app") return@subprojects - // Apply the common conventions plugin to all subprojects- if(name != "library") {- //apply(plugin = "common-conventions-app")- apply(plugin = "com.android.application") apply(plugin = "org.jetbrains.kotlin.plugin.compose") apply(plugin = "org.jetbrains.kotlin.plugin.serialization") apply(plugin = "com.google.devtools.ksp")-- configure<com.android.build.api.dsl.ApplicationExtension> {- dependenciesInfo {- includeInApk = false- includeInBundle = false- }- buildFeatures {- compose = true- }--- namespace = "com.vayunmathur${path.replace(":", ".")}"- compileSdk {- version = release(36)- }-- ndkVersion = "29.0.14206865"-- defaultConfig {- minSdk = 31- versionCode = appVersionCode- versionName = appVersionName- }-- signingConfigs {- val isSigningConfigAvailable = project.hasProperty("RELEASE_STORE_FILE")-- if (isSigningConfigAvailable) {- create("release") {- storeFile = file(project.property("RELEASE_STORE_FILE") as String)- storePassword = project.property("RELEASE_STORE_PASSWORD") as String- keyAlias = project.property("RELEASE_KEY_ALIAS") as String- keyPassword = project.property("RELEASE_KEY_PASSWORD") as String-- enableV1Signing = true- enableV2Signing = true- enableV3Signing = true- enableV4Signing = false- }- }- }-- buildTypes {- release {- isMinifyEnabled = true- isShrinkResources = true- if (signingConfigs.findByName("release") != null) {- signingConfig = signingConfigs.getByName("release")- }- proguardFiles(- getDefaultProguardFile("proguard-android-optimize.txt"), proguardFile.absolutePath,- )- }- }- }-- dependencies {- "implementation"(project(":library"))- } } else {- //apply(plugin = "common-conventions-library")- apply(plugin = "com.android.library") apply(plugin = "org.jetbrains.kotlin.plugin.compose") apply(plugin = "org.jetbrains.kotlin.plugin.serialization")-- configure<com.android.build.api.dsl.LibraryExtension> {- buildFeatures {- compose = true- }-- namespace = "com.vayunmathur.$name"- compileSdk {- version = release(36)- }-- defaultConfig {- minSdk = 31- testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"- }- } } pluginManager.withPlugin("com.google.devtools.ksp") {