-
Notifications
You must be signed in to change notification settings - Fork 353
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
[Windows build from source] Gradle JDK auto-download doesn't work as expected #4018
Comments
Thanks for pointing this out and linking to the relevant sources @piomar123 ! I'm guessing this was missed when we upgraded Gradle. We had a similar PR opened against rewrite-gradle-plugin recently; you might be interested to weigh in there with the best way forward: |
So there are two parts here.
|
@timtebeek, from an opinion question standpoint would you rather see:
|
Thanks for the reminder @shanman190 ! I'm leaning towards updating the docs, as I'd find it unlikely that folks don't have a matching Java version available already, or if they don't, they might have another preferred mechanism of obtaining such a JDK (SDKman, Jenv, homebrew, Chocolatey, ...) I can be swayed if there's a convincing argument for auto download, but when I'm giving a workshop I wouldn't want folks to unknowingly all start to download JDKs when it's likely that they have one already in a custom path. Would you agree there? If so we'd want to remove the line highlighted at the very top here from the docs @mike-solomon 🙏🏻 |
Yeah, I can agree in part that if the user is using custom locations that are unknown to Gradle's discovery mechanism -- especially in restrictive environments or environments where bandwidth is limited -- it can certainly be surprising. This is actually exactly the reason that Gradle dropped the auto download from being internally done and giving control to users via an API as part of the Gradle 8.0 release. Gradle's lookup mechanisms include system installs, SDKman, jenv, and a few others. Things like chocolatey and homebrew generally install into the system install locations, so those should be auto discovered without any problem. To me on a personal level, is a coin flip as to what to do. |
Also on the fence a bit 😅 good to hear common paths are at least handled; that should surprise fewer folks. Beyond that it's then perhaps most welcoming and lowering the bar to entry if we do automatically download or at least configure as needed for projects, especially seeing how today we use Java 17 for tests, but that might change to Java 21 at some point. Just not sure what changes we should make, so any help appreciated! :) |
So funny enough, it's actually already Java 21 due to the |
According to https://docs.openrewrite.org/reference/building-openrewrite-from-source Gradle should first auto-detect and if not found then download the missing JDKs:
But if I understand correctly, from Gradle version 8, the functionality to auto-download requires an additional configuration in the project settings: https://docs.gradle.org/8.6/userguide/toolchains.html#sec:provisioning
I couldn't find any related Toolchain download repositories in the project settings, so I assume this functionality won't work for OpenRewrite. Hence, either the documentation should be corrected or such configuration should be added to the project to allow auto-download.
What version of OpenRewrite are you using?
I am using main branch - commit
dd77eddabc9dbb0003f3b4be08673960ac19402b
How are you running OpenRewrite?
I am trying to build OpenRewrite from sources according to https://docs.openrewrite.org/reference/building-openrewrite-from-source
My environment:
Windows 10 Enterprise
Version 22H2
Installed on 06.10.2021
OS build 19045.3930
Experience Windows Feature Experience Pack 1000.19053.1000.0
Java "installations" (unpacked zips):
C:\jdk8u402-b06
C:\jdk-11.0.12+7
C:\jdk-17.0.8.1+1
Environment variables include:
What is the smallest, simplest way to reproduce the problem?
Match the environment and run:
What did you expect to see?
A successful build.
What did you see instead?
Are you interested in contributing a fix to OpenRewrite?
Yes, but I need to discuss the best solution for this issue.
Workaround
When using simple unzipped JDKs directly under
C:\
directory it looks like the Gradle also fails to auto-detect the installations.As a workaround I used Maven Toolchains configurations under
~/.m2/toolchains.xml
pointing to the unzipped JDKs:Maybe there is a better way to force Gradle to find the installations?
The text was updated successfully, but these errors were encountered: