Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle --show-version

Tags:

maven

gradle

What is the Gradle analog for Maven's --show-version option?

 -V,--show-version                      Display version information
                                        WITHOUT stopping build

Output includes Maven, Java and OS versions:

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 23:22:22+0800)
Maven home: D:\Progs\maven\apache-maven-3.1.1
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_11\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"  

-version stops the build. Both lines below give the same result: version only

gradle build -version
gradle -version build
like image 427
Paul Verest Avatar asked Apr 18 '14 10:04

Paul Verest


People also ask

How do I find my Gradle version?

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.

How do I mention Gradle version in build Gradle?

You can add the --gradle-version X.Y argument to specify which version of Gradle to use. Now you can run any Gradle task in your project using the gradlew shell script or bat file located in your project's root directory.

How do I check my Java version in Gradle?

Gradle doesn't expose any specific API for this but you can simply check the 'java. version' system property from the settings. gradle file. We actually do, it's ['JavaVersion'](http://www.gradle.org/docs/current/javadoc/org/gradle/api/JavaVersion.html).


2 Answers

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.

like image 113
Matthias Braun Avatar answered Oct 17 '22 07:10

Matthias Braun


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.

like image 34
Gabriele Mariotti Avatar answered Oct 17 '22 06:10

Gabriele Mariotti