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
Java: Please either autodetect the needed JDK version from pom.xml
or document that setup-java
must be called manually
#2074
Comments
That statement is overly optimistic ;-) GitHub-hosted runners have several versions of Java pre-installed, but it definitively does not contain every possible version. According to internal.ubuntu-22.04.json the current github-hosted runner image contains: {
"NodeType": "HeaderNode",
"Title": "Java",
"Children": {
"NodeType": "TableNode",
"Headers": "Version|Environment Variable",
"Rows": [
"8.0.392+8|JAVA_HOME_8_X64",
"11.0.21+9 (default)|JAVA_HOME_11_X64",
"17.0.9+9|JAVA_HOME_17_X64",
"21.0.1+12|JAVA_HOME_21_X64"
]
}
}, The CodeQL autobuilder looks in the pom.xml file for hints about the required Java version and should pick the best matching version from the ones above and otherwise falls back to JAVA_HOME or the one on the PATH. The Could you share the |
NB. we have intended to detect needed version from pom.xml more ambitiously for a while, but that work is stuck because we found that roughly equal numbers of repositories were fixed thanks to finding useful cues to install a particular version, as were deceived into installing an incompatible Java version by some misleading apparent hint in the pom.xml file. We intend to revisit the matter to try to refine our heuristics, but it's not easy. |
For CodeQL runs on Maven Java projects, the default-generated workflow, which runs autobuild, fails with
error: invalid target release: 17
if the project requires JDK 17 (or, apparently, any version besides JDK 8). The same failure occurs if autobuild is replaced with a basicmvn compile
manual build step.Several issues have comments describing a solution (namely, adding a
setup-java
action) -- but I could not find any mention of it in the CodeQL config docs (1, 2, 3, 4). In fact, these docs strongly suggest that setting up the right version of Java build tools is only required if using self-hosted runners:Many people have tripped over this: 1, 2, 3, 4, 5.
There was already an intention to autodetect the needed JDK version, which would be the ideal solution. (It could be implemented by looking for any
<maven.compiler.target/>
element inpom.xml
.) But if that's tricky, then please at least document that manually addingsetup-java
to the workflow is needed for JDK versions other than 8.The text was updated successfully, but these errors were encountered: