/home/user/gradle-5.6.4/bin/gradle -Dorg.gradle.java.home=/home/user/java11/jdk-11.0.2 -version
Output
Gradle 5.6.4
------------------------------------------------------------
Build time: 2019-11-01 20:42:00 UTC
Revision: dd870424f9bd8e195d614dc14bb140f43c22da98
Kotlin: 1.3.41
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 1.8.0_252 (Private Build 25.252-b09)
OS: Linux 4.15.0-106-generic amd64
Why is it picking 1.8.0_252?
It looks like your post is mostly code; please add some more details.
feedback for so
Turns out the -Dorg.gradle.java.home does not override JAVA_HOME
echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/
Related
How do I convert this build.gradle code to build.gradle.kts?
// run ./gradlew wrapper whenever you change this
wrapper {
distributionUrl("https://globochem.jfrog.io/artifactory/globochem-gradle/globochem-6.6.6.zip")
}
For this setup:
$ gradle -v
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------
Build time: 2022-11-25 13:35:10 UTC
Revision: daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8
Kotlin: 1.7.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.18 (Homebrew 11.0.18+0)
OS: Mac OS X 12.6.2 aarch64
This works for build.gradle.kts:
// run ./gradlew wrapper whenever you change this
tasks.withType<Wrapper> {
distributionUrl = "https://globochem.jfrog.io/artifactory/globochem-gradle/globochem-6.6.6.zip"
}
I''ve installed gradle via SDK, and my java version is 11.0.14. But whe I run gradle -v it returns:
Gradle 6.5
------------------------------------------------------------
Build time: 2020-06-02 20:46:21 UTC
Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_321 (Oracle Corporation 25.321-b07)
OS: Linux 5.4.0-109-generic amd64
Java --version:
java 11.0.14 2022-01-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.14+8-LTS-263)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.14+8-LTS-263, mixed mode)
But I want this gradle JVM to be 11.0.14, how can I change this?
I want to use JDK11 in Gradle for compiling my project without modifying JDK_HOME, which points to JDK10. I'm using JDK10 for most projects, but testing an upgrade to JDK11 in Gradle.
JAVA_HOME=C:\Program Files\Java\jdk-10.0.2
In /.gradle/gradle.properties I set the following property:
org.gradle.java.home=C:/Program Files/Java/jdk-11.0.3
when I run the command: gradle properties, I see the following line:
org.gradle.java.home: C:/Program Files/Java/jdk-11.0.3
but when I run the command: gradle -version, I see this, showing JVM is version 10:
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------
Build time: 2019-04-26 08:14:42 UTC
Revision: 261d171646b36a6a28d5a19a69676cd098a4c19d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 10.0.2 ("Oracle Corporation" 10.0.2+13)
OS: Windows 10 10.0 amd64
Despite is saying JDK10 above, is it still compiling in JDK11 and JVM only means the Java version used to run the Gradle Daemon?
The version reported by gradle -version is the one of the client VM executing that command.
Normally, Gradle will otherwise use a daemon process to execute your build. That process will respect the org.gradle.java.home setting.
Note that you can also have a finer control on which Java executable is used for the different tasks in Gradle. See the documentation for details.
I am using Kotlin DSL with Gradle build tool.
My gradle build works well both locally and on jenkins server when run from command line.
However IDEA complains and marks several items red with the following errors:
Cannot access class 'java.lang.Object'. Check your module classpath for missing or conflicting dependencies
None of the following functions can be called with the arguments supplied
I have tried all 3 options in project settings:
- Use default gradle wrapper
- Use gradle 'wrapper' task configuration
- Use local gradle distribuition
Result if pretty same
QUESTION: is something wrong in config, or is there a fix or workaround for that?
IntelliJ IDEA 2018.1.2 (Community Edition)
Build #IC-181.4668.68, built on April 24, 2018
JRE: 1.8.0_152-release-1136-b29 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-20-generic
.
Kotlin plugin: 1.2.41-release-IJ2018.1-1
.
Gradle 4.7
------------------------------------------------------------
Build time: 2018-04-18 09:09:12 UTC Revision: b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy: 2.4.12 Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017 JVM: 1.8.0_171 (Oracle Corporation 25.171-b11) OS: Linux 4.15.0-20-generic amd64
UPD: #tweitzel you are right, it was incorrect SDK setting, thanks!
in my case I had set a jdk as File->Project Structure... -> Project->Project SDK
instead of setting the Kotlin SDK
after setting Kotlin SDK as Project SDK my build.gradle.kts errors disappeared
The gradle task that I have added to my build.gradle is not getting listed.
This is how my build.gradle looks
task helloWorld {
doLast {
println 'Hello world from gradle.'
}
}
However when I run gradle tasks the task helloWorld is not listed. Please help.
The gradle version is the following.
$ gradle -v
------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------
Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_31 (Oracle Corporation 25.31-b07)
OS: Mac OS X 10.11.6 x86_64
Looks like we need to use --all switch. The following works.
$ gradle tasks --all