Project SDK Version is ignored for Gradle

I have a simple Gradle project with a configured Project SDK Java 1.8.

Running the project as a Java application inside IntelliJ works fine and Java 1.8 is used.

But if I use a Gradle task like "run" inside the IntelliJ the SDK-Version is ignored.
It takes always Java 1.7 which is the default on my operation system.

Is there a way to force the Gradle process to use the configured Project SDK?

Bonus question:
Intellij comes with a Gradle wrapper to Version 2.0.  Is there a way to update
the wrapper to use Gradle 2.3?

Thanks!

0
6 comments

Anyone?  Thanks....


0

Can somebody from JetBrains help and answer the questions?
Thanks!

0

mos wrote:


Is there a way to force the Gradle process to use the configured Project SDK?

yes, if you use IDEA 14.1 you can set JDK for Gradle in settings, see details at https://youtrack.jetbrains.com/issue/IDEA-134428
For earlier IDEA versions you could use 'gradle.java.home' property, just add the following line to your '$IDEA_HOME/bin/idea.properties' file:

gradle.java.home=<path to the jdk>

mos wrote:

Intellij comes with a Gradle wrapper to Version 2.0.  Is there a way to update
the wrapper to use Gradle 2.3?

yes, open Gradle Settings
if the following option is available "Use default gradle wrapper (recommended)", turn it on and open <your_project_path>\gradle\wrapper\gradle-wrapper.properties file and edit distributionUrl as follows:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip

if you use "Use customisable gradle wrapper" option, you can set the version you want in the build.gradle script of you root project:

'2.3'
}

see details about wrapper task at https://gradle.org/docs/current/userguide/gradle_wrapper.html

or you can install gradle locally and select "Use local gradle distribution" option.

0

Thanks Vladislav!  Great information!

When will the IDEA Version 14.1 be released?

0

it's expected roughly at the end of March

0

Unfortunately, https://youtrack.jetbrains.com/issue/IDEA-134428 does not seem to fix similar problem for me. In fact, I have JDK 1.8 set as JAVA_HOME, and also as Project SDK and as Gradle JVM as per setting above.

It still launches Gradle from JDK 1.7 JVM.

When I run gradlew.bat from the command line, it uses right JVM

0

Please sign in to leave a comment.