@@ -187,6 +187,18 @@ public static class Options extends OptionsBase {
187
187
help = "Only schedules extra_actions for top level targets." )
188
188
public boolean extraActionTopLevelOnly ;
189
189
190
+ @ Option (
191
+ name = "experimental_extra_action_top_level_only_with_aspects" ,
192
+ defaultValue = "true" ,
193
+ category = "experimental" ,
194
+ help =
195
+ "If true and --experimental_extra_action_top_level_only=true, will include actions "
196
+ + "from aspects injected by top-level rules. "
197
+ + "This is an escape hatch in case commit df9e5e16c370391098c4432779ad4d1c9dd693ca "
198
+ + "breaks something."
199
+ )
200
+ public boolean extraActionTopLevelOnlyWithAspects ;
201
+
190
202
@ Option (name = "version_window_for_dirty_node_gc" ,
191
203
defaultValue = "0" ,
192
204
category = "undocumented" ,
@@ -656,22 +668,26 @@ private NestedSet<ExtraArtifactSet> addExtraActionsFromTargets(
656
668
target .getProvider (ExtraActionArtifactsProvider .class );
657
669
if (provider != null ) {
658
670
if (viewOptions .extraActionTopLevelOnly ) {
659
- // Collect all aspect-classes that topLevel might inject.
660
- Set <AspectClass > aspectClasses = new HashSet <>();
661
- for (Attribute attr : target .getTarget ().getAssociatedRule ().getAttributes ()) {
662
- aspectClasses .addAll (attr .getAspectClasses ());
663
- }
664
-
665
- Iterable <Artifact > artifacts ;
666
- if (aspectClasses .isEmpty ()) {
667
- artifacts = provider .getExtraActionArtifacts ();
671
+ if (!viewOptions .extraActionTopLevelOnlyWithAspects ) {
672
+ builder .add (ExtraArtifactSet .of (target .getLabel (), provider .getExtraActionArtifacts ()));
668
673
} else {
669
- ImmutableList .Builder <Artifact > artifactBuilder = ImmutableList .builder ();
670
- artifactBuilder .addAll (provider .getExtraActionArtifacts ());
671
- artifactBuilder .addAll (filterTransitiveExtraActions (provider , aspectClasses ));
672
- artifacts = artifactBuilder .build ();
674
+ // Collect all aspect-classes that topLevel might inject.
675
+ Set <AspectClass > aspectClasses = new HashSet <>();
676
+ for (Attribute attr : target .getTarget ().getAssociatedRule ().getAttributes ()) {
677
+ aspectClasses .addAll (attr .getAspectClasses ());
678
+ }
679
+
680
+ Iterable <Artifact > artifacts ;
681
+ if (aspectClasses .isEmpty ()) {
682
+ artifacts = provider .getExtraActionArtifacts ();
683
+ } else {
684
+ ImmutableList .Builder <Artifact > artifactBuilder = ImmutableList .builder ();
685
+ artifactBuilder .addAll (provider .getExtraActionArtifacts ());
686
+ artifactBuilder .addAll (filterTransitiveExtraActions (provider , aspectClasses ));
687
+ artifacts = artifactBuilder .build ();
688
+ }
689
+ builder .add (ExtraArtifactSet .of (target .getLabel (), artifacts ));
673
690
}
674
- builder .add (ExtraArtifactSet .of (target .getLabel (), artifacts ));
675
691
} else {
676
692
builder .addTransitive (provider .getTransitiveExtraActionArtifacts ());
677
693
}
0 commit comments