JavaLibraryHelper: when collecting transitive source jars, look in the targets that were added using addDeps(), instead of looking in the "deps" attribute.
This is currently a no-op, because collectTransitiveJavaSourceJars() is only called if noProviders() hasn't been called, which never happens in the current code in Blaze.
--
MOS_MIGRATED_REVID=122985812
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java
index 969ce07..0be4319 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibraryHelper.java
@@ -19,7 +19,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
@@ -331,9 +330,11 @@
NestedSetBuilder<Artifact> transitiveJavaSourceJarBuilder =
NestedSetBuilder.<Artifact>stableOrder();
transitiveJavaSourceJarBuilder.addAll(sourceJars);
- for (JavaSourceJarsProvider other : ruleContext.getPrerequisites(
- "deps", Mode.TARGET, JavaSourceJarsProvider.class)) {
- transitiveJavaSourceJarBuilder.addTransitive(other.getTransitiveSourceJars());
+ for (TransitiveInfoCollection dep : deps) {
+ JavaSourceJarsProvider provider = dep.getProvider(JavaSourceJarsProvider.class);
+ if (provider != null) {
+ transitiveJavaSourceJarBuilder.addTransitive(provider.getTransitiveSourceJars());
+ }
}
return transitiveJavaSourceJarBuilder.build();
}