-
Notifications
You must be signed in to change notification settings - Fork 744
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
Support multiple JDKs during build #44
Comments
+1 It appears to me that adding an optional java-home variable that would determine where to place the java package (which can currently be a jre, jdk, or jdk+fx), overriding the default location, would suffice, right? One would the use setup-java multiple times, once per version. |
I'm just wondering what happens if you define two different Lines 76 to 79 in b52cd69
|
I managed to do this by calling out to the |
I think that knowing where the JDK was installed is not enough. Some tools expect that java versions to appear at specific file paths. E.g. https://github.com/apache/logging-log4j2/blob/64a5c73636cef24c5cbb70143eef99536944d188/.travis-toolchains.xml#L28 . You could probably do something by symlinking the requested path to where extendedJavaHome points, but that would be messy for the user, and fairly easy for us to do in installer.ts if indicated by setting an optional java-home variable |
see:
you can use environment vars in your toolchain |
This somehow refs #21. Then, one can "just" rely on environment variables. |
Hi, I forked this project a while ago to change some things according to my needs. However, there were also additional changes that might be of interest to this project. (Sorry for bringing them up so late. I could have sworn that I commented about this months ago.) Supporting multiple JDKs was an important feature I needed at that time and the solution I ended up going with is adding an additional input parameter to the action used to specify the "target" environment variable/s with the following semantics:
Naturally, this makes it incredibly easy to work with multiple JDK versions since their locations could simply be pointed to by separate environment variables. For example:
This snippet suffices is sufficient to set up a Java 8 and Java 9 for parallel use. Here, 8 will be pointed to by
Additionally, should it become necessary to provide control about the directory in which the JDK should reside in (I have not seen the need arise yet), it would be possible to add this as an additional property. In my opinion, controlling the location of the file-system and the environment variables are orthogonal concepts that should not be configurable separately. If you are interested I would love to get this integrated upstream and I would be happy to contribute. |
I wonder if the matrix strategy is already everything we need here (as also stated on stackoverflow). I implemented this in codecentric/cxf-spring-boot-starter's action configuration in the .github/workflows/maven.yml:
|
No, this only installs 1 java version for one build, not multiple java versions for 1 build |
Ah I see. Didn't get that first, maybe the issue could be refrased a bit like |
Since Java 9, So it would be nice if setup-java could not only setup (and configure in |
Look what we did for the While we could migrate to v2 and still use |
For the Gradle users, it would be incredibly useful if Gradle could auto-detect JVMs provisioned by the There's already an issue in the Gradle repository to make this happen, but it needs a way to detect the provisioned JVMs: gradle/gradle#14903. Perhaps a bit of guidance from the maintainers of this action could get things running? |
Any update on this? |
The tycho project could use that as well... |
Gradle will by default use the same JDK for building the project as it does for running Gradle. Newer JDKs are assumed to be more performant, contain fewer bugs and to come with desirable features that we would like to utilize in our build, but doing so should not endanger backwards compatibility for the plugin itself. We can do that now by utilizing Gradle toolchains, which allows us to use one JDK/JRE for running Gradle and the other for building the project, i.e. executing `javac`. Doing this requires us to make multiple JDKs available to the Gradle build action for each individual execution of the build. The setup-java action doesn't support this at the moment, and the multiple build steps configured for actions/setup-java in this commit is at best a workaround for this, and at worst a bad assumption with respect to no environment variables or other settings being overwritten. Also, there's no handling of duplicate invocations of the action with the end result being duplicate JDKs installed. Hopefully both actions/setup-java and gradle/gradle-build-action will handle this case gracefully. For more details, see: - actions/setup-java#44 - gradle/gradle#14903
Gradle will by default use the same JDK for building the project as it does for running Gradle. Newer JDKs are assumed to be more performant, contain fewer bugs and to come with desirable features that we would like to utilize in our build, but doing so should not endanger backwards compatibility for the plugin itself. We can do that now by utilizing Gradle toolchains, which allows us to use one JDK/JRE for running Gradle and the other for building the project, i.e. executing `javac`. Doing this requires us to make multiple JDKs available to the Gradle build action for each individual execution of the build. The setup-java action doesn't support this at the moment, and the multiple build steps configured for actions/setup-java in this commit is at best a workaround for this, and at worst a bad assumption with respect to no environment variables or other settings being overwritten. Also, there's no handling of duplicate invocations of the action with the end result being duplicate JDKs installed. Hopefully both actions/setup-java and gradle/gradle-build-action will handle this case gracefully. For more details, see: - actions/setup-java#44 - gradle/gradle#14903
This commit decouples the JDK running Gradle from the one building the project. Gradle will by default use the same JDK for building the project as it does for running Gradle. Newer JDKs are assumed to be more performant, contain fewer bugs and to come with desirable features that we would like to utilize in our build, but doing so should not endanger backwards compatibility for the plugin itself. We can do that now by utilizing Gradle toolchains, which allows us to use one JDK/JRE for running Gradle and the other for building the project, i.e. executing `javac`. Doing this requires us to make multiple JDKs available to the Gradle build action for each individual execution of the build. The setup-java action doesn't support this at the moment, and the multiple build steps configured for actions/setup-java in this commit is at best a workaround for this, and at worst a bad assumption with respect to environment variables or other settings being overwritten. Furthermore, there's no handling of duplicate invocations of the action. Hopefully both actions/setup-java and gradle/gradle-build-action will handle all of this gracefully. For more details, see: - actions/setup-java#44 - gradle/gradle#14903
This commit decouples the JDK running Gradle from the one building the project. Gradle will by default use the same JDK for building the project as it does for running Gradle. Newer JDKs are assumed to be more performant, contain fewer bugs and to come with desirable features that we would like to utilize in our build, but doing so should not endanger backwards compatibility for the plugin itself. We can do that now by utilizing Gradle toolchains, which allows us to use one JDK/JRE for running Gradle and the other for building the project, i.e. executing `javac`. Doing this requires us to make multiple JDKs available to the Gradle build action for each individual execution of the build. The setup-java action doesn't support this at the moment, and the multiple build steps configured for actions/setup-java in this commit is at best a workaround for this, and at worst a bad assumption with respect to environment variables or other settings being overwritten. Furthermore, there's no handling of duplicate invocations of the action. Hopefully both actions/setup-java and gradle/gradle-build-action will handle all of this gracefully. For more details, see: - actions/setup-java#44 - gradle/gradle#14903
There is even a PR for this already, would be cool if it could be merged: #282
This sounds really useful do you think you can open a PR? @dmitry-shibanov any chance this could be implemented soon or a PR being accepted for this? |
Hello @laeubi, We will explore this pull request and the possibility of adding this functionality. |
hello @vy, i believe the solution suggested by @jvalkeal do exactly that was requested:
installs all 3 JDKs in their own directory under And in case if it is needed to know the exact location of every JDK just store them somewhere, say in environment :
and
i think this approach is more straightforward than complicating the action with non-obvious inputs |
Agreed that the concern expressed at the beginning can be addressed by running the action multiple times with different Java versions. As a matter of fact, that is what we ended up doing in Log4j too. |
@vy if this is really the solution for this issue, it should mention the snippet on the Help/Readme page, I think this is not that obvious to the usual user. |
The snippet to install multiple JDKs and keep the paths to each in the intermediate variables added to README by the PR #351 |
I am currently working on #276 (see #282 as already mentioned by @laeubi), i.e. directly supporting a generation of the
Checkout the aforementioned issue and PR for more details or in case you want to leave feedback; specifically before the maintainers decide the implementation is integration-worthy. |
FYI: I have managed to make this work for my own project like this: https://github.com/nielsbasjes/yauaa/blob/main/.github/workflows/build.yml#L43 |
Hello everyone. We released a new version of setup-java with support of multiple jdks. For now I'm going to close the issue. If you have any concerns feel free to ping us. |
This commit decouples the JDK running Gradle from the one building the project. Gradle will by default use the same JDK for building the project as it does for running Gradle. Newer JDKs are assumed to be more performant, contain fewer bugs and to come with desirable features that we would like to utilize in our build, but doing so should not endanger backwards compatibility for the plugin itself. We can do that now by utilizing Gradle toolchains, which allows us to use one JDK/JRE for running Gradle and the other for building the project, i.e. executing `javac`. Doing this requires us to make multiple JDKs available to the Gradle build action for each individual execution of the build. The setup-java action doesn't support this at the moment, and the multiple build steps configured for actions/setup-java in this commit is at best a workaround for this, and at worst a bad assumption with respect to environment variables or other settings being overwritten. Furthermore, there's no handling of duplicate invocations of the action. Hopefully both actions/setup-java and gradle/gradle-build-action will handle all of this gracefully. For more details, see: - actions/setup-java#44 - gradle/gradle#14903
This commit decouples the JDK running Gradle from the one building the project. Gradle will by default use the same JDK for building the project as it does for running Gradle. Newer JDKs are assumed to be more performant, contain fewer bugs and to come with desirable features that we would like to utilize in our build, but doing so should not endanger backwards compatibility for the plugin itself. We can do that now by utilizing Gradle toolchains, which allows us to use one JDK/JRE for running Gradle and the other for building the project, i.e. executing `javac`. Doing this requires us to make multiple JDKs available to the Gradle build action for each individual execution of the build. The setup-java action doesn't support this at the moment, and the multiple build steps configured for actions/setup-java in this commit is at best a workaround for this, and at worst a bad assumption with respect to environment variables or other settings being overwritten. Furthermore, there's no handling of duplicate invocations of the action. Hopefully both actions/setup-java and gradle/gradle-build-action will handle all of this gracefully. For more details, see: - actions/setup-java#44 - gradle/gradle#14903
Certain projects might require multiple JDKs during build (e.g., Apache Log4j requires Java 7 and Java 9+ by means of
toolchains.xml
) and in its current form, that is not possible viasetup-java
.The text was updated successfully, but these errors were encountered: