BuildShip: assemble task does not run with expected Java Home

Gradle Version: 3.1
BuildShip Version: 1.0.21.v20161010-1637
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Windows 8.1 6.3 amd64Is this a regression? No

When I execute the “build” task for my Gradle project via the Gradle Tasks view, the task runs successfully with the expected Java Home value:

Working Directory: D:\DEV\workspaces\SpringBoot\OIService
Gradle User Home: D:\DEV\gradle_user_home
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 3.1
Java Home: D:\DEV\jdk1.7.0_79
JVM Arguments: None
Program Arguments: None
Gradle Tasks: build

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:OIServiceClient:processResources
:OIServiceClient:generateJsonSchema2Pojo
:OIServiceClient:compileJava
:OIServiceClient:classes
:OIServiceClient:jar
:OIServiceClient:sourceJar
:OIServiceClient:assemble
:OIServiceClient:compileTestJava UP-TO-DATE
:OIServiceClient:processTestResources UP-TO-DATE
:OIServiceClient:testClasses UP-TO-DATE
:OIServiceClient:test UP-TO-DATE
:OIServiceClient:check UP-TO-DATE
:OIServiceClient:build

BUILD SUCCESSFUL

Total time: 0.65 secs

Execution of the “assemble” task fails, due to a different, unexpected value for the Java Home being used:

Working Directory: D:\DEV\workspaces\SpringBoot\OIService
Gradle User Home: D:\DEV\gradle_user_home
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 3.1
Java Home: C:\Program Files\Java\jre7
JVM Arguments: None
Program Arguments: None
Gradle Tasks: assemble

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:assemble
:OIServiceClient:processResources
:OIServiceClient:generateJsonSchema2Pojo
:OIServiceClient:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':OIServiceClient:compileJava'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre7 contains a valid JDK installation.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.508 secs

The “assemble” task seems to be the only one that exhibits this behavior.

I’ve verified that the “jdk1.7.0_79” is configured as the default Installed JRE, and that the JavaSE-1.7 execution environment has been configured to specify the “jdk1.7.0_79” JDK.

Thanks,
Tony

Hey Anthony,

can you check the run configuration of the assemble task for any differences to other run configurations?

Cheers,
Stefan

Hi Stefan,

Thanks for the suggestion. I compared the run configuration for the “build” task to the “assemble” task, and found that the Java Home had been set for “build” but not for “assemble.” Once I added the path for the Java Home to the “assemble” tasks run configuration, it ran without error.

However, this leads me to a follow-up question…

I had set the Java Home to the appropriate path at the project level. Should the project-level setting be inherited by all of the tasks? Or, is there really a need to configure the Java Home specifically for the “build” and “assemble” tasks?

Thanks,
Tony

Hi Anthony,

the java home can no longer be set at the Eclipse project level. Please use your ~/.gradle/gradle.properties. This has the added benefit of ensuring the same Java home for Gradle on the command line and in the IDE. You can then remove the config from the tasks too.

Cheers,
Stefan

Sweet - thanks again!