Can anybody please help me how to run the below command in gradle:
gradle -version | grep ^JVM
Thanks, Sanjiv Note: This topic was created from a reply on the Need help to compile Java code in Gradle topic.
Can anybody please help me how to run the below command in gradle:
gradle -version | grep ^JVM
Thanks, Sanjiv Note: This topic was created from a reply on the Need help to compile Java code in Gradle topic.
Can you give more background information what you try to achieve with the jvm version information? You can get Information about the current Jvm by using:
def currentJvm = org.gradle.internal.jvm.Jvm.current()
println currentJvm
Hi Rene,
I am not looking for the JVM information. I need to extract the current Java and Gradle version to use somewhere in the script. I was trying the following command:
gradle -version | grep JVM
I have written my gradle task also to get the same. This is the code:
task extarctVersion {
new ByteArrayOutputStream().withStream { os ->
def result = exec {
executable = ‘gradle’
args = [’-version’,’|’,‘grep JVM’]
standardOutput = os
}
output = os.toString()
}
}
I seems that the command after pipe symbol is not working. Is there some way in Gradle to get the current Java and Gradle version?
Thanks,
Sanjiv
Thanks Rene
Yes the code which you sent is giving me the Java version. Is there something similar to get the Gradle version no?
Thanks, Sanjiv
hi,
you can use GradleVersion for that:
println GradleVersion.current().getVersion()
// or even better
println GradleVersion.current().toString()
cheers, René
Thanks Rene for your quick response!!!
Yup its working fine now.