Gradle --show-version

Since Gradle 5.0, GradleVersion is no longer accessible. Use

project.getGradle().getGradleVersion()

instead.

For example:

task printGradleVersion() {
    def gradleVersion = project.getGradle().getGradleVersion()
    println "Gradle version: $gradleVersion"
}

See the docs for more information.


Just add this line at the very beginning of build.gradle script:

println GradleVersion.current().prettyPrint()

It won't stop the build and print all the required info (I hope so). Unfortunately haven't found docs for this class.

EDIT

Note for newer versions of Gradle: As prettyPrint is dropped from some gradle version, you can just add this line at the very beginning of build.gradle script:

println GradleVersion.current().getVersion() + " - " + GradleVersion.current().getBuildTime() + " - " + GradleVersion.current().getRevision() + GradleVersion.current().isSnapshot() ? " - is snapshot" : ""

You can use:

gradle -v

This is the output:

------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
Build time:   2013-12-17 09:28:15 UTC
Build number: none
Revision:     36ced393628875ff15575fa03d16c1349ffe8bb6
Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.7.0_51 (Oracle Corporation 24.51-b03)
OS:           Linux 2.6.32-042stab079.5 amd64

If you use it in CI environment, it doesn't stop the build.

Tags:

Maven

Gradle