-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot exclude kotlin-stdlib-jdk8 in 0.46.0 #733
Comments
I tried it on Groovy and Kotlin, and it worked for me. Can you make a minimal reproduction? Kotlinimport com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
`java-library`
id("com.github.ben-manes.versions") version "0.46.0"
}
repositories {
mavenCentral()
}
fun String.isNonStable(): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(this)
return isStable.not()
}
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
candidate.version.isNonStable()
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10")
} ben: kotlin $ gradle dU
> Task :dependencyUpdates
------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------
The following dependencies are using the latest milestone version:
- com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin:0.46.0
- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10
Gradle release-candidate updates:
- Gradle: [7.5.1 -> 8.0.1]
Generated report file build/dependencyUpdates/report.txt Groovyplugins {
id "java-library"
id "com.github.ben-manes.versions" version "0.46.0"
}
repositories {
mavenCentral()
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10'
} ben: groovy $ gradle dU
> Task :dependencyUpdates
------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------
The following dependencies are using the latest milestone version:
- com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin:0.46.0
- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10
Gradle release-candidate updates:
- Gradle: [7.5.1 -> 8.0.1]
Generated report file build/dependencyUpdates/report.txt
BUILD SUCCESSFUL in 3s
1 actionable task: 1 executed |
I am also experiencing this problem. One potential cause is that instead of writing I might be able to provide a minimal reproduction example, but not today 😄 . |
@Adriankhl That was my instinct as well. I did not manage to reproduce it in a minimal example though. So this is pretty interesting. I will also try to get some time to dig into it this week, but feel free to troubleshoot on your end. |
@ben-manes I think this problem is android-related, here a minimal build:
Output:
|
When running the org.jetbrains.kotlin:kotlin-stdlib-jdk8:{strictly 1.8.10} -> 1.8.10 (c) If the dependency is declared on multiple configurations at different versions, then we will list each upgrade opportunity. We see As mentioned, this worked correctly in 0.45. There were 3 changes in v46 so the next step is to see which caused the regression by building the commits as locally installed plugins. |
Hey @Vampire, It seems that your changes in #725 / #731 caused this regression. I narrowed the cause to this code change that had confused us, /** Returns the version status of the configuration's dependencies. */
private fun getStatus(
coordinates: Map<Coordinate.Key, Coordinate>,
resolved: Set<ResolvedDependency>,
unresolved: Set<UnresolvedDependency>,
): Set<DependencyStatus> {
val result = hashSetOf<DependencyStatus>()
for (dependency in resolved) {
val resolvedCoordinate = Coordinate.from(dependency.module.id)
val originalCoordinate = coordinates[resolvedCoordinate.key]
val coord = originalCoordinate ?: resolvedCoordinate
- if (originalCoordinate == null && resolvedCoordinate.groupId != "null") {
- project.logger.info("Skipping hidden dependency: $resolvedCoordinate")
- } else {
- val projectUrl = getProjectUrl(dependency.module.id)
- result.add(DependencyStatus(coord, resolvedCoordinate.version, projectUrl))
- }
+ val projectUrl = getProjectUrl(dependency.module.id)
+ result.add(DependencyStatus(coord, resolvedCoordinate.version, projectUrl))
} In the logs I see that it was a hidden dependency that was skipped,
In this case the |
I was under the impression that it duplicates the code at
Which was also supported by the fact, that no test failed when removing that So yeah, if the mentioned line is not sufficient to exclude those, probably the |
Btw. it might make sense to have some way to display those too, it having them a separate category. If some configuration has default dependencies it is usually provided so that you can manually change the dependency, for example because coordinates of the artifact changed or a fork should be used. Sometimes additionally an extension property like |
It raises questions because users don’t understand what to do about it or where they came from. Here I guess because kotlin hard codes the config name that constraints apply to, the copy resolves to a different version than their actual build. It didn’t honor the resolution strategy for some reason which would also annoy people, which I don’t think is a bug in our code. I end up using a custom configuration to add tool dependencies to so that it is shown on the report. I tried using a partial if clause but the tests failed. It will take some experimenting to figure this out again and satisfy everyone’s desired behaviors. |
As a temporary fix, add this to the
|
After upgrade to the latest version 0.46.0 we get this error:
Here is our normal way of excluding versions, inspired by your README:
The
isNonStable
check works in 0.45.0 (without the explicit exclude in excludeKotlinVersions), but not in 0.46.0.It does trigger the warning in both 0.45.0 and 0.46.0:
But I still get the version warning:
The text was updated successfully, but these errors were encountered: