@@ -3,35 +3,47 @@ package io.github.composegears.valkyrie.task
33import net.swiftzer.semver.SemVer
44import org.gradle.api.DefaultTask
55import org.gradle.api.GradleException
6- import org.gradle.api.provider.ListProperty
6+ import org.gradle.api.provider.MapProperty
77import org.gradle.api.provider.Property
88import org.gradle.api.tasks.Input
99import org.gradle.api.tasks.TaskAction
1010
1111abstract class CheckVersionCompatibility : DefaultTask () {
1212
13+ /* * Maps each resolved coordinate (`group:name:version`) to the list of coordinates that depend on it. */
1314 @get:Input
14- abstract val resolvedComponents: ListProperty <String >
15+ abstract val resolvedComponents: MapProperty <String , List < String > >
1516
1617 @get:Input
1718 abstract val maxKotlinVersion: Property <String >
1819
1920 @get:Input
2021 abstract val maxComposeVersion: Property <String >
2122
23+ @get:Input
24+ abstract val maxCoroutinesVersion: Property <String >
25+
2226 @TaskAction
2327 fun check () {
2428 val maxKotlin = SemVer .parse(maxKotlinVersion.get())
2529 val maxCompose = SemVer .parse(maxComposeVersion.get())
30+ val maxCoroutines = SemVer .parse(maxCoroutinesVersion.get())
2631
2732 val violations = resolvedComponents.get()
28- .mapNotNull { coordinate ->
33+ .mapNotNull { ( coordinate, dependents) ->
2934 val (group, name, version) = coordinate.split(" :" )
35+ val requiredBy = if (dependents.isNotEmpty()) {
36+ " \n " + dependents.joinToString(" \n " ) { " \t\t - $it " }
37+ } else {
38+ " "
39+ }
3040 when {
3141 group == " org.jetbrains.kotlin" && SemVer .parse(version) > maxKotlin ->
32- " \t - $group :$name :$version (max supported: $maxKotlin )"
42+ " \t - $group :$name :$version (max supported: $maxKotlin )$requiredBy "
3343 group.startsWith(" org.jetbrains.compose" ) && SemVer .parse(version) > maxCompose ->
34- " \t - $group :$name :$version (max supported: $maxCompose )"
44+ " \t - $group :$name :$version (max supported: $maxCompose )$requiredBy "
45+ group == " org.jetbrains.kotlinx" && name.startsWith(" kotlinx-coroutines" ) && SemVer .parse(version) > maxCoroutines ->
46+ " \t - $group :$name :$version (max supported: $maxCoroutines )$requiredBy "
3547 else -> null
3648 }
3749 }
@@ -45,6 +57,6 @@ abstract class CheckVersionCompatibility : DefaultTask() {
4557 },
4658 )
4759 }
48- logger.lifecycle(" ✅ All dependencies are compatible (kotlin ≤ $maxKotlin , compose ≤ $maxCompose )" )
60+ logger.lifecycle(" ✅ All dependencies are compatible (kotlin ≤ $maxKotlin , compose ≤ $maxCompose , coroutines ≤ $maxCoroutines )" )
4961 }
5062}
0 commit comments