Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
* Specifies the base directory for test resources in Maven plugin tests.
* This annotation can be applied to test methods, or test class, to define where test resources are located.
*
** <p>Example usage:</p>
* * <p>Example usage:</p>
* <pre>
* {@code
* {@code.
*
* @see MojoTest
* @see MojoExtension
* @since 3.4.0
* @MojoTest
* class MyMojoTest {
* @Test
* @Basedir("src/test/resources/specific-test-case")
* @InjectMojo(goal = "compile")
* @Test
* @Basedir("src/test/resources/specific-test-case")
* @InjectMojo(goal = "compile")
* void testSpecificCase(MyMojo mojo) {
* // Test resources will be loaded from src/test/resources/specific-test-case
* mojo.execute();
* }
* }
* }
* </pre>
*
* @see MojoTest
* @see MojoExtension
* @since 3.4.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Inherited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
*
* <p>Example usage on a test method:</p>
* <pre>
* {@code
* {@code.
*
* @see MojoTest
* @see MojoParameter
* @see MojoExtension
* @since 3.4.0
* @Test
* @InjectMojo(goal = "compile")
* void testCompileMojo(CompileMojo mojo) {
Expand All @@ -44,7 +49,6 @@
* }
* }
* </pre>
*
* <p>Example usage with a custom POM:</p>
* <pre>
* {@code
Expand All @@ -59,7 +63,6 @@
* }
* }
* </pre>
*
* <p>The annotation can be used in conjunction with {@link MojoParameter} to provide
* specific parameter values for the Mojo:</p>
* <pre>
Expand All @@ -74,11 +77,6 @@
* }
* }
* </pre>
*
* @see MojoTest
* @see MojoParameter
* @see MojoExtension
* @since 3.4.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Inherited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,28 @@
*
* <p>Example usage in a test class:</p>
* <pre>
* {@code
* {@code.
*
* @see MojoTest
* @see InjectMojo
* @see MojoParameter
* @see Basedir
* @since 3.4.0
* @MojoTest
* class MyMojoTest {
* @Test
* @InjectMojo(goal = "my-goal")
* @MojoParameter(name = "outputDirectory", value = "${project.build.directory}/generated")
* @Test
* @InjectMojo(goal = "my-goal")
* @MojoParameter(name = "outputDirectory", value = "${project.build.directory}/generated")
* void testMojoExecution(MyMojo mojo) throws Exception {
* mojo.execute();
* // verify execution results
* }
* }
* }
* </pre>
**
* <p>For custom POM configurations, you can specify a POM file using the {@link InjectMojo#pom()}
* attribute. The extension will merge this configuration with default test project settings.</p>
*
* <p><b>NOTE:</b> only plugin configuration is taken from provided POM, all other tags are ignored.</p>
*
*
* @see MojoTest
* @see InjectMojo
* @see MojoParameter
* @see Basedir
* @since 3.4.0
*/
public class MojoExtension extends PlexusExtension implements ParameterResolver {

Expand Down Expand Up @@ -308,7 +305,7 @@ public void afterEach(ExtensionContext context) throws Exception {
}

/**
* Default MojoExecution mock
* Default MojoExecution mock.
*
* @return a MojoExecution mock
*/
Expand All @@ -317,7 +314,7 @@ private MojoExecution mockMojoExecution() {
}

/**
* Default MavenSession mock
* Default MavenSession mock.
*
* @return a MavenSession mock
*/
Expand All @@ -329,7 +326,7 @@ private MavenSession mockMavenSession() {
}

/**
* Default MavenProject mock
* Default MavenProject mock.
*
* @return a MavenProject mock
*/
Expand Down Expand Up @@ -444,7 +441,7 @@ protected String[] mojoCoordinates(String goal, PluginDescriptor pluginDescripto
}

/**
* lookup the mojo while we have all the relevent information
* Lookup the mojo while we have all the relevent information.
*/
protected Mojo lookupMojo(
ExtensionContext extensionContext,
Expand Down Expand Up @@ -536,7 +533,7 @@ private boolean isRealRepositorySessionNotRequired(ExtensionContext context) {
}

/**
* Create a MavenExecutionRequest if not already present in the MavenSession
* Create a MavenExecutionRequest if not already present in the MavenSession.
*/
private void createMavenExecutionRequest(ExtensionContext context) throws ComponentLookupException {
PlexusContainer container = getContainer(context);
Expand Down Expand Up @@ -738,7 +735,7 @@ public static String getTestPath(String path) {
}

/**
* Convenience method to set values to variables in objects that don't have setters
* Convenience method to set values to variables in objects that don't have setters.
*/
public static void setVariableValueToObject(Object object, String variable, Object value)
throws IllegalAccessException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
*
* <p>Example usage with a single parameter:</p>
* <pre>
* {@code
* {@code.
*
* @see MojoParameters
* @see InjectMojo
* @see MojoTest
* @since 3.4.0
* @Test
* @InjectMojo(goal = "compile")
* @MojoParameter(name = "source", value = "1.8")
Expand All @@ -46,7 +51,6 @@
* }
* }
* </pre>
*
* <p>Example usage with multiple parameters:</p>
* <pre>
* {@code
Expand All @@ -60,11 +64,6 @@
* }
* }
* </pre>
*
* @see MojoParameters
* @see InjectMojo
* @see MojoTest
* @since 3.4.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(MojoParameters.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@
*
* <p>Example of direct usage:</p>
* <pre>
* {@code
* {@code.
*
* @see MojoParameter
* @see InjectMojo
* @see MojoTest
* @since 3.4.0
* @Test
* @InjectMojo(goal = "compile")
* @MojoParameters({
* @MojoParameter(name = "source", value = "1.8"),
* @MojoParameter(name = "target", value = "1.8"),
* @MojoParameter(name = "debug", value = "true")
* @MojoParameter(name = "source", value = "1.8"),
* @MojoParameter(name = "target", value = "1.8"),
* @MojoParameter(name = "debug", value = "true")
* })
* void testCompilation(CompileMojo mojo) {
* mojo.execute();
* }
* }
* </pre>
*
* <p>Equivalent usage with repeatable annotation:</p>
* <pre>
* {@code
Expand All @@ -62,11 +66,6 @@
* }
* }
* </pre>
*
* @see MojoParameter
* @see InjectMojo
* @see MojoTest
* @since 3.4.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Inherited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,33 @@
*
* <p>Example usage:</p>
* <pre>
* {@code
* {@code.
*
* @see MojoExtension
* @see InjectMojo
* @see MojoParameter
* @see Provides
* @since 4.0.0
* @MojoTest
* class MyMojoTest {
* @Inject
* @Inject
* private SomeComponent component;
*
* @Test
* @InjectMojo(goal = "my-goal")
* @MojoParameter(name = "parameter", value = "value")
* @Test
* @InjectMojo(goal = "my-goal")
* @MojoParameter(name = "parameter", value = "value")
* void testMojoExecution(MyMojo mojo) {
* // mojo is instantiated with the specified parameters
* // component is automatically injected
* mojo.execute();
* // verify execution results
* }
*
* @Provides
* @Provides
* SomeComponent provideMockedComponent() {
* return mock(SomeComponent.class);
* }
* }
* }
* </pre>
*
* <p>The annotation supports:</p>
* <ul>
* <li>Automatic Mojo instantiation and configuration</li>
Expand All @@ -72,13 +75,6 @@
* <li>Custom POM configuration via {@link InjectMojo#pom()}</li>
* <li>Base directory configuration for test resources via {@link Basedir}</li>
* </ul>
*
*
* @see MojoExtension
* @see InjectMojo
* @see MojoParameter
* @see Provides
* @since 4.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(MojoExtension.class)
Expand Down
Loading
Loading