Determine Gradle version programmatically from Gradle plugin

How can I get the Gradle version programmatically from the Gradle plugin?

+4


source to share


2 answers


It just turned out that one can get it using

  • getProject().getGradle().getGradleVersion()


    Javadoc and DSL link for the core Gradle type that contains the version. As per the javadoc, getVersion will never return null.


or

  • Plugin.class.getPackage().getImplementationVersion()


    It is simple groovy / java class based and depends on the classloader and the provided manifest.
+5


source


This question came up as the first result when I googled for it.

There is a class - GradleVersion that will do the job too. So

GradleVersion.current();

      



will return the same as

getProject().getGradle().getGradleVersion()

      

0


source







All Articles