Closed johnjohndoe closed 4 months ago
You might see if my build snippet from Caffeine helps? I added an unstableKeyword
and return that in the condition. I'm not sure why yours didn't work as the two look very similar in concept.
trying your version in a groovy repl and it seems like it should work....
def isNonStable = { String version ->
def nonStableKeyword = ["BETA"].any { it -> version.toUpperCase().contains(it) }
if (nonStableKeyword) {
return true
}
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
println(isNonStable("2.0.0-Beta3"))
println(isNonStable("1.9.22"))
true
false
Yes, it seem to be correct. When I apply it to my project still the beta version is printed out when run the plugin task:
- org.jetbrains.kotlin:kotlin-stdlib [1.9.22 -> 2.0.0-Beta3]
https://kotlinlang.org/
I took that snippet into a sample project and it came out as you desired. This PR actually isn't needed because the keyword search is for stable or numeric, and anything else is assumed unstable to be excluded. So beta
should have been dropped. However, I also see in your build it shows up which is weird, but I haven't looked into it much yet.
A println shows it rejections,
Selection of org.jetbrains.kotlin:kotlin-stdlib:2.0.0-Beta3 rejected by component selection rule: Rejected by rejectVersionIf
but then I also observe,
Comparing dependency (current: org.jetbrains.kotlin:kotlin-stdlib:2.0.0-Beta3, latest: 2.0.0-Beta3)
Which indicates a dynamic version somewhere on the declared dependencies, and that is somehow not applying the resolution strategy.
Unfortunately I'm not sure beyond that. It is a configuration in the app
subproject, but it does not print out which one. I don't know why it is not being constrained by Gradle.
oh, this is the regression in https://github.com/ben-manes/gradle-versions-plugin/issues/733. We might just want to revert the contributed changes (https://github.com/ben-manes/gradle-versions-plugin/issues/733#issuecomment-1451095661). I never had a chance to look into it and see if the contributor's improvements could be reworked to not cause this breakage. If I use v0.45 in your project then you get the right output.
I'll close pr. There is a workaround in that issue. It would be good to fix but it's not something I have the time to investigate unfortunately.
Thank you for looking into it. I agree that at this point it might not be worth the time. We have it documented here so it is easy to pick up in the future.
I tried to extend the rejection rule to exclude versions like
org.jetbrains.kotlin:kotlin-stdlib [1.9.22 -> 2.0.0-Beta3]
but for some reason it is still listed. Do you spot the mistake?