Skip to content

Support Maven Plugin annotations in ExcludedFieldAnnotations #1319

@ascopes

Description

@ascopes

Apache Maven's plugin API runs on top of Plexus and Google Guice via Eclipse Sisu to provide dependency injection.

The org.apache.maven.plugins.annotations.Parameter annotation is a special annotation that shares some semantics with javax.inject.Inject, in that it will be populated by dependency injection.

See https://maven.apache.org/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Parameter.html.

Whilst more complex configuration could be provided, at a bare minimum, it is safe to assume that anything annotated with this should be treated as being dynamically initialized if and only if the outer class implements Mojo (or extends a class implementing that interface, such as AbstractMojo).

A rough workaround right now is to specify the class in -XepOpt:NullAway:ExcludedFieldAnnotations=org.apache.maven.plugins.annotations.Parameter, but it would be nice for potential first-class support as described above, as it will allow encouraging the use of null-safety annotations within Maven plugins correctly, which in turn will encourage the development of more robust build tooling in the Java community.

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