X Tutup
The Wayback Machine - https://web.archive.org/web/20240324115127/https://github.com/github/codeql-action/issues/1855
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple JAVA_HOME detected and wrong one selected #1855

Open
onacit opened this issue Aug 27, 2023 · 4 comments
Open

Multiple JAVA_HOME detected and wrong one selected #1855

onacit opened this issue Aug 27, 2023 · 4 comments

Comments

@onacit
Copy link

onacit commented Aug 27, 2023

I set up JDK 17 like this.

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Setup Java
      uses: actions/setup-java@v3
      with:
        distribution: 'temurin'
        java-version: '17'

And it seems that autobuild selects wrong JDK.


  /opt/hostedtoolcache/CodeQL/2.14.1/x64/codeql/java/tools/autobuild.sh 
  Picked up JAVA_TOOL_OPTIONS:  -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
  [2023-08-27 13:07:02] Build directory is .
  [2023-08-27 13:07:02] Discovered Java toolchain for version 17.0.0 at /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.8-7/x64 in /home/runner/.m2/toolchains.xml
  [2023-08-27 13:07:02] Discovered Java toolchain for version 17.0.0 at /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.8-7/x64 in JAVA_HOME_17_X64
  [2023-08-27 13:07:02] Discovered Java toolchain for version 8.0.0 at /usr/lib/jvm/temurin-8-jdk-amd64 in JAVA_HOME_8_X64
  [2023-08-27 13:07:02] Discovered Java toolchain for version 11.0.0 at /usr/lib/jvm/temurin-11-jdk-amd64 in JAVA_HOME_11_X64
  [2023-08-27 13:07:02] Setting Java version to 8.0.0 (GHA) <<<<<<<<<<<<<<<<<<<<<<<<<<<<
  [2023-08-27 13:07:02] Setting JAVA_HOME to /usr/lib/jvm/temurin-8-jdk-amd64 <<<<<<<<<<<<<<<<<
  [2023-08-27 13:07:02] Adding /usr/lib/jvm/temurin-8-jdk-amd64/bin to PATH
  [2023-08-27 13:07:02] [autobuild] > mvn -N io.takari:maven:wrapper 

And this is my enforcer rules evaluates.

>mvn validate
[INFO] Scanning for projects...
[INFO]
[INFO] --------< ... >--------
[INFO] Building ...-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- enforcer:3.4.0:enforce (enforce-dependency-convergence) @ ... ---
[INFO] Skipping Rule Enforcement.
[INFO]
[INFO] --- enforcer:3.4.0:enforce (enforce-require-java-version-to-[17,)) @ ... ---
[INFO] Detected Java Version: '20.0.2'
[INFO] Normalized Java Version: '20.0.2'
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
[INFO]
[INFO] --- enforcer:3.4.0:enforce (enforce-require-maven-version-to-[3.2.5,)) @ ... ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.319 s
[INFO] Finished at: 2023-08-27T22:23:15+09:00
[INFO] ------------------------------------------------------------------------
@aeisenberg
Copy link
Contributor

Is your repository using codeql? If so, can you include your full (redacted) workflow file? If it isn't using codeql, then this is not the correct repo to raise the issue. actions/setup-java is the right place.

@aeisenberg
Copy link
Contributor

I just learned that we have recently made some changes to CodeQL's ability to discover which versions of Java are installed in the build environment. Please see the details in this issue and it may help with what you are seeing.

github/codeql#13541

@mbg
Copy link
Member

mbg commented Aug 29, 2023

Hi @onacit! The issue that @aeisenberg linked to is likely what you are running into, but we have made some further improvements to the version selection logic since. I note that you are currently using CodeQL 2.14.1. CodeQL 2.14.3 contains the improvements, so if you can give that version a go and report back whether that works for you, that would be great!

@dargmuesli
Copy link

dargmuesli commented Oct 26, 2023

I think this is still happening: https://github.com/maevsi/android/actions/runs/6648225427/job/18064934351#step:4:78
I'd expect v17 to be chosen as Gradle 8.4 should certainly support it, shouldn't it? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@onacit @mbg @aeisenberg @dargmuesli and others
X Tutup