Skip to content

Wire up @After annotation scanning in the annotation-based descriptor extractor - #1137

Open
gnodet wants to merge 1 commit into
masterfrom
wire-up-after-annotation-scanning-in-maven-plugin
Open

Wire up @After annotation scanning in the annotation-based descriptor extractor#1137
gnodet wants to merge 1 commit into
masterfrom
wire-up-after-annotation-scanning-in-maven-plugin

Conversation

@gnodet

@gnodet gnodet commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Register @After / @Afters (v4 API) in CLASS_LEVEL_ANNOTATIONS so the ASM scanner picks them up
  • Add AfterAnnotationContent datamodel class and List<AfterAnnotationContent> field on MojoAnnotatedClass
  • Enhance MojoAnnotationVisitor to track nested annotation visitors (needed to unpack the @Afters repeatable container)
  • Process single @After and @Afters container in DefaultMojoAnnotationsScanner.analyzeVisitors()
  • Walk the class hierarchy collecting @After annotations and map them to ExtendedMojoDescriptor.AfterLink in JavaAnnotationsMojoDescriptorExtractor.toMojoDescriptors()
  • Emit <afterLinks>/<afterLink> elements in the v4 plugin descriptor via PluginDescriptorFilesGenerator

Complements apache/maven#12535 which adds the model (AfterLink in plugin.mdo), runtime processing (BuildPlanExecutor.applyAfterLinks), @Repeatable support on @After, and an IT that currently hand-crafts the descriptor because the scanner did not exist yet.

Test plan

🤖 Generated with Claude Code

… extractor

The v4 API @after annotation (and its @repeatable container @afters)
was not recognized by the annotation scanner, so plugins using @after
had to hand-craft the <afterLink> descriptor entries.  This commit adds
end-to-end support:

- MojoAnnotationsScanner: register @after / @afters in CLASS_LEVEL_ANNOTATIONS
- AfterAnnotationContent: new datamodel POJO holding phase/type/scope
- MojoAnnotatedClass: add List<AfterAnnotationContent> field
- MojoAnnotationVisitor: track nested annotation visitors returned from
  visitAnnotation() and array sub-visitors from visitArray(), so the
  @afters repeatable container can be unpacked
- DefaultMojoAnnotationsScanner.analyzeVisitors(): extract single @after
  and @afters container into AfterAnnotationContent objects
- ExtendedMojoDescriptor: add AfterLink inner class and addAfterLink()
- JavaAnnotationsMojoDescriptorExtractor.toMojoDescriptors(): walk the
  class hierarchy collecting @after annotations and map them to AfterLink
- PluginDescriptorFilesGenerator: emit <afterLinks>/<afterLink> elements
  in the v4 plugin descriptor

Complements apache/maven#12535 which adds the model (AfterLink), runtime
processing (BuildPlanExecutor.applyAfterLinks), and an IT that currently
hand-crafts the descriptor.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet marked this pull request as ready for review July 26, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant