-
Notifications
You must be signed in to change notification settings - Fork 201
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
Plugin not show the latest stable version when there is alpha version #798
Comments
We delegate to Gradle for resolution, which should be looking at the Central: maven-metadata.xml |
I use these:
I tried with a single repository (only jcenter or mavenCentral) and cleared gradle / Studio cache, but the result is the same. Gradle: v8.2.1 (tried v8.0.2 too) Gradle logs this XMLs when checking version:
|
Linter reports the right version in build.gradle file inspection: |
I wrote a minimal example which works, plugins {
id 'com.github.ben-manes.versions' version '0.47.0'
id 'java-library'
}
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('com.squareup.okhttp3:okhttp:4.9.2')
} $ gradle dU --refresh-dependencies -q
------------------------------------------------------------
: 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.47.0
The following dependencies have later milestone versions:
- com.squareup.okhttp3:okhttp [4.9.2 -> 4.11.0]
https://square.github.io/okhttp/
Gradle release-candidate updates:
- Gradle: [8.0.2 -> 8.2.1 -> 8.3-rc-1] |
This is a blank Android project I generated with Android Studio and added the gradle versions plugin. It is also not working for me, same result as above. I also tried with Project: MyApplication2.zip
|
is there any type of bom or other attribute restrictions? I see the same in that project and it is not rejected. It might be something weird like a kotlin stdlib compatibility issue, causing Gradle to not select it? I know Android/Kotlin do very funky things that can break Gradle in weird ways. tasks.named("dependencyUpdates").configure {
resolutionStrategy {
componentSelection {
all {
if (isNonStable(it.candidate.version)) {
println candidate
reject('Release candidate')
}
}
}
}
} |
Unfortunately you might need to ask the Gradle folks directly. Nothing in the debug log or module metadata stands out to me, but the resolution is done by them. Something is restricting it, but it is their apis and the non-Android sample worked fine. |
minimally switching between Android and Java is enough to see this foreign restriction being applied. I just don't know the guts of Android or Gradle enough to explain why it is doing this. plugins {
id 'com.android.application'
//id 'java-library'
}
android {
namespace 'com.example.myapplication'
compileSdk 33
}
dependencies {
api 'com.squareup.okhttp3:okhttp:4.9.3'
} |
I found the issue! When I use version
|
Odd! I still don’t understand why it’s so weird, but great find |
Is there a workaround and/or upstream issue that we can follow? This issue makes using the plugin a deal breaker, since it does not do the one thing it's supposed to (report outdated dependencies) |
In this case it is something weird from the Android plugin authors. As I am not an android developer or have a relationship with their team or ecosystem, it makes more sense for users to file a ticket with them and link here as they have an interest in getting it resolved. I'm happy to help, but it's not really in scope for me to chase this down and try to get a fix out of them. |
I can file an issue, but I'm not too familiar with the internals. Which API is AGP breaking? |
They are placing some type of restriction on the dynamic resolution, |
Thanks for the info, I've created an upstream bug here: https://issuetracker.google.com/issues/311414913 |
Hi @ben-manes Just to add to this, I also get this issue for a couple of dependencies:
Here is my
I added the println to help show this issue... |
You might inspect the info log to see if a reject reason is given for a problematic version. An external resolution rule, constraint, locking, etc may be interfering with the evaluation. Since we resolve using gradle other configuration is at play, for good or bad. |
It doesn't look like Google will ever get to solving this issue. Do you think there is a workaround that we can take? |
I don’t know android enough to help. They are screwing up gradle’s resolution, which this plugin depends on, so if you resolve outside of that you’ll be fine. There’s dependabot for example to query and upgrade your version catalogs. |
I have declared
com.squareup.okhttp3:okhttp:4.9.3
in my build.gradle file. When no version filter added, it prints there is a new alpha (5.0.0-alpha.11) version. So I added the version rejecter described in readme.md. As the result, it is not reporting outdated, but also not reports the newercom.squareup.okhttp3:okhttp:4.11.0
version. It saysBut it isn't true! I add a debug printer in the
rejectVersionIf
script and it is returnsSo it seems this script working, somehow the plugin rejects stable version too if alpha rejected.
The text was updated successfully, but these errors were encountered: