@@ -187,6 +187,18 @@ public static class Options extends OptionsBase {
187187 help = "Only schedules extra_actions for top level targets." )
188188 public boolean extraActionTopLevelOnly ;
189189
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+
190202 @ Option (name = "version_window_for_dirty_node_gc" ,
191203 defaultValue = "0" ,
192204 category = "undocumented" ,
@@ -656,22 +668,26 @@ private NestedSet<ExtraArtifactSet> addExtraActionsFromTargets(
656668 target .getProvider (ExtraActionArtifactsProvider .class );
657669 if (provider != null ) {
658670 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 ()));
668673 } 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 ));
673690 }
674- builder .add (ExtraArtifactSet .of (target .getLabel (), artifacts ));
675691 } else {
676692 builder .addTransitive (provider .getTransitiveExtraActionArtifacts ());
677693 }
0 commit comments