Skip to content

Wire up @After annotation processing in maven-plugin-tools #12534

Description

@gnodet

Summary

The @After annotation (org.apache.maven.api.plugin.annotations.After, @since 4.0.0, @Experimental) exists in maven-api-core and the underlying Lifecycle.Link/Pointer model is already used internally by DefaultLifecycleRegistry to define the tree-based lifecycle. However, there is no processing pipeline that makes @After usable by plugin authors — it compiles but has zero runtime effect.

Missing pieces

1. Plugin descriptor model (plugin.mdo)

MojoDescriptor has no fields for after/link/pointer. Needs new elements to represent the ordering constraints declared by @After.

2. maven-plugin-tools annotation scanner

The annotation processor that generates META-INF/maven/plugin.xml from @Mojo/@Parameter annotations does not read @After at all. Needs to extract phase(), type(), and scope() from @After annotations on mojo classes and emit them into the descriptor.

3. Maven core plugin executor

Needs to read the new descriptor fields and create proper Lifecycle.Link entries (Kind.AFTER with the appropriate Pointer subtype) when loading plugin descriptors, so the concurrent builder can schedule mojos correctly.

Context

The internal lifecycle definition already uses the exact same model:

// DefaultLifecycleRegistry.java
phase(COMPILE, after(SOURCES), dependencies(SCOPE_COMPILE, READY)),
phase(READY, after(COMPILE), after(RESOURCES)),
phase(TEST_COMPILE, after(TEST_SOURCES), after(READY),
                    dependencies(SCOPE_TEST_ONLY, READY)),

The intent of @After is to let plugin mojos declare the same ordering constraints:

@After(phase = "compile", type = After.Type.PROJECT)
@After(phase = "ready", type = After.Type.DEPENDENCIES, scope = "compile")
@Mojo(name = "my-goal")
public class MyMojo implements Mojo { ... }

This would be particularly powerful with the concurrent builder — a mojo could express precise ordering constraints without being pinned to a single fixed phase.

Relevant source files

  • After.javamaven-api-core annotation definition
  • Lifecycle.javaLink, Pointer, PhasePointer, DependenciesPointer, ChildrenPointer
  • Lifecycles.javaafter(), dependencies(), children() helper methods
  • DefaultLifecycleRegistry.java — tree-based lifecycle definition using those helpers
  • plugin.mdo — plugin descriptor model (in maven-plugin-tools)

No plugin currently uses @After — searched all major Apache Maven plugins (compiler, surefire, dependency, javadoc, resources, jar, install, deploy, site, clean, shade, assembly, war, ear, enforcer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions