From a99112a3f254b215344183a0119bb1348b15acb5 Mon Sep 17 00:00:00 2001 From: Steven Parkes Date: Thu, 24 Mar 2016 19:57:49 -0700 Subject: [PATCH] strip remote workspace path from java resources --- .../google/devtools/build/lib/rules/java/JavaHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java index 75ba880025763c..4dac022eb974f6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHelper.java @@ -109,6 +109,12 @@ public static List tokenizeJavaOptions(Iterable inOpts) { public static PathFragment getJavaResourcePath( JavaSemantics semantics, RuleContext ruleContext, Artifact resource) { PathFragment rootRelativePath = resource.getRootRelativePath(); + + if (!resource.getOwner().getWorkspaceRoot().isEmpty()) { + PathFragment workspace = new PathFragment(resource.getOwner().getWorkspaceRoot()); + rootRelativePath = rootRelativePath.relativeTo(workspace); + } + if (!ruleContext.attributes().has("resource_strip_prefix", Type.STRING) || !ruleContext.attributes().isAttributeValueExplicitlySpecified("resource_strip_prefix")) { return semantics.getDefaultJavaResourcePath(rootRelativePath);