-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Depending on embedded JDK #445
Comments
Looks like it's actually possible to use the downloaded JDK (not embedded one, since the embedded one is minimal enough to run Bazel, and probably not other Java applications) to execute Coursier, but I just haven't got to doing this yet. Would you wanna take a stab at this and submit a PR? |
Sure, I'll give it a try soon.
Yeah, sorry, by "embedded" I meant the downloaded JDK, not the embedded JRE. So from now on, I will refer to the downloaded JDK as the "remote JDK", because that's how it's called in the bazel_tools workspace. |
Update: It would be so easy to just use
Could it possibly be available? Probably, but not at this moment. I guess Bazel itself would have to change the way toolchains are created. It's another story for another time. So are there any other possibilities? To an extent. This issue came up in other Bazel ecosystems too. See this issue and this PR from
Option 1 is ok if you know the path to the tool you want to use. That's fine if you want to use your local tool, but unsuitable for remote tools (as in remote JDK). So, as I understand (and I might be wrong), the only way our goal can be achieved is for the remote JDK repository to expose the So I think I will leave it like that for now (unless someone points out that I'm wrong and it is possible - in that case I would willingly come back to it). I'm sure this issue will come up in the future, because fully hermetic Java builds are kind of desired, I guess. So that's just my analysis of the situation and some thoughts, maybe it will be useful. |
Thank you for taking the time to look into this, @spietras. It sounds like there's a usability gap between toolchains and repository rules, and the current API is not sufficient to express such a relationship. I think that the approach to expose |
Also reported here, with a repro example: #450 |
Just hit this as well... Really need a better story around toolchains and repository rules
|
I just ran into this again, and the solution linked above from @brentleyjones is really nice: Just add to
|
Even better would be a way to make |
Pinging since I still run into this regularly. |
@alexeagle, if you set the |
ooh thanks @shs96c - I imagine you're referring to https://github.com/bazel-contrib/rules_jvm_external/blob/master/docs/api.md#maven_install-resolver ? |
You'll need to use a lock file --- that's a requirement of the maven resolver. To bootstrap, this can be empty file. Unless your list of |
As far as I understand, Bazel by default provides an embedded JDK (or at least some rules to get it), so we don't have to have one locally.
rules_jvm_external
use Coursier, which is invoked by runningjava
:https://github.com/bazelbuild/rules_jvm_external/blob/aed0eb3747682e64611bf98bb1ca590a44b470de/coursier.bzl#L109-L129
This assumes java is available at
JAVA_HOME
, which is unset with no local JDK. If I understand correctly Bazel setsJAVABASE
to the location of the embedded JDK.So is it possible to use the embedded JDK with
rules_jvm_external
? Maybe it is possible now and I am missing something? And if it's not currently possible, wouldn't it be sufficient to just check ifJAVABASE
is set too? I guess the order of checking is important because someone can have a local JDK, while still wanting to use the embedded one.For now, a cheap workaround is to just set
JAVA_HOME
relatively, knowing that bothmaven
andjdk
are in theexternal
workspace. I can confirm that adding this line:to the
.bazelrc
file works and the embedded JDK is used.The text was updated successfully, but these errors were encountered: