aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
index b301161088..bfccae39eb 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java
@@ -154,6 +154,11 @@ public class BazelJavaSemantics implements JavaSemantics {
BuildConfiguration config = ruleContext.getConfiguration();
List<Substitution> arguments = new ArrayList<>();
+ String workspacePrefix = ruleContext.getWorkspaceName();
+ if (!workspacePrefix.isEmpty()) {
+ workspacePrefix += "/";
+ }
+ arguments.add(Substitution.of("%workspace_prefix%", workspacePrefix));
arguments.add(Substitution.of("%javabin%", javaExecutable));
arguments.add(Substitution.of("%needs_runfiles%",
config.getFragment(Jvm.class).getJavaExecutable().isAbsolute() ? "0" : "1"));
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
index a17246f81d..ff7202499a 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
@@ -158,7 +158,7 @@ if [[ "$SINGLEJAR" == 1 ]]; then
|| die "Option --singlejar was passed, but %s does not exist.\n (You may need to build it explicitly.)" "$CLASSPATH"
else
# Create the shortest classpath we can, by making it relative if possible.
- RUNPATH="${JAVA_RUNFILES}/"
+ RUNPATH="${JAVA_RUNFILES}/%workspace_prefix%"
RUNPATH="${RUNPATH#$PWD/}"
CLASSPATH=%classpath%
fi