Is there a way to programmatically ensure a minimum gradle version, using non-internal gradle apis?

I want to check in my plugin if a user is using atleast some version of gradle, say 2.1

if (gradleVersionComparator(project.gradle.gradleVersion, "2.1") >= 0) {
   // tell the user to upgrade or something
}

I was using something external, but it turns out it doesn’t handle "-"s and "+"s that are in the nightly gradle build version : 2.1-123123+00000

I see there are a bunch of version matchers in “org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy” and I can use

new ExactVersionMatcher().compare("2.0", "2.1")

being an internal thing, is there any expectation that this will continue to work? Or should I just push my own solution?

1 Like

You may want to look at ‘org.gradle.util.VersionNumber’. In the example you gave it would consider the nightly version less than the release version, which I believe is the behavior you want.

Unfortunately, ‘VersionNumber’ is not part of the public API (not contained in Javadoc or Groovydoc).

Is there a whitelist somewhere that indicates what classes should be included in the public javadoc?

Edit Nevermind, I found it in the docs.gradle build script.