I am working on a maven plugin. I seem to have a hard time figuring out, what would be a good way to get POM information from project in which you execute the MOJO ?
For
@Component
private MavenProject project;
also works (more succinctly and intuitively) if using the new maven-plugin-annotations
, which is the default for new mojos created from maven-archetype-plugin
.
EDIT (thanks to @bmargulies): although the @Component
Javadoc as of 3.2 suggests using it for MavenProject
, apparently that is deprecated and the suggestion is dropped as of 3.3; the idiom suggested by maven-plugin-tools-annotations
(as of 3.3) is something like this (both seem to work):
@Parameter(defaultValue="${project}", readonly=true, required=true)
private MavenProject project;