aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Michael Staib <mstaib@google.com>2016-02-04 20:18:48 +0000
committerGravatar David Chen <dzc@google.com>2016-02-05 00:45:32 +0000
commitd7eae80a50de94c8d3a43493f39b91e411754e82 (patch)
tree2bd18307e024d80b6cd811d3bd9f6e5520b8153c /src/main
parentea16e10b71da3797c22ec8fbe30970dae90e597c (diff)
Enable ProguardLibrary's dependency set to be controlled by a calling rule.
This permits rules using ProguardLibrary to modify the attributes being read. -- MOS_MIGRATED_REVID=113876253
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/ProguardLibrary.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/ProguardLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/ProguardLibrary.java
index f7e7f6cee7..1f92aac2db 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/ProguardLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/ProguardLibrary.java
@@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.java;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.FilesToRunProvider;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
@@ -57,9 +58,17 @@ public final class ProguardLibrary {
* Collects the validated proguard specs exported by this rule and its dependencies.
*/
public NestedSet<Artifact> collectProguardSpecs() {
+ return collectProguardSpecs(DEPENDENCY_ATTRIBUTES);
+ }
+
+ /**
+ * Collects the validated proguard specs exported by this rule and its dependencies through the
+ * given attributes.
+ */
+ public NestedSet<Artifact> collectProguardSpecs(Multimap<Mode, String> attributes) {
NestedSetBuilder<Artifact> specsBuilder = NestedSetBuilder.naiveLinkOrder();
- for (Entry<Mode, String> attribute : DEPENDENCY_ATTRIBUTES.entries()) {
+ for (Entry<Mode, String> attribute : attributes.entries()) {
specsBuilder.addTransitive(
collectProguardSpecsFromAttribute(attribute.getValue(), attribute.getKey()));
}
@@ -88,10 +97,11 @@ public final class ProguardLibrary {
}
/**
- * Collects the proguard specs exported by dependencies on the given LABEL_LIST attribute.
+ * Collects the proguard specs exported by dependencies on the given LABEL_LIST/LABEL attribute.
*/
private NestedSet<Artifact> collectProguardSpecsFromAttribute(String attribute, Mode mode) {
- if (!ruleContext.getRule().isAttrDefined(attribute, BuildType.LABEL_LIST)) {
+ if (!(ruleContext.getRule().isAttrDefined(attribute, BuildType.LABEL_LIST)
+ || ruleContext.getRule().isAttrDefined(attribute, BuildType.LABEL))) {
return NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER);
}
NestedSetBuilder<Artifact> dependencySpecsBuilder = NestedSetBuilder.naiveLinkOrder();