Skip to content

Commit

Permalink
Portable classpath in stub template (#739)
Browse files Browse the repository at this point in the history
* Make class path work on Windows

* Make sure class path gets quoted to escape semicolons
  • Loading branch information
gmishkin authored and johnynek committed May 8, 2019
1 parent cb6ba6f commit b5daa06
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scala/private/rule_impls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def _write_executable(ctx, rjars, main_class, jvm_flags, wrapper, use_jacoco):
)

if use_jacoco and _coverage_replacements_provider.is_enabled(ctx):
classpath = ":".join(
classpath = ctx.configuration.host_path_separator.join(
["${RUNPATH}%s" % (j.short_path) for j in rjars.to_list() + ctx.files._jacocorunner + ctx.files._lcov_merger],
)
jacoco_metadata_file = ctx.actions.declare_file(
Expand All @@ -618,7 +618,7 @@ def _write_executable(ctx, rjars, main_class, jvm_flags, wrapper, use_jacoco):
template = template,
output = ctx.outputs.executable,
substitutions = {
"%classpath%": classpath,
"%classpath%": "\"%s\"" % classpath,
"%javabin%": javabin,
"%jarbin%": _jar_path_based_on_java_bin(ctx),
"%jvm_flags%": jvm_flags,
Expand All @@ -637,14 +637,14 @@ def _write_executable(ctx, rjars, main_class, jvm_flags, wrapper, use_jacoco):
else:
# RUNPATH is defined here:
# https://github.com/bazelbuild/bazel/blob/0.4.5/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt#L227
classpath = ":".join(
classpath = ctx.configuration.host_path_separator.join(
["${RUNPATH}%s" % (j.short_path) for j in rjars.to_list()],
)
ctx.actions.expand_template(
template = template,
output = ctx.outputs.executable,
substitutions = {
"%classpath%": classpath,
"%classpath%": "\"%s\"" % classpath,
"%java_start_class%": main_class,
"%javabin%": javabin,
"%jarbin%": _jar_path_based_on_java_bin(ctx),
Expand Down

0 comments on commit b5daa06

Please sign in to comment.