-
Notifications
You must be signed in to change notification settings - Fork 310
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
Improve support for different Java versions #8249
Comments
I can say decoupling Maven, and Gradle is the best suitable solution. Explain what would be the alternatives and how this can become a nightmare: 1 - Multiple docker images with all LTS images. 2 - Use SDKMAN for java |
I'm also thinking into the direction of simply installing multiple JDK versions in parallel in the Docker image, and finding a way to choose the JDK at runtime for the package manager implementations. At least for SBT that would work, as it's called as an external CLI tool. Also for Gradle projects that leverage the toolchains mechanism that should work. Not sure about Maven, though. |
I'm not sure if have seen the issue with Maven projects so far, probably because it's more declarative than Gradle. Maybe it can happen if plugins are used the require a specific Java version, we at least load Wagon transport plugins. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
My current idea, at least for SBT for now, is to bootstrap the required JDK via https://github.com/foojayio/discoclient at ORT analyzer runtime. |
Hi, I have also some projects with maven and jdk21, and there is no issue with them, all is fine. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@sschuberth hope this help. |
Configure Gradle to build class files compatible with Java 11. This allows to use the published ORT artifacts also in Projects that use Java 11. Previously, Java 17 was required. The main use case for this is to build a Docker image with Java 11 to be able to analyze Gradle projects that are not compatible with newer Java versions. Relates to #8249. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Configure Gradle to build class files compatible with Java 11. This allows to use the published ORT artifacts also in Projects that use Java 11. Previously, Java 17 was required. The main use case for this is to be able to build the Analyzer Docker image for the ORT Server [1] with Java 11 which is required to analyze Gradle projects that are not compatible with newer Java versions. Relates to #8249. [1]: https://github.com/eclipse-apoapsis/ort-server Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Configure Gradle to build class files compatible with Java 11. This allows to use the published ORT artifacts also in Projects that use Java 11. Previously, Java 17 was required. The main use case for this is to be able to build the Analyzer Docker image for the ORT Server [1] with Java 11 which is required to analyze Gradle projects that are not compatible with newer Java versions. Relates to #8249. [1]: https://github.com/eclipse-apoapsis/ort-server Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
The previous code was calling `JavaVersion.current()` at build time, assuming that the Java version running Gradle is the same Java version used for building ORT. This assumption makes it more difficult to built ORT for different Java versions. Solve that by using Gradle's toolchains mechanism [1] instead. Choose Java 11 as the default for the new `javaLanguageVersion` property to support analyzing older projects with ORT, also see [2]. [1]: https://docs.gradle.org/current/userguide/toolchains.html [2]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
The previous code was calling `JavaVersion.current()` at build time, assuming that the Java version running Gradle is the same Java version used for building ORT. This assumption makes it more difficult to build ORT for different Java versions in the same environment. Solve that by using Gradle's toolchains mechanism [1] instead. Choose Java 11 as the default for the new `javaLanguageVersion` property to support analyzing older projects with ORT, also see [2]. [1]: https://docs.gradle.org/current/userguide/toolchains.html [2]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
The previous code was calling `JavaVersion.current()` at build time, assuming that the Java version running Gradle is the same Java version used for building ORT. This assumption makes it more difficult to build ORT for different Java versions in the same environment. Solve that by using Gradle's toolchains mechanism [1] instead. Choose Java 11 as the default for the new `javaLanguageVersion` property to support analyzing older projects with ORT, also see [2]. [1]: https://docs.gradle.org/current/userguide/toolchains.html [2]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Note that `setJavaHome()` [1] set the Java home to "to use for the Gradle process". However, as by default (unless toolchains are used [2]) "Gradle will compile Java code to the language level of the JVM running Gradle" [3], this will impact the Java target of the build. See #8249 for context. [1]: https://docs.gradle.org/current/javadoc/org/gradle/tooling/ConfigurableLauncher.html#setJavaHome(java.io.File) [2]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:compiling_with_toolchain [3]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:java_cross_compilation Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Note that `setJavaHome()` [1] set the Java home to "to use for the Gradle process". However, as by default (unless toolchains are used [2]) "Gradle will compile Java code to the language level of the JVM running Gradle" [3], this will impact the Java target of the build. See #8249 for context. [1]: https://docs.gradle.org/current/javadoc/org/gradle/tooling/ConfigurableLauncher.html#setJavaHome(java.io.File) [2]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:compiling_with_toolchain [3]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:java_cross_compilation Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Note that `setJavaHome()` [1] set the Java home to "to use for the Gradle process". However, as by default (unless toolchains are used [2]) "Gradle will compile Java code to the language level of the JVM running Gradle" [3], this will impact the Java target of the build. See #8249 for context. [1]: https://docs.gradle.org/current/javadoc/org/gradle/tooling/ConfigurableLauncher.html#setJavaHome(java.io.File) [2]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:compiling_with_toolchain [3]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:java_cross_compilation Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Note that `setJavaHome()` [1] sets the Java home "to use for the Gradle process". However, as by default (unless toolchains are used [2]) "Gradle will compile Java code to the language level of the JVM running Gradle" [3], this will impact the Java target of the build. See #8249 for context. [1]: https://docs.gradle.org/current/javadoc/org/gradle/tooling/ConfigurableLauncher.html#setJavaHome(java.io.File) [2]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:compiling_with_toolchain [3]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:java_cross_compilation Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Note that `setJavaHome()` [1] sets the Java home "to use for the Gradle process". However, as by default (unless toolchains are used [2]) "Gradle will compile Java code to the language level of the JVM running Gradle" [3], this will impact the Java target of the build. See #8249 for context. [1]: https://docs.gradle.org/current/javadoc/org/gradle/tooling/ConfigurableLauncher.html#setJavaHome(java.io.File) [2]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:compiling_with_toolchain [3]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:java_cross_compilation Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Note that `setJavaHome()` [1] sets the Java home "to use for the Gradle process". However, as by default (unless toolchains are used [2]) "Gradle will compile Java code to the language level of the JVM running Gradle" [3], this will impact the Java target of the build. See #8249 for context. [1]: https://docs.gradle.org/current/javadoc/org/gradle/tooling/ConfigurableLauncher.html#setJavaHome(java.io.File) [2]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:compiling_with_toolchain [3]: https://docs.gradle.org/8.10/userguide/building_java_projects.html#sec:java_cross_compilation Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
@fb33 for Gradle it was basically fixed by #9127, for SBT it will be fixed by #9179. Both introduce package manager options to customize the JDK to use.
Could you yourself give #9179 a try on it? |
Hi @sschuberth I have done some successful tests with ORT-32.1.0 👍 I don't know if I did it in the way you imagine, but here is what I done : I built a special ORT docker image (with only tools for my stacks) in which I added open jdk 21. packageManagers:
GradleInspector:
options:
javaHome: /usr/lib/jvm/java-21-openjdk-amd64 I override javaHome (the default one - 17, or the jdk21) on the fly according to the stack of projects being audited. |
Yes, that's a perfectly valid way to do it. If you can limit the number of required JDKs beforehand, you can add them to the Docker image and just configure the right Java home per ORT run. Alternatively, if you don't know which JDK will be required, you can let ORT bootstrap a JDK at runtime that matches the |
Great ! I'll try the bootstrap method. and good job for this new feature ! 👏 |
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
As fcfab20 decoupled the Java version to use for analysis of Gradle projects from the Java version running ORT, finally update the Java version from 11 / 17 to 21. See [1] for context. Also stop using the deprecated `Thread.id` in favor of `Thread.threadId()` and ensure to run with Java 21 when generating completion scripts. [1]: #8249 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
@mnonnenmacher, do you think this can be closed now with the recent additions to customize the Java home / version? |
Yes. |
Currently the Docker image and the artifacts published to Maven Central are both built with Java 17. This can cause two kinds of issues:
One approach to solve this would be to release the Docker images and the Maven Central artifacts with different variants for each of the Java LTS releases, currently relevant are Java 11, 17, and 21.
Another more complex approach would be to decouple the Maven and Gradle analyzers from ORT itself and release them as standalone tools, comparable to the python-inspector. These tools could then be released with a bundled JVM for the different Java versions.
Also see some related PRs and issues: #4948, #6311, #8027, #8242
The text was updated successfully, but these errors were encountered: