Skip to content

Commit 55f585d

Browse files
committed
Refactor build system for instrumentation, use version catalog etc
1 parent 83b5501 commit 55f585d

16 files changed

Lines changed: 533 additions & 641 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[versions]
2+
androidxActivity = "1.10.1"
3+
androidxMultidex = "2.0.1"
4+
androidxTestAnnotation = "1.0.1"
5+
androidxTestCore = "1.6.1"
6+
androidxTestMonitor = "1.7.2"
7+
androidxTestRunner = "1.6.2"
8+
apiguardian = "1.1.2"
9+
compose = "1.10.0"
10+
dokka = "2.0.0"
11+
espresso = "3.6.1"
12+
instantTaskExecutorExtension = "1.0.0"
13+
junit4 = "4.13.2"
14+
#noinspection NewerVersionAvailable
15+
junit5 = "5.14.1"
16+
junit6 = "6.0.1"
17+
konftoml = "1.1.2"
18+
korte = "2.4.12"
19+
kotlin = "2.3.0"
20+
kotlinBinaryCompValidator = "0.17.0"
21+
kotlinCoroutines = "1.10.2"
22+
mockitoCore = "5.16.0"
23+
mockitoKotlin = "5.4.0"
24+
nexusPublish = "2.0.0"
25+
robolectric = "4.14.1"
26+
shadow = "8.1.1"
27+
truth = "1.4.4"
28+
29+
[plugins]
30+
# Intentionally missing version declaration, as different versions are applied depending on context
31+
android-app = { id = "com.android.application" }
32+
android-library = { id = "com.android.library" }
33+
android-junit = { id = "de.mannodermaus.android-junit5" }
34+
35+
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
36+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
37+
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
38+
kotlin-binarycompvalidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinBinaryCompValidator" }
39+
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
40+
publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" }
41+
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
42+
43+
[libraries]
44+
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidxActivity" }
45+
androidx-multidex = { module = "androidx.multidex:multidex", version.ref = "androidxMultidex" }
46+
androidx-test-annotation = { module = "androidx.test:annotation", version.ref = "androidxTestAnnotation" }
47+
androidx-test-core = { module = "androidx.test:core", version.ref = "androidxTestCore" }
48+
androidx-test-monitor = { module = "androidx.test:monitor", version.ref = "androidxTestMonitor" }
49+
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" }
50+
apiguardian = { module = "org.apiguardian:apiguardian-api", version.ref = "apiguardian" }
51+
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
52+
compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
53+
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
54+
compose-uitooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
55+
compose-test-core = { module = "androidx.compose.ui:ui-test", version.ref = "compose" }
56+
compose-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
57+
compose-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }
58+
espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
59+
instanttaskexecutor-extension = { module = "io.github.neboskreb:instant-task-executor-extension", version.ref = "instantTaskExecutorExtension" }
60+
#noinspection SimilarGradleDependency
61+
junit-framework-bom5 = { module = "org.junit:junit-bom", version.ref = "junit5" }
62+
#noinspection SimilarGradleDependency
63+
junit-framework-bom6 = { module = "org.junit:junit-bom", version.ref = "junit6" }
64+
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" }
65+
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }
66+
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params" }
67+
junit-platform-commons = { module = "org.junit.platform:junit-platform-commons" }
68+
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
69+
junit-platform-runner = { module = "org.junit.platform:junit-platform-runner" }
70+
junit-vintage-api = { module = "junit:junit", version.ref = "junit4" }
71+
junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine" }
72+
konftoml = { module = "com.uchuhimo:konf-toml", version.ref = "konftoml" }
73+
korte = { module = "com.soywiz.korlibs.korte:korte", version.ref = "korte" }
74+
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinCoroutines" }
75+
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
76+
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockitoCore" }
77+
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlin" }
78+
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
79+
truth-core = { module = "com.google.truth:truth", version.ref = "truth" }
80+
truth-extensions = { module = "com.google.truth.extensions:truth-java8-extension", version.ref = "truth" }
Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
1-
@file:Suppress("ClassName")
2-
3-
object libs {
4-
object versions {
5-
const val kotlin = "2.3.0"
6-
const val junitJupiter = "5.14.0"
7-
const val junitVintage = "5.14.0"
8-
const val junitPlatform = "1.14.0"
9-
10-
const val compose = "1.10.0"
11-
const val androidXMultidex = "2.0.1"
12-
const val androidXTestAnnotation = "1.0.1"
13-
const val androidXTestCore = "1.6.1"
14-
const val androidXTestMonitor = "1.7.2"
15-
const val androidXTestRunner = "1.6.2"
16-
17-
const val activityCompose = "1.10.1"
18-
const val apiGuardian = "1.1.2"
19-
const val coroutines = "1.10.2"
20-
const val dokka = "2.0.0"
21-
const val espresso = "3.6.1"
22-
const val junit4 = "4.13.2"
23-
const val konfToml = "1.1.2"
24-
const val kotlinxBinaryCompatibilityValidator = "0.17.0"
25-
const val nexusPublish = "2.0.0"
26-
const val korte = "2.4.12"
27-
const val mockitoCore = "5.16.0"
28-
const val mockitoKotlin = "5.4.0"
29-
const val robolectric = "4.14.1"
30-
const val shadow = "8.1.1"
31-
const val truth = "1.4.4"
32-
}
33-
34-
object plugins {
35-
fun android(version: SupportedAgp) = "com.android.tools.build:gradle:${version.version}"
36-
const val composeCompiler = "org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:${versions.kotlin}"
37-
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin}"
38-
const val shadow = "com.github.johnrengelman:shadow:${libs.versions.shadow}"
39-
const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${libs.versions.dokka}"
40-
}
41-
42-
// Libraries
43-
val androidTools = run {
44-
// The version of this library is linked to AGP
45-
// (essentially: "AGP + 23.0.0")
46-
val agpVersionParts = SupportedAgp.oldest.version.split('.')
47-
val toolsVersion = "${23 + agpVersionParts.first().toInt()}." + agpVersionParts.drop(1).joinToString(".")
48-
"com.android.tools:common:$toolsVersion"
49-
}
50-
51-
const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"
52-
const val kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}"
53-
54-
const val junitJupiterApi = "org.junit.jupiter:junit-jupiter-api:${versions.junitJupiter}"
55-
const val junitJupiterParams = "org.junit.jupiter:junit-jupiter-params:${versions.junitJupiter}"
56-
const val junitJupiterEngine = "org.junit.jupiter:junit-jupiter-engine:${versions.junitJupiter}"
57-
const val junitVintageEngine = "org.junit.vintage:junit-vintage-engine:${versions.junitVintage}"
58-
const val junitPlatformCommons = "org.junit.platform:junit-platform-commons:${versions.junitPlatform}"
59-
const val junitPlatformLauncher = "org.junit.platform:junit-platform-launcher:${versions.junitPlatform}"
60-
const val junitPlatformRunner = "org.junit.platform:junit-platform-runner:${versions.junitPlatform}"
61-
const val apiguardianApi = "org.apiguardian:apiguardian-api:${versions.apiGuardian}"
62-
63-
const val composeUi = "androidx.compose.ui:ui:${versions.compose}"
64-
const val composeUiTooling = "androidx.compose.ui:ui-tooling:${versions.compose}"
65-
const val composeFoundation = "androidx.compose.foundation:foundation:${versions.compose}"
66-
const val composeMaterial = "androidx.compose.material:material:${versions.compose}"
67-
const val composeActivity = "androidx.activity:activity-compose:${versions.activityCompose}"
68-
69-
// Testing
70-
const val junit4 = "junit:junit:${versions.junit4}"
71-
const val korte = "com.soywiz.korlibs.korte:korte:${versions.korte}"
72-
const val konfToml = "com.uchuhimo:konf-toml:${versions.konfToml}"
73-
const val mockitoCore = "org.mockito:mockito-core:${versions.mockitoCore}"
74-
const val mockitoKotlin = "org.mockito.kotlin:mockito-kotlin:${versions.mockitoKotlin}"
75-
const val truth = "com.google.truth:truth:${versions.truth}"
76-
const val truthJava8Extensions = "com.google.truth.extensions:truth-java8-extension:${versions.truth}"
77-
const val robolectric = "org.robolectric:robolectric:${versions.robolectric}"
78-
79-
const val androidXMultidex = "androidx.multidex:multidex:${versions.androidXMultidex}"
80-
const val androidXTestAnnotation = "androidx.test:annotation:${versions.androidXTestAnnotation}"
81-
const val androidXTestCore = "androidx.test:core:${versions.androidXTestCore}"
82-
const val androidXTestMonitor = "androidx.test:monitor:${versions.androidXTestMonitor}"
83-
const val androidXTestRunner = "androidx.test:runner:${versions.androidXTestRunner}"
84-
const val espressoCore = "androidx.test.espresso:espresso-core:${versions.espresso}"
85-
86-
const val composeUiTest = "androidx.compose.ui:ui-test:${versions.compose}"
87-
const val composeUiTestJUnit4 = "androidx.compose.ui:ui-test-junit4:${versions.compose}"
88-
const val composeUiTestManifest = "androidx.compose.ui:ui-test-manifest:${versions.compose}"
89-
90-
// Documentation
91-
// For the latest version refer to GitHub repo neboskreb/instant-task-executor-extension
92-
const val instantTaskExecutorExtension = "io.github.neboskreb:instant-task-executor-extension:1.0.0"
93-
}
1+
//@file:Suppress("ClassName")
2+
//
3+
//object libs2 {
4+
// object versions {
5+
// const val kotlin = "2.3.0"
6+
// const val junitJupiter = "5.14.0"
7+
// const val junitVintage = "5.14.0"
8+
// const val junitPlatform = "1.14.0"
9+
//
10+
// const val compose = "1.10.0"
11+
// const val androidXMultidex = "2.0.1"
12+
// const val androidXTestAnnotation = "1.0.1"
13+
// const val androidXTestCore = "1.6.1"
14+
// const val androidXTestMonitor = "1.7.2"
15+
// const val androidXTestRunner = "1.6.2"
16+
//
17+
// const val activityCompose = "1.10.1"
18+
// const val apiGuardian = "1.1.2"
19+
// const val coroutines = "1.10.2"
20+
// const val dokka = "2.0.0"
21+
// const val espresso = "3.6.1"
22+
// const val junit4 = "4.13.2"
23+
// const val konfToml = "1.1.2"
24+
// const val kotlinxBinaryCompatibilityValidator = "0.17.0"
25+
// const val nexusPublish = "2.0.0"
26+
// const val korte = "2.4.12"
27+
// const val mockitoCore = "5.16.0"
28+
// const val mockitoKotlin = "5.4.0"
29+
// const val robolectric = "4.14.1"
30+
// const val shadow = "8.1.1"
31+
// const val truth = "1.4.4"
32+
// }
33+
//
34+
// object plugins {
35+
// fun android(extensions.version: SupportedAgp) = "com.android.tools.build:gradle:${extensions.version.extensions.version}"
36+
// const val composeCompiler = "org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:${versions.kotlin}"
37+
// const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${extensions.libs.versions.kotlin}"
38+
// const val shadow = "com.github.johnrengelman:shadow:${extensions.libs.versions.shadow}"
39+
// const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${extensions.libs.versions.dokka}"
40+
// }
41+
//
42+
// // Libraries
43+
// val androidTools = run {
44+
// // The extensions.version of this extensions.library is linked to AGP
45+
// // (essentially: "AGP + 23.0.0")
46+
// val agpVersionParts = SupportedAgp.oldest.extensions.version.split('.')
47+
// val toolsVersion = "${23 + agpVersionParts.first().toInt()}." + agpVersionParts.drop(1).joinToString(".")
48+
// "com.android.tools:common:$toolsVersion"
49+
// }
50+
//
51+
// const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"
52+
// const val kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}"
53+
//
54+
// const val junitJupiterApi = "org.junit.jupiter:junit-jupiter-api:${versions.junitJupiter}"
55+
// const val junitJupiterParams = "org.junit.jupiter:junit-jupiter-params:${versions.junitJupiter}"
56+
// const val junitJupiterEngine = "org.junit.jupiter:junit-jupiter-engine:${versions.junitJupiter}"
57+
// const val junitVintageEngine = "org.junit.vintage:junit-vintage-engine:${versions.junitVintage}"
58+
// const val junitPlatformCommons = "org.junit.platform:junit-platform-commons:${versions.junitPlatform}"
59+
// const val junitPlatformLauncher = "org.junit.platform:junit-platform-launcher:${versions.junitPlatform}"
60+
// const val junitPlatformRunner = "org.junit.platform:junit-platform-runner:${versions.junitPlatform}"
61+
// const val apiguardianApi = "org.apiguardian:apiguardian-api:${versions.apiGuardian}"
62+
//
63+
// const val composeUi = "androidx.compose.ui:ui:${versions.compose}"
64+
// const val composeUiTooling = "androidx.compose.ui:ui-tooling:${versions.compose}"
65+
// const val composeFoundation = "androidx.compose.foundation:foundation:${versions.compose}"
66+
// const val composeMaterial = "androidx.compose.material:material:${versions.compose}"
67+
// const val composeActivity = "androidx.activity:activity-compose:${versions.activityCompose}"
68+
//
69+
// // Testing
70+
// const val junit4 = "junit:junit:${versions.junit4}"
71+
// const val korte = "com.soywiz.korlibs.korte:korte:${versions.korte}"
72+
// const val konfToml = "com.uchuhimo:konf-toml:${versions.konfToml}"
73+
// const val mockitoCore = "org.mockito:mockito-core:${versions.mockitoCore}"
74+
// const val mockitoKotlin = "org.mockito.kotlin:mockito-kotlin:${versions.mockitoKotlin}"
75+
// const val truth = "com.google.truth:truth:${versions.truth}"
76+
// const val truthJava8Extensions = "com.google.truth.extensions:truth-java8-extension:${versions.truth}"
77+
// const val robolectric = "org.robolectric:robolectric:${versions.robolectric}"
78+
//
79+
// const val androidXMultidex = "androidx.multidex:multidex:${versions.androidXMultidex}"
80+
// const val androidXTestAnnotation = "androidx.test:annotation:${versions.androidXTestAnnotation}"
81+
// const val androidXTestCore = "androidx.test:core:${versions.androidXTestCore}"
82+
// const val androidXTestMonitor = "androidx.test:monitor:${versions.androidXTestMonitor}"
83+
// const val androidXTestRunner = "androidx.test:runner:${versions.androidXTestRunner}"
84+
// const val espressoCore = "androidx.test.espresso:espresso-core:${versions.espresso}"
85+
//
86+
// const val composeUiTest = "androidx.compose.ui:ui-test:${versions.compose}"
87+
// const val composeUiTestJUnit4 = "androidx.compose.ui:ui-test-junit4:${versions.compose}"
88+
// const val composeUiTestManifest = "androidx.compose.ui:ui-test-manifest:${versions.compose}"
89+
//
90+
// // Documentation
91+
// // For the latest extensions.version refer to GitHub repo neboskreb/instant-task-executor-extension
92+
// const val instantTaskExecutorExtension = "io.github.neboskreb:instant-task-executor-extension:1.0.0"
93+
//}

build-logic/src/main/kotlin/Deployment.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fun Project.configureDeployment(deployConfig: Deployed) {
3434
// and will raise an error on inconsistent data)
3535
rootProject.configureRootDeployment(deployConfig, credentials)
3636

37-
val isAndroid = plugins.findPlugin("com.android.library") != null
37+
val isAndroid = plugins.findPlugin("com.android.extensions.library") != null
3838
val isGradlePlugin = plugins.hasPlugin("java-gradle-plugin")
3939

4040
apply {
@@ -133,13 +133,13 @@ private fun Project.configureRootDeployment(deployConfig: Deployed, credentials:
133133
}
134134

135135
// Validate the integrity of published versions
136-
// (all subprojects must use the same group ID and version number or else an error is raised)
136+
// (all subprojects must use the same group ID and extensions.version number or else an error is raised)
137137
if (version != "unspecified") {
138138
if (version != deployConfig.currentVersion || group != deployConfig.groupId) {
139139
throw IllegalStateException("A subproject tried to set '${deployConfig.groupId}:${deployConfig.currentVersion}' " +
140140
"as the coordinates for the artifacts of the repository, but '$group:$version' was already set " +
141141
"previously by a different subproject. As per the requirements of the Nexus Publishing plugin, " +
142-
"all subprojects must use the same version number! Please check Artifacts.kt for inconsistencies!")
142+
"all subprojects must use the same extensions.version number! Please check Artifacts.kt for inconsistencies!")
143143
} else {
144144
// Already configured and correct
145145
return
@@ -175,7 +175,7 @@ private fun MavenPublication.applyPublicationDetails(
175175
if (isAndroid) {
176176
artifact(buildDir.file("outputs/aar/${project.name}-release.aar").get().asFile)
177177
} else {
178-
artifact(buildDir.file("libs/${project.name}-$version.jar"))
178+
artifact(buildDir.file("extensions.libs/${project.name}-$version.jar"))
179179
}
180180
artifact(androidSourcesJar)
181181
artifact(javadocJar)
@@ -211,7 +211,7 @@ private fun MavenPublication.applyPublicationDetails(
211211
"Found a BOM declaration in the dependencies of project" +
212212
"${project.path}: $dep. Prefer declaring its " +
213213
"transitive artifacts explicitly by " +
214-
"adding a version contraint to them."
214+
"adding a extensions.version contraint to them."
215215
)
216216
}
217217

build-logic/src/main/kotlin/Environment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum class SupportedAgp(
3131
}
3232

3333
val shortVersion: String = run {
34-
// Extract first two components of the Maven dependency's version string.
34+
// Extract first two components of the Maven dependency's extensions.version string.
3535
val components = version.split('.')
3636
if (components.size < 2) {
3737
throw IllegalArgumentException("Cannot derive AGP configuration name from: $this")
@@ -58,7 +58,7 @@ sealed class Platform(val name: String) {
5858
}
5959

6060
/**
61-
* Encapsulation for "deployable" library artifacts,
61+
* Encapsulation for "deployable" extensions.library artifacts,
6262
* containing all sorts of configuration related to Maven coordinates, for instance.
6363
*/
6464
class Deployed internal constructor(

0 commit comments

Comments
 (0)