bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
364 stars 275 forks source link

For Windows: Fix to enable scala_test and scala_binary outputs to be executed on Windows #1502

Closed crt-31 closed 1 year ago

crt-31 commented 1 year ago

Description

For Windows, this PR fixes issue where outputs of scala_test and scala_binary are failing when ran with 'bazel run' and 'bazel test'. When trying to do run or test, Bazel shows error like:

LAUNCHER ERROR: rlocation failed on “external\localjdk\bin\java.exe not found in MANIFEST”.

The Fix: On Windows, Bazel’s Java Launcher was being passed paths in the wrong ‘form’. The launcher expects rpathlocation form for some paths and rootpath form for others. Fix is to pass the right forms of the paths to the LauncherFileWriter which in turn passes correct paths into the Launcher.

Motivation

scala_test and scala_binary should work properly on Windows

Seems to have been caused by #1313 Should also fix #1497

Test/Reproduction

The following can be used as a demonstration test on windows (will fail before this PR):

bazel test //test/RunScalaBinary --enable_runfiles --extra_toolchains=//scala:minimal_direct_source_deps

Note that: 'bazel test' requires --enable_runfiles to be set on Windows. Also note that many other tests fail in Windows, but fixes for those are for a separate PR.

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.