From b5daa06bd65f92c0b04fc52e6a2b550dc396e6a3 Mon Sep 17 00:00:00 2001 From: Geoff Mishkin Date: Wed, 8 May 2019 16:50:10 -0400 Subject: [PATCH] Portable classpath in stub template (#739) * Make class path work on Windows * Make sure class path gets quoted to escape semicolons --- scala/private/rule_impls.bzl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index fe3a536d3..d9f29cba0 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -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( @@ -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, @@ -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),