updated examples to use new plugin-tools' java annotations
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-testing/trunk@1345439 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt b/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt
index c5aa970..8bab33f 100644
--- a/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt
+++ b/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt
@@ -30,17 +30,14 @@
Sometimes, your Mojo uses project artifact and ArtifactHandler mechanisms. For instance, you could need to
filter on Java projects, i.e.:
------
++---+
public class MyMojo
extends AbstractMojo
{
/**
* The Maven Project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
*/
+ @Component
protected MavenProject project;
public void execute()
@@ -57,11 +54,11 @@
...
}
}
------
++---+
* Create Stubs
------
++---+
public class MyArtifactHandlerStub
extends DefaultArtifactHandler
{
@@ -82,9 +79,9 @@
this.language = language;
}
}
------
++---+
------
++---+
public class MyArtifactStub
extends ArtifactStub
{
@@ -192,9 +189,9 @@
this.handler = handler;
}
}
------
++---+
------
++---+
public class MyProjectStub
extends MavenProjectStub
{
@@ -215,4 +212,4 @@
...
}
------
++---+
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt b/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt
index 7a9caf9..a0761c2 100644
--- a/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt
+++ b/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt
@@ -32,7 +32,7 @@
Suppose that you have the following dependencies in the maven-my-plugin pom:
------
++---+
<project>
...
<dependencies>
@@ -49,51 +49,42 @@
...
</dependencies>
</project>
------
++---+
You will add the following in the <<<MyMojo>>>:
------
++---+
public class MyMojo
extends AbstractMojo
{
/**
* The Maven Project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
*/
+ @Component
protected MavenProject project;
/**
* Local Repository.
- *
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
protected ArtifactRepository localRepository;
/**
* The Maven Settings.
- *
- * @parameter default-value="${settings}"
- * @required
- * @readonly
*/
+ @Component
private Settings settings;
...
}
------
++---+
* Create Stubs
You need to create stub objects to run <<<MyMojoTest#testSomething()>>>. By convention, the package name should
reflect the stubs, i.e. in our case <<<org.apache.maven.plugin.my.stubs>>>.
------
++---+
public class MyProjectStub
extends MavenProjectStub
{
@@ -145,9 +136,9 @@
return new File( super.getBasedir() + "/src/test/resources/unit/project-to-test/" );
}
}
------
++---+
------
++---+
public class SettingsStub
extends Settings
{
@@ -157,11 +148,11 @@
return Collections.EMPTY_LIST;
}
}
------
++---+
* Configure <<<project-to-test>>> pom
------
++---+
<project>
...
<build>
@@ -183,4 +174,4 @@
</plugins>
</build>
</project>
------
++---+
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt b/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt
index 1564723..e010348 100644
--- a/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt
+++ b/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt
@@ -29,7 +29,20 @@
Your Mojo should have <<<@aggregator>>> parameter, i.e.:
-------
+ * with java annotations ({{{/plugin-tools/}maven-plugin-plugin 3.x}}):
+
++----+
+@Mojo( name = "touch", aggregator = true )
+public class MyMojo
+ extends AbstractMojo
+{
+ ...
+}
++----+
+
+ * or with javadoc tags:
+
++----+
/**
* @goal touch
* @aggregator
@@ -39,7 +52,9 @@
{
...
}
-------
++----+
+
+ []
To test a Mojo in a multiproject area, you need to define several stubs, i.e. for the main test project and its modules.
@@ -47,7 +62,7 @@
Stub for the main test project:
------
++----+
public class MyProjectStub
extends MavenProjectStub
{
@@ -67,11 +82,11 @@
return this;
}
}
------
++----+
Stubs for the subprojects:
------
++----+
public class SubProject1Stub
extends MavenProjectStub
{
@@ -83,9 +98,9 @@
...
}
}
------
++----+
------
++----+
public class SubProject2Stub
extends MavenProjectStub
{
@@ -97,11 +112,11 @@
...
}
}
------
++----+
* Configure <<<project-to-test>>> pom
------
++----+
<project>
...
<build>
@@ -120,4 +135,4 @@
</plugins>
</build>
</project>
------
++----+
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt b/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt
index b3b7388..6a86ebc 100644
--- a/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt
+++ b/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt
@@ -30,31 +30,26 @@
When developing a Maven plugin you often need to play with repositories. Suppose that the MyMojo needs
to download artifacts into your local repository, i.e.:
------
++----+
public class MyMojo
extends AbstractMojo
{
/**
* Used for resolving artifacts
- *
- * @component
*/
+ @Component
private ArtifactResolver resolver;
/**
* Factory for creating artifact objects
- *
- * @component
*/
+ @Component
private ArtifactFactory factory;
/**
* Local Repository.
- *
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
private ArtifactRepository localRepository;
public void execute()
@@ -79,13 +74,13 @@
...
}
}
------
++----+
* Create Stubs
Stub for the test project:
------
++----+
public class MyProjectStub
extends MavenProjectStub
{
@@ -106,11 +101,11 @@
return Collections.singletonList( repository );
}
}
------
++----+
* Configure <<<project-to-test>>> pom
------
++----+
<project>
...
<build>
@@ -131,7 +126,7 @@
</plugins>
</build>
</project>
------
++----+
** Execute test