Based on the documentation and mailing threads I have seen 3 ways to inject the maven project into my mojo:
/**
* Project instance
*
* @parameter default-value="${project}"
* @required
* @readonly
*/
private MavenProject project;
@Component
private MavenProject project;
@Parameter( expression = "${project}" )
private MavenProject project;
But regardless of which one of these I choose, when I run the unit test based on the example I found in maven docs, project is always null.
public void testMojoGoal() throws Exception {
File testPom = new File(getBasedir(),
"src/test/resources/unit/basic-test/sample-sh-project-config.xml");
ShunitResourcesMojo mojo = (ShunitResourcesMojo) lookupMojo("prepare",testPom);
assertNotNull(mojo);
mojo.execute();
}
mojo execute contains (and fails on)
Validate.notNull(project);