Skip to content

Commit eaf0a54

Browse files
authored
build-logic refactoring. (#301)
- multi-project build - move convention plugins to `:kstreamlined-gradle-plugin` project - add new CI job for running `build-logic` checks
1 parent 876d3ae commit eaf0a54

30 files changed

+99
-77
lines changed

.github/actions/cache-build-logic/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ runs:
88
uses: actions/cache@v4
99
with:
1010
path: build-logic/build
11-
key: build-logic-${{ hashFiles('build-logic/src/**', 'build-logic/build.gradle.kts','build-logic/settings.gradle.kts') }}
11+
key: build-logic-${{ hashFiles('build-logic/**/src/**', 'build-logic/**/build.gradle.kts','build-logic/settings.gradle.kts') }}

.github/workflows/android.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,33 @@ jobs:
151151
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
152152

153153
- name: Run detekt, ktlint and Android Lint
154-
run: |
155-
./gradlew detekt lint
156-
./gradlew -p build-logic detekt
154+
run: ./gradlew detekt lint
155+
156+
build-logic-checks:
157+
name: build-logic checks
158+
runs-on: ubuntu-latest
159+
timeout-minutes: 15
160+
161+
steps:
162+
- uses: actions/checkout@v4
163+
164+
- uses: actions/setup-java@v4
165+
with:
166+
distribution: 'zulu'
167+
java-version: '24'
168+
169+
- uses: kaeawc/setup-tcmalloc@v0.0.1
170+
171+
- uses: gradle/actions/setup-gradle@v4
172+
with:
173+
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
174+
175+
- name: Run build-logic checks
176+
run: ./gradlew -p build-logic check
157177

158178
deploy-dev-build:
159179
name: Upload dev build
160-
needs: [ assemble, unit-tests, screenshot-tests, static-analysis ]
180+
needs: [ assemble, unit-tests, screenshot-tests, static-analysis, build-logic-checks ]
161181
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/android')
162182
runs-on: ubuntu-latest
163183
timeout-minutes: 15
@@ -204,7 +224,7 @@ jobs:
204224
205225
deploy-release-build:
206226
name: Publish release build to Play Store (internal test track)
207-
needs: [ assemble, unit-tests, screenshot-tests, static-analysis ]
227+
needs: [ assemble, unit-tests, screenshot-tests, static-analysis, build-logic-checks ]
208228
if: startsWith(github.ref, 'refs/tags/android')
209229
runs-on: ubuntu-latest
210230
timeout-minutes: 15

android/app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import com.google.firebase.appdistribution.gradle.tasks.UploadDistributionTask
22
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
33
import com.google.firebase.perf.plugin.FirebasePerfExtension
44
import com.google.gms.googleservices.GoogleServicesPlugin
5-
import io.github.reactivecircus.kstreamlined.buildlogic.FlavorDimensions
6-
import io.github.reactivecircus.kstreamlined.buildlogic.ProductFlavors
5+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.FlavorDimensions
6+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.ProductFlavors
77
import java.time.Instant
88

99
plugins {

android/benchmark/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@file:Suppress("UnstableApiUsage")
22

33
import com.android.build.api.dsl.ManagedVirtualDevice
4-
import io.github.reactivecircus.kstreamlined.buildlogic.FlavorDimensions
5-
import io.github.reactivecircus.kstreamlined.buildlogic.ProductFlavors
4+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.FlavorDimensions
5+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.ProductFlavors
66

77
plugins {
88
id("kstreamlined.android.test")

build-logic/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

build-logic/build.gradle.kts renamed to build-logic/kstreamlined-gradle-plugin/build.gradle.kts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tasks.withType<JavaCompile>().configureEach {
3131

3232
detekt {
3333
source.from(files("src/"))
34-
config.from(files("../detekt.yml"))
34+
config.from(files("$rootDir/../detekt.yml"))
3535
buildUponDefaultConfig = true
3636
allRules = true
3737
parallel = true
@@ -81,51 +81,51 @@ gradlePlugin {
8181
plugins {
8282
register("root") {
8383
id = "kstreamlined.root"
84-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.RootPlugin"
84+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.RootPlugin"
8585
}
8686
register("androidApplication") {
8787
id = "kstreamlined.android.application"
88-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.AndroidApplicationConventionPlugin"
88+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.AndroidApplicationConventionPlugin"
8989
}
9090
register("androidLibrary") {
9191
id = "kstreamlined.android.library"
92-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.AndroidLibraryConventionPlugin"
92+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.AndroidLibraryConventionPlugin"
9393
}
9494
register("androidTest") {
9595
id = "kstreamlined.android.test"
96-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.AndroidTestConventionPlugin"
96+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.AndroidTestConventionPlugin"
9797
}
9898
register("androidScreenshotTest") {
9999
id = "kstreamlined.android.screenshot-test"
100-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.AndroidScreenshotTestConventionPlugin"
100+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.AndroidScreenshotTestConventionPlugin"
101101
}
102102
register("kmpCommon") {
103103
id = "kstreamlined.kmp.common"
104-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KMPCommonConventionPlugin"
104+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.KMPCommonConventionPlugin"
105105
}
106106
register("kmpAndroidAndIos") {
107107
id = "kstreamlined.kmp.android-and-ios"
108-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KMPAndroidAndIosConventionPlugin"
108+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.KMPAndroidAndIosConventionPlugin"
109109
}
110110
register("kmpIosOnly") {
111111
id = "kstreamlined.kmp.ios-only"
112-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KMPIosOnlyConventionPlugin"
112+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.KMPIosOnlyConventionPlugin"
113113
}
114114
register("kmpTest") {
115115
id = "kstreamlined.kmp.test"
116-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KMPTestConventionPlugin"
116+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.KMPTestConventionPlugin"
117117
}
118118
register("kotlinJvm") {
119119
id = "kstreamlined.kotlin.jvm"
120-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KotlinJvmConventionPlugin"
120+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.KotlinJvmConventionPlugin"
121121
}
122122
register("compose") {
123123
id = "kstreamlined.compose"
124-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.ComposeConventionPlugin"
124+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.ComposeConventionPlugin"
125125
}
126126
register("ksp") {
127127
id = "kstreamlined.ksp"
128-
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KspConventionPlugin"
128+
implementationClass = "io.github.reactivecircus.kstreamlined.gradle.KspConventionPlugin"
129129
}
130130
}
131131
}

build-logic/src/main/kotlin/buildEnvironment.kt renamed to build-logic/kstreamlined-gradle-plugin/src/main/kotlin/buildEnvironment.kt

File renamed without changes.

build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidApplicationConventionPlugin.kt renamed to build-logic/kstreamlined-gradle-plugin/src/main/kotlin/io/github/reactivecircus/kstreamlined/gradle/AndroidApplicationConventionPlugin.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package io.github.reactivecircus.kstreamlined.buildlogic.convention
1+
package io.github.reactivecircus.kstreamlined.gradle
22

33
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
44
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
5-
import io.github.reactivecircus.kstreamlined.buildlogic.configureAndroidApplicationExtension
6-
import io.github.reactivecircus.kstreamlined.buildlogic.configureAndroidApplicationVariants
7-
import io.github.reactivecircus.kstreamlined.buildlogic.configureCommonAndroidExtension
8-
import io.github.reactivecircus.kstreamlined.buildlogic.configureDetekt
9-
import io.github.reactivecircus.kstreamlined.buildlogic.configureKotlin
10-
import io.github.reactivecircus.kstreamlined.buildlogic.configureTest
5+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureAndroidApplicationExtension
6+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureAndroidApplicationVariants
7+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureCommonAndroidExtension
8+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureDetekt
9+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureKotlin
10+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureTest
1111
import org.gradle.api.Plugin
1212
import org.gradle.api.Project
1313
import org.gradle.kotlin.dsl.configure

build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidLibraryConventionPlugin.kt renamed to build-logic/kstreamlined-gradle-plugin/src/main/kotlin/io/github/reactivecircus/kstreamlined/gradle/AndroidLibraryConventionPlugin.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package io.github.reactivecircus.kstreamlined.buildlogic.convention
1+
package io.github.reactivecircus.kstreamlined.gradle
22

33
import com.android.build.api.variant.LibraryAndroidComponentsExtension
44
import com.android.build.gradle.LibraryExtension
5-
import io.github.reactivecircus.kstreamlined.buildlogic.configureAndroidLibraryVariants
6-
import io.github.reactivecircus.kstreamlined.buildlogic.configureCommonAndroidExtension
7-
import io.github.reactivecircus.kstreamlined.buildlogic.configureDetekt
8-
import io.github.reactivecircus.kstreamlined.buildlogic.configureKotlin
9-
import io.github.reactivecircus.kstreamlined.buildlogic.configureTest
5+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureAndroidLibraryVariants
6+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureCommonAndroidExtension
7+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureDetekt
8+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureKotlin
9+
import io.github.reactivecircus.kstreamlined.gradle.buildlogic.configureTest
1010
import org.gradle.api.Plugin
1111
import org.gradle.api.Project
1212
import org.gradle.kotlin.dsl.configure

build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidScreenshotTestConventionPlugin.kt renamed to build-logic/kstreamlined-gradle-plugin/src/main/kotlin/io/github/reactivecircus/kstreamlined/gradle/AndroidScreenshotTestConventionPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.reactivecircus.kstreamlined.buildlogic.convention
1+
package io.github.reactivecircus.kstreamlined.gradle
22

33
import app.cash.paparazzi.gradle.PrepareResourcesTask
44
import com.android.build.api.dsl.LibraryExtension

0 commit comments

Comments
 (0)