Getting gradle version from build.gradle or settings.gradle

Is there a cleaner way to get the gradle version then the code below?

println GradleConnector.newConnector().forProjectDirectory(rootDir).connect().getModel(BuildEnvironment.class).getGradle().getGradleVersion()`

Idealy i would to get the version from the settings.gradle file.


If you’re in a build script, just use gradle.gradleVersion.

1 Like

perfect. that works in build.gradle and settings.gradle Thank you.