2828import com .google .devtools .build .lib .analysis .RuleContext ;
2929import com .google .devtools .build .lib .analysis .Runfiles ;
3030import com .google .devtools .build .lib .analysis .RunfilesProvider ;
31+ import com .google .devtools .build .lib .analysis .TransitiveInfoCollection ;
3132import com .google .devtools .build .lib .collect .nestedset .NestedSetBuilder ;
3233import com .google .devtools .build .lib .syntax .Type ;
3334
@@ -37,9 +38,14 @@ public class ProtoLangToolchain implements RuleConfiguredTargetFactory {
3738 public ConfiguredTarget create (RuleContext ruleContext )
3839 throws InterruptedException , RuleErrorException , ActionConflictException {
3940 NestedSetBuilder <Artifact > blacklistedProtos = NestedSetBuilder .stableOrder ();
40- for (FileProvider protos :
41- ruleContext .getPrerequisites ("blacklisted_protos" , TARGET , FileProvider .class )) {
42- blacklistedProtos .addTransitive (protos .getFilesToBuild ());
41+ for (TransitiveInfoCollection protos :
42+ ruleContext .getPrerequisites ("blacklisted_protos" , TARGET )) {
43+ blacklistedProtos .addTransitive (protos .getProvider (FileProvider .class ).getFilesToBuild ());
44+ ProtoInfo protoInfo = protos .get (ProtoInfo .PROVIDER );
45+ // TODO(cushon): it would be nice to make this mandatory and stop adding files to build too
46+ if (protoInfo != null ) {
47+ blacklistedProtos .addAll (protoInfo .getDirectProtoSources ());
48+ }
4349 }
4450
4551 return new RuleConfiguredTargetBuilder (ruleContext )
0 commit comments