heroku / heroku-buildpack-gradle

Heroku's buildpack for Gradle applications.
MIT License
63 stars 91 forks source link

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. #56

Open jansenm opened 4 years ago

jansenm commented 4 years ago

The buildpack has a conceptual problem.

Compile installs the required jdk and sets the required environment variable JAVA_HOME, then calls gradlew <buildCommand> .

Test-Compile first executes Compile and then calls gradlew resolveTestRuntime without setting JAVA_HOME so it fails with the error in the title. Unless naturally your image has a java in $PATH which might or might not be the one you wanted to use. But the script just exits, the buildpack call doesn't return an error. So the pipeline continues. I guess its not a problem if you don't have testRuntimeDependencies.

The Test step btw. doesn't do much setup either so it downloads gradlew a second time before executing the tests.

Test-Compile probably should source Compile.

Test should get the needed configuration so it doesn't download gradlew twice

hassanmohaideen commented 6 months ago

Hi, wanted to see if there is a solution or work around for this? I am currently getting this error -

       > Task :compileJava NO-SOURCE
       > Task :classes UP-TO-DATE
       > Task :jvmMainClasses
       > Task :compileTestKotlinJvm
       > Task :compileTestJava NO-SOURCE
       > Task :testClasses UP-TO-DATE

       BUILD SUCCESSFUL in 1m 12s
       4 actionable tasks: 4 executed
-----> Resolving testRuntime dependencies...

       ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

       Please set the JAVA_HOME variable in your environment to match the
       location of your Java installation.

 !     Could not detect buildpack https://github.com/heroku/heroku-buildpack-java