File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
build-logic/convention/src/main/kotlin/io/github/composegears/valkyrie/task Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ package io.github.composegears.valkyrie.task
2+
3+ import org.gradle.api.DefaultTask
4+ import org.gradle.api.GradleException
5+ import org.gradle.api.artifacts.ArtifactCollection
6+ import org.gradle.api.artifacts.component.ModuleComponentIdentifier
7+ import org.gradle.api.provider.Property
8+ import org.gradle.api.tasks.Input
9+ import org.gradle.api.tasks.Internal
10+ import org.gradle.api.tasks.TaskAction
11+
12+ abstract class CheckComposeVersionCompatibility : DefaultTask () {
13+ @get:Internal
14+ abstract val artifactCollection: Property <ArtifactCollection >
15+
16+ @get:Input
17+ abstract val expectedComposeVersion: Property <String >
18+
19+ @TaskAction
20+ fun checkVersions () {
21+ val expectedVersion = expectedComposeVersion.get()
22+
23+ val composeDependencies = artifactCollection.get().artifacts
24+ .mapNotNull { it.id.componentIdentifier as ? ModuleComponentIdentifier }
25+ .filter { it.group.startsWith(" org.jetbrains.compose" ) }
26+
27+ val invalidVersions = composeDependencies.filter { it.version != expectedVersion }
28+
29+ if (invalidVersions.isNotEmpty()) {
30+ val errorMessage = buildString {
31+ appendLine(" Found org.jetbrains.compose dependencies with version != $expectedVersion :" )
32+ invalidVersions.forEach {
33+ appendLine(" - ${it.group} :${it.module} :${it.version} " )
34+ }
35+ }
36+ throw GradleException (errorMessage)
37+ }
38+ logger.lifecycle(" ✅ All compose dependencies have the correct version $expectedVersion " )
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ import io.github.composegears.valkyrie.task.CheckComposeVersionCompatibility
12import org.jetbrains.changelog.Changelog
23import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
34import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask.FailureLevel
@@ -131,4 +132,15 @@ tasks {
131132 prepareSandbox {
132133 exclude { " coroutines" in it.name }
133134 }
135+ check {
136+ dependsOn(" checkComposeVersionCompatibility" )
137+ }
138+ }
139+
140+ tasks.register<CheckComposeVersionCompatibility >(" checkComposeVersionCompatibility" ) {
141+ val runtimeClasspath = configurations.named(" runtimeClasspath" )
142+ artifactCollection = provider {
143+ runtimeClasspath.get().incoming.artifactView { lenient(true ) }.artifacts
144+ }
145+ expectedComposeVersion = libs.versions.compose
134146}
You can’t perform that action at this time.
0 commit comments