ben-manes / gradle-versions-plugin

Gradle plugin to discover dependency updates
Apache License 2.0
3.82k stars 199 forks source link

Introduce options similar to allowMajorUpdates and allowMinorUpdates in maven versions plug-in #866

Open dpolivaev opened 1 month ago

dpolivaev commented 1 month ago

Sometimes major updates require update of Java runtime version or introduce other breaking changes and therefore they are not always possible.

See https://www.mojohaus.org/versions/versions-maven-plugin/update-property-mojo.html#allowMajorUpdates Relates to https://github.com/ben-manes/gradle-versions-plugin/issues/841

ben-manes commented 1 month ago

You can do this today using a resolutionStrategy. That offers more control as you can inspect the current version and the candidate selection. There is the short form below and an expanded block where you can specify the reject reason for different dependencies.

tasks.withType<DependencyUpdatesTask> {
  rejectVersionIf {
    candidate.version.substringBefore(".") != currentVersion.substringBefore(".")
  }
}

The version strings in the ecosystem varies and some do not follow Maven's version conventions or semver. For example, I've seen some use even / odd version numbers to denote stable and beta releases. Instead we make sure you have the flexibility to define the logic for what your build needs, which likely will be mostly semver, but don't provide out-of-the-box that breaks and causes users wanting us to chase down bugs from 3rd parties.