Annotation Interface MojoParameter
@Target({METHOD,PARAMETER})
@Retention(RUNTIME)
@Inherited
@Repeatable(MojoParameters.class)
public @interface MojoParameter
Specifies a parameter value for a Mojo in a Maven plugin test.
This annotation can be used to configure individual Mojo parameters
without requiring a full POM file.
The annotation is repeatable, allowing multiple parameters to be set
on a single test method or parameter. For multiple parameters, you can
either use multiple @MojoParameter
annotations or a single
MojoParameters
annotation.
Example usage with a single parameter:
@Test
@InjectMojo(goal = "compile")
@MojoParameter(name = "source", value = "1.8")
void testCompilation(CompileMojo mojo) {
mojo.execute();
}
Example usage with multiple parameters:
@Test
@InjectMojo(goal = "compile")
@MojoParameter(name = "source", value = "1.8")
@MojoParameter(name = "target", value = "1.8")
@MojoParameter(name = "debug", value = "true")
void testCompilation(CompileMojo mojo) {
mojo.execute();
}
- Since:
- 4.0.0
- See Also:
-
Required Element Summary
Required Elements
-
Element Details
-
name
String nameThe name of the Mojo parameter to set. This should match the name of a parameter in the Mojo class, as specified by its@Parameter
annotation or field name.- Returns:
- the parameter name
-
value
String valueThe value to set for the parameter. The value can include Maven property expressions (e.g., "${project.version}").- Returns:
- the parameter value
-