<@U021C96KUGJ>: Is there any way to obtain the abs...
# development
f
@ancient-vegetable-10556: Is there any way to obtain the absolute path to
JAVA_HOME
via
JdkEnvironment
?
a
Yes!
Give me ~5 mins
f
đź‘Ť
(context is letting BSP clients know where the relevant JDK is)
a
@fast-nail-55400 it lives in
__java_home
in the root of the sandbox
it worries me slightly that BSP clients want to know where the relevant JDK is, because it’s very much the point that we don’t expose the JDK
f
And that is a relative link which was tripping ip making a file URI out of it which needs absolute path.
It's optional in the protocol but unclear to me whether IntelliJ will index JDK when using BSP unless this is given.
Will try hard-coding path for now to see what IntelliJ does.
IntelliJ adds a new JDK to its list using the path provided over BSP. So technically users could also supply a configured-in-IntelliJ JDK.
__java_home
in the sandbox is a symlink to the Coursier JDK cache, correct?
a
Yes
And that jdk cache is a long-lived append-only cache
(sorry, missed this reply)
f
what would be the best way to resolve the absolute path on disk of that cache then?
a
hrrrrrrm
I’d say the easiest way would be to get
jdk_preparation_script
to spit out its
$PWD
Oh wait, nope
It would be to run the
java_home_command
that’s set up inside
jdk_rules
, but we do not expose that just yet
f
ok so I’ll need to expose that then
this is a low priority BSP change in any event. just good to have the background context for it.
a
I’d suggest pinging @witty-crayon-22786 to see how we’d expose that append-only cache directory directly, so that we control for future sandbox implementation changes
Another alternative would be to download the working JDK into a non-sandbox location for IDEs to use
which is probably the safest approach?
f
yeah and that would be consistent with discussion in https://github.com/pantsbuild/pants/issues/14562 regarding where to put compiled classfiles to expose them to the IDE
w
imo, it’s “ok” to leak a location inside of the cache out, by invoking a process that will render the output of
java-home
.
…as part of an API like this. probably not elsewhere.