From beccb9bfee87fb4869b5c00abd9400ebaf647bf0 Mon Sep 17 00:00:00 2001 From: Lukacs Berki Date: Tue, 6 Oct 2015 11:16:31 +0000 Subject: Implement the prefix stripping for Java resources. This CL sure works, but it leaves a few call sites for JavaSemantics#getJavaResourcePath() which make me uncomfortable. RELNOTES: Java rules now support a resource_strip_prefix attribute that allows the removal of path prefixes from Java resources. -- MOS_MIGRATED_REVID=104748537 --- .../lib/bazel/rules/java/BazelJavaRuleClasses.java | 12 +++++++++ .../lib/bazel/rules/java/BazelJavaSemantics.java | 2 +- .../build/lib/rules/android/AndroidCommon.java | 9 +------ .../lib/rules/java/BaseJavaCompilationHelper.java | 17 ++++++------- .../devtools/build/lib/rules/java/JavaBinary.java | 2 +- .../devtools/build/lib/rules/java/JavaCommon.java | 6 ++++- .../lib/rules/java/JavaCompilationHelper.java | 9 ++++++- .../build/lib/rules/java/JavaCompileAction.java | 26 ++++++++++--------- .../devtools/build/lib/rules/java/JavaHelper.java | 22 ++++++++++++++++ .../build/lib/rules/java/JavaSemantics.java | 4 ++- .../lib/rules/java/JavaSourceInfoProvider.java | 11 +------- .../build/lib/rules/java/JavaTargetAttributes.java | 29 +++++++++++----------- .../bazel/rules/java/BazelJavaSemanticsTest.java | 10 ++++---- 13 files changed, 95 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java index 5cd576f567..4925cb7fcd 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java @@ -223,6 +223,18 @@ public class BazelJavaRuleClasses { */ .add(attr("resources", LABEL_LIST).orderIndependent() .allowedFileTypes(FileTypeSet.ANY_FILE)) + /* + The path prefix to strip from Java resources. + ${SYNOPSIS} +

+ If specified, this path prefix is stripped from every file in the resources + attribute. It is an error for a resource file not to be under this directory. If not + specified (the default), the path of resource file is determined according to the same + logic as the Java package of source files. For example, a source file at + stuff/java/foo/bar/a.txt will be located at foo/bar/a.txt. +

+ */ + .add(attr("resource_strip_prefix", STRING)) /* Java compiler plugins to run at compile-time. ${SYNOPSIS} 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 8208ee98ee..d702dd9ede 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 @@ -295,7 +295,7 @@ public class BazelJavaSemantics implements JavaSemantics { } @Override - public PathFragment getJavaResourcePath(PathFragment path) { + public PathFragment getDefaultJavaResourcePath(PathFragment path) { // Look for src/.../resources to match Maven repository structure. for (int i = 0; i < path.segmentCount() - 2; ++i) { if (path.getSegment(i).equals("src") && path.getSegment(i + 2).equals("resources")) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java index 598d121146..59f7ac7770 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java @@ -19,7 +19,6 @@ import static com.google.devtools.build.lib.analysis.config.BuildConfiguration.S import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ResourceSet; import com.google.devtools.build.lib.analysis.AnalysisUtils; @@ -67,9 +66,7 @@ import com.google.devtools.build.lib.vfs.PathFragment; import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import javax.annotation.Nullable; @@ -471,10 +468,6 @@ public class AndroidCommon { JackCompilationHelper initJack(JavaTargetAttributes attributes, JavaSemantics javaSemantics) throws InterruptedException { - Map resourcesMap = new LinkedHashMap<>(); - for (Artifact resource : attributes.getResources()) { - resourcesMap.put(javaSemantics.getJavaResourcePath(resource.getRootRelativePath()), resource); - } AndroidSdkProvider sdk = AndroidSdkProvider.fromRuleContext(ruleContext); return new JackCompilationHelper.Builder() // blaze infrastructure @@ -488,7 +481,7 @@ public class AndroidCommon { .addJavaSources(attributes.getSourceFiles()) .addSourceJars(attributes.getSourceJars()) .addCompiledJars(attributes.getJarFiles()) - .addResources(ImmutableMap.copyOf(resourcesMap)) + .addResources(attributes.getResources()) .addProcessorNames(attributes.getProcessorNames()) .addProcessorClasspathJars(attributes.getProcessorPath()) .addExports(JavaCommon.getExports(ruleContext)) diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java index 6a325d44b2..85573f8e3d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/BaseJavaCompilationHelper.java @@ -32,6 +32,7 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.Collection; +import java.util.Map; /** * A helper class for compiling Java targets. This helper does not rely on the @@ -66,16 +67,15 @@ public class BaseJavaCompilationHelper { "--exclude_build_data", "--warn_duplicate_resources"); - private CommandLine sourceJarCommandLine(JavaSemantics semantics, Artifact outputJar, - Iterable resources, Iterable resourceJars) { + private CommandLine sourceJarCommandLine(Artifact outputJar, + Map resources, Iterable resourceJars) { CustomCommandLine.Builder args = CustomCommandLine.builder(); args.addExecPath("--output", outputJar); args.add(SOURCE_JAR_COMMAND_LINE_ARGS); args.addExecPaths("--sources", resourceJars); args.add("--resources"); - for (Artifact resource : resources) { - args.addPaths("%s:%s", resource.getExecPath(), - semantics.getJavaResourcePath(resource.getRootRelativePath())); + for (Map.Entry resource : resources.entrySet()) { + args.addPaths("%s:%s", resource.getValue().getExecPath(), resource.getKey()); } return args.build(); } @@ -83,23 +83,22 @@ public class BaseJavaCompilationHelper { /** * Creates an Action that packages files into a Jar file. * - * @param semantics delegate semantics for java. * @param resources the resources to put into the Jar. * @param resourceJars the resource jars to merge into the jar * @param outputJar the Jar to create */ - public void createSourceJarAction(JavaSemantics semantics, Collection resources, + public void createSourceJarAction(Map resources, Collection resourceJars, Artifact outputJar) { ruleContext.registerAction(new SpawnAction.Builder() .addOutput(outputJar) - .addInputs(resources) + .addInputs(resources.values()) .addInputs(resourceJars) .addTransitiveInputs(JavaCompilationHelper.getHostJavabaseInputs(ruleContext)) .setJarExecutable( ruleContext.getHostConfiguration().getFragment(Jvm.class).getJavaExecutable(), ruleContext.getPrerequisiteArtifact("$singlejar", Mode.HOST), ImmutableList.of("-client", SINGLEJAR_MAX_MEMORY)) - .setCommandLine(sourceJarCommandLine(semantics, outputJar, resources, resourceJars)) + .setCommandLine(sourceJarCommandLine(outputJar, resources, resourceJars)) .useParameterFile(ParameterFileType.SHELL_QUOTED) .setProgressMessage("Building source jar " + outputJar.prettyPrint()) .setMnemonic("JavaSourceJar") diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java index 84efb5de3b..2855ff110a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java @@ -205,7 +205,7 @@ public class JavaBinary implements RuleConfiguredTargetFactory { // TODO(bazel-team): if (getOptions().sourceJars) then make this a dummy prerequisite for the // DeployArchiveAction ? Needs a few changes there as we can't pass inputs - helper.createSourceJarAction(semantics, ImmutableList.of(), + helper.createSourceJarAction(ImmutableMap.of(), transitiveSourceJars.toCollection(), ruleContext.getImplicitOutputArtifact(JavaSemantics.JAVA_BINARY_DEPLOY_SOURCE_JAR)); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java index 8ffd0f176b..fd9825f32b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java @@ -518,7 +518,11 @@ public class JavaCommon { ruleContext.attributeError("deps", "deps not allowed without srcs; move to runtime_deps?"); } - javaTargetAttributes.addResources(semantics.collectResources(ruleContext)); + for (Artifact resource : semantics.collectResources(ruleContext)) { + javaTargetAttributes.addResource( + JavaHelper.getJavaResourcePath(semantics, ruleContext, resource), resource); + } + addPlugins(javaTargetAttributes); javaTargetAttributes.setRuleKind(ruleContext.getRule().getRuleClass()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java index 29d3b70ce5..2bb56e9580 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java @@ -34,10 +34,13 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.rules.java.JavaCompilationArgs.ClasspathType; import com.google.devtools.build.lib.rules.java.JavaConfiguration.JavaClasspathMode; import com.google.devtools.build.lib.vfs.FileSystemUtils; +import com.google.devtools.build.lib.vfs.PathFragment; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Nullable; @@ -344,7 +347,11 @@ public class JavaCompilationHelper extends BaseJavaCompilationHelper { if (gensrcJar != null) { resourceJars.add(gensrcJar); } - createSourceJarAction(semantics, attributes.getSourceFiles(), resourceJars, outputJar); + Map resources = new LinkedHashMap<>(); + for (Artifact sourceFile : attributes.getSourceFiles()) { + resources.put(semantics.getDefaultJavaResourcePath(sourceFile.getRootRelativePath()), sourceFile); + } + createSourceJarAction(resources, resourceJars, outputJar); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java index d8debf3efe..72ab4fb934 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java @@ -63,8 +63,10 @@ import com.google.devtools.build.lib.vfs.PathFragment; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; /** * Action that represents a Java compilation. @@ -180,7 +182,7 @@ public class JavaCompileAction extends AbstractAction { Iterable instrumentationJars, List processorNames, Collection messages, - Collection resources, + Map resources, Collection classpathResources, Collection sourceJars, Collection sourceFiles, @@ -192,7 +194,7 @@ public class JavaCompileAction extends AbstractAction { .addTransitive(classpathEntries) .addAll(processorPath) .addAll(messages) - .addAll(resources) + .addAll(resources.values()) .addAll(classpathResources) .addAll(sourceJars) .addAll(sourceFiles) @@ -213,7 +215,7 @@ public class JavaCompileAction extends AbstractAction { this.processorPath = ImmutableList.copyOf(processorPath); this.processorNames = ImmutableList.copyOf(processorNames); this.messages = ImmutableList.copyOf(messages); - this.resources = ImmutableList.copyOf(resources); + this.resources = ImmutableList.copyOf(resources.values()); this.classpathResources = ImmutableList.copyOf(classpathResources); this.sourceJars = ImmutableList.copyOf(sourceJars); this.sourceFiles = ImmutableList.copyOf(sourceFiles); @@ -462,7 +464,7 @@ public class JavaCompileAction extends AbstractAction { List processorPath, List processorNames, Collection messages, - Collection resources, + Map resources, Collection classpathResources, Collection sourceJars, Collection sourceFiles, @@ -539,14 +541,15 @@ public class JavaCompileAction extends AbstractAction { if (!messages.isEmpty()) { result.add("--messages"); for (Artifact message : messages) { - addAsResourcePrefixedExecPath(semantics, message, result); + addAsResourcePrefixedExecPath( + semantics.getDefaultJavaResourcePath(message.getRootRelativePath()), message, result); } } if (!resources.isEmpty()) { result.add("--resources"); - for (Artifact resource : resources) { - addAsResourcePrefixedExecPath(semantics, resource, result); + for (Map.Entry resource : resources.entrySet()) { + addAsResourcePrefixedExecPath(resource.getKey(), resource.getValue(), result); } } @@ -604,10 +607,9 @@ public class JavaCompileAction extends AbstractAction { return result; } - private static void addAsResourcePrefixedExecPath(JavaSemantics semantics, + private static void addAsResourcePrefixedExecPath(PathFragment resourcePath, Artifact artifact, CustomCommandLine.Builder builder) { PathFragment execPath = artifact.getExecPath(); - PathFragment resourcePath = semantics.getJavaResourcePath(artifact.getRootRelativePath()); if (execPath.equals(resourcePath)) { builder.addPaths(":%s", resourcePath); } else { @@ -734,7 +736,7 @@ public class JavaCompileAction extends AbstractAction { private Artifact metadata; private final Collection sourceFiles = new ArrayList<>(); private final Collection sourceJars = new ArrayList<>(); - private final Collection resources = new ArrayList<>(); + private final Map resources = new LinkedHashMap<>(); private final Collection classpathResources = new ArrayList<>(); private final Collection translations = new LinkedHashSet<>(); private BuildConfiguration.StrictDepsMode strictJavaDeps = @@ -966,8 +968,8 @@ public class JavaCompileAction extends AbstractAction { return this; } - public Builder addResources(Collection resources) { - this.resources.addAll(resources); + public Builder addResources(Map resources) { + this.resources.putAll(resources); return this; } 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 1c84d7342c..8a702e3cc1 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 @@ -19,6 +19,8 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.shell.ShellUtils; +import com.google.devtools.build.lib.syntax.Type; +import com.google.devtools.build.lib.vfs.PathFragment; import java.util.ArrayList; import java.util.List; @@ -101,4 +103,24 @@ public abstract class JavaHelper { } return result; } + + public static PathFragment getJavaResourcePath( + JavaSemantics semantics, RuleContext ruleContext, Artifact resource) { + PathFragment rootRelativePath = resource.getRootRelativePath(); + if (!ruleContext.attributes().has("resource_strip_prefix", Type.STRING) + || !ruleContext.attributes().isAttributeValueExplicitlySpecified("resource_strip_prefix")) { + return semantics.getDefaultJavaResourcePath(rootRelativePath); + } + + PathFragment prefix = new PathFragment( + ruleContext.attributes().get("resource_strip_prefix", Type.STRING)); + + if (!rootRelativePath.startsWith(prefix)) { + ruleContext.attributeError("resource_strip_prefix", String.format( + "Resource file '%s' is not under the specified prefix to strip", rootRelativePath)); + return rootRelativePath; + } + + return rootRelativePath.relativeTo(prefix); + } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java index a75b414ef1..ba94706a4b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java @@ -360,12 +360,14 @@ public interface JavaSemantics { * Takes the path of a Java resource and tries to determine the Java * root relative path of the resource. * + *

This is only used if the Java rule doesn't have a {@code resource_strip_prefix} attribute. + * * @param path the root relative path of the resource. * @return the Java root relative path of the resource of the root * relative path of the resource if no Java root relative path can be * determined. */ - PathFragment getJavaResourcePath(PathFragment path); + PathFragment getDefaultJavaResourcePath(PathFragment path); /** * @return a list of extra arguments to appends to the runfiles support. diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceInfoProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceInfoProvider.java index 33b488147a..40794bca92 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceInfoProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSourceInfoProvider.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.Collection; -import java.util.LinkedHashMap; import java.util.Map; /** @@ -117,19 +116,11 @@ public final class JavaSourceInfoProvider implements TransitiveInfoProvider { */ public static JavaSourceInfoProvider fromJavaTargetAttributes( JavaTargetAttributes attributes, JavaSemantics semantics) { - Map resourcesMap = new LinkedHashMap<>(); - for (Artifact resource : attributes.getResources()) { - /* The resources are passed in iteration order to the javac command line; - * javac chooses the last resource with a given path to make it into the jar. - * So too shall we overwrite the values that have come before and end up with the last of the - * colliding resources. */ - resourcesMap.put(semantics.getJavaResourcePath(resource.getRootRelativePath()), resource); - } return new Builder() .setSourceFiles(attributes.getSourceFiles()) .setSourceJars(attributes.getSourceJars()) .setJarFiles(attributes.getJarFiles()) - .setResources(ImmutableMap.copyOf(resourcesMap)) + .setResources(attributes.getResources()) .setProcessorNames(attributes.getProcessorNames()) .setProcessorPath(attributes.getProcessorPath()) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaTargetAttributes.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaTargetAttributes.java index 1e3cb2e86c..ed4b49dc2a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaTargetAttributes.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaTargetAttributes.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.java; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; @@ -25,11 +26,14 @@ import com.google.devtools.build.lib.collect.IterablesChain; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.rules.cpp.CppFileTypes; +import com.google.devtools.build.lib.vfs.PathFragment; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -71,7 +75,7 @@ public class JavaTargetAttributes { private final Set processorPath = new LinkedHashSet<>(); private final Set processorNames = new LinkedHashSet<>(); - private final List resources = new ArrayList<>(); + private final Map resources = new LinkedHashMap<>(); private final List messages = new ArrayList<>(); private final List instrumentationMetadata = new ArrayList<>(); private final List sourceJars = new ArrayList<>(); @@ -108,7 +112,8 @@ public class JavaTargetAttributes { sourceJars.add(srcArtifact); } else if (JavaSemantics.PROPERTIES.matches(srcFilename)) { // output files of the message compiler - resources.add(srcArtifact); + resources.put( + semantics.getDefaultJavaResourcePath(srcArtifact.getRootRelativePath()), srcArtifact); } else if (JavaSemantics.JAVA_SOURCE.matches(srcFilename)) { sourceFiles.add(srcArtifact); } else { @@ -300,15 +305,9 @@ public class JavaTargetAttributes { return this; } - public Builder addResources(Collection resources) { + public Builder addResource(PathFragment execPath, Artifact resource) { Preconditions.checkArgument(!built); - this.resources.addAll(resources); - return this; - } - - public Builder addResource(Artifact resource) { - Preconditions.checkArgument(!built); - resources.add(resource); + this.resources.put(execPath, resource); return this; } @@ -404,7 +403,7 @@ public class JavaTargetAttributes { private final ImmutableSet processorPath; private final ImmutableSet processorNames; - private final ImmutableList resources; + private final ImmutableMap resources; private final ImmutableList messages; private final ImmutableList sourceJars; @@ -431,7 +430,7 @@ public class JavaTargetAttributes { List nativeLibraries, Set processorPath, Set processorNames, - List resources, + Map resources, List messages, List sourceJars, List classPathResources, @@ -450,7 +449,7 @@ public class JavaTargetAttributes { this.nativeLibraries = ImmutableList.copyOf(nativeLibraries); this.processorPath = ImmutableSet.copyOf(processorPath); this.processorNames = ImmutableSet.copyOf(processorNames); - this.resources = ImmutableList.copyOf(resources); + this.resources = ImmutableMap.copyOf(resources); this.messages = ImmutableList.copyOf(messages); this.sourceJars = ImmutableList.copyOf(sourceJars); this.classPathResources = ImmutableList.copyOf(classPathResources); @@ -474,7 +473,7 @@ public class JavaTargetAttributes { return sourceJars; } - public Collection getResources() { + public Map getResources() { return resources; } @@ -577,7 +576,7 @@ public class JavaTargetAttributes { if (includeClasspath) { inputs.add(ImmutableList.copyOf(getRuntimeClassPathForArchive())); } - inputs.add(getResources()); + inputs.add(ImmutableList.copyOf(getResources().values())); inputs.add(getClassPathResources()); return inputs.build(); } diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemanticsTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemanticsTest.java index e74f1ca751..529053b42e 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemanticsTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemanticsTest.java @@ -31,14 +31,14 @@ public class BazelJavaSemanticsTest { public void testFindingResources() { BazelJavaSemantics semantics = BazelJavaSemantics.INSTANCE; assertEquals(PathFragment.EMPTY_FRAGMENT, - semantics.getJavaResourcePath(new PathFragment("x/y/src/main/resources"))); + semantics.getDefaultJavaResourcePath(new PathFragment("x/y/src/main/resources"))); assertEquals(new PathFragment("foo"), - semantics.getJavaResourcePath(new PathFragment("x/y/src/main/resources/foo"))); + semantics.getDefaultJavaResourcePath(new PathFragment("x/y/src/main/resources/foo"))); assertEquals(new PathFragment("foo"), - semantics.getJavaResourcePath(new PathFragment("java/x/y/src/main/resources/foo"))); + semantics.getDefaultJavaResourcePath(new PathFragment("java/x/y/src/main/resources/foo"))); assertEquals(new PathFragment("foo/java/bar"), - semantics.getJavaResourcePath(new PathFragment("java/foo/java/bar"))); + semantics.getDefaultJavaResourcePath(new PathFragment("java/foo/java/bar"))); assertEquals(new PathFragment("foo/java/bar"), - semantics.getJavaResourcePath(new PathFragment("javatests/foo/java/bar"))); + semantics.getDefaultJavaResourcePath(new PathFragment("javatests/foo/java/bar"))); } } -- cgit v1.2.3