gradle-versions-plugin: Plugin not show the latest stable version when there is alpha version

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 newer com.squareup.okhttp3:okhttp:4.11.0 version. It says

The following dependencies are using the latest milestone version:
- com.squareup.okhttp3:okhttp:4.9.2

But it isn’t true! I add a debug printer in the rejectVersionIf script and it is returns

isNonStable: true 5.0.0-alpha.1
isNonStable: false 4.11.0

So it seems this script working, somehow the plugin rejects stable version too if alpha rejected.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 17 (9 by maintainers)

Most upvoted comments

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.

Thanks for the info, I’ve created an upstream bug here: https://issuetracker.google.com/issues/311414913

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]