You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2012/06/02 06:53:53 UTC

svn commit: r1345439 - in /maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples: artifact.apt complex-mojo-parameters.apt multiproject.apt repositories.apt

Author: hboutemy
Date: Sat Jun  2 04:53:53 2012
New Revision: 1345439

URL: http://svn.apache.org/viewvc?rev=1345439&view=rev
Log:
updated examples to use new plugin-tools' java annotations

Modified:
    maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt
    maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt
    maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt
    maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt

Modified: maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt?rev=1345439&r1=1345438&r2=1345439&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt Sat Jun  2 04:53:53 2012
@@ -30,17 +30,14 @@ Testing Project Artifact
  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 @@ public class MyMojo
         ...
      }
 }
------
++---+
 
 * Create Stubs
 
------
++---+
 public class MyArtifactHandlerStub
     extends DefaultArtifactHandler
 {
@@ -82,9 +79,9 @@ public class MyArtifactHandlerStub
         this.language = language;
     }
 }
------
++---+
 
------
++---+
 public class MyArtifactStub
     extends ArtifactStub
 {
@@ -192,9 +189,9 @@ public class MyArtifactStub
         this.handler = handler;
     }
 }
------
++---+
 
------
++---+
 public class MyProjectStub
     extends MavenProjectStub
 {
@@ -215,4 +212,4 @@ public class MyProjectStub
 
     ...
 }
------
++---+

Modified: maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt?rev=1345439&r1=1345438&r2=1345439&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt Sat Jun  2 04:53:53 2012
@@ -32,7 +32,7 @@ Testing Complex Mojo Parameters
 
  Suppose that you have the following dependencies in the maven-my-plugin pom:
 
------
++---+
 <project>
   ...
   <dependencies>
@@ -49,51 +49,42 @@ Testing Complex Mojo Parameters
     ...
   </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 @@ public class MyProjectStub
         return new File( super.getBasedir() + "/src/test/resources/unit/project-to-test/" );
     }
 }
------
++---+
 
------
++---+
 public class SettingsStub
     extends Settings
 {
@@ -157,11 +148,11 @@ public class SettingsStub
         return Collections.EMPTY_LIST;
     }
 }
------
++---+
 
 * Configure <<<project-to-test>>> pom
 
------
++---+
 <project>
   ...
   <build>
@@ -183,4 +174,4 @@ public class SettingsStub
     </plugins>
   </build>
 </project>
------
++---+

Modified: maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt?rev=1345439&r1=1345438&r2=1345439&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt Sat Jun  2 04:53:53 2012
@@ -29,7 +29,20 @@ Testing Multiproject
 
  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 @@ public class MyMojo
 {
   ...
 }
-------
++----+
+
+ []
 
  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 @@ public class MyMojo
 
  Stub for the main test project:
 
------
++----+
 public class MyProjectStub
     extends MavenProjectStub
 {
@@ -67,11 +82,11 @@ public class MyProjectStub
         return this;
     }
 }
------
++----+
 
  Stubs for the subprojects:
 
------
++----+
 public class SubProject1Stub
     extends MavenProjectStub
 {
@@ -83,9 +98,9 @@ public class SubProject1Stub
         ...
     }
 }
------
++----+
 
------
++----+
 public class SubProject2Stub
     extends MavenProjectStub
 {
@@ -97,11 +112,11 @@ public class SubProject2Stub
         ...
     }
 }
------
++----+
 
 * Configure <<<project-to-test>>> pom
 
------
++----+
 <project>
   ...
   <build>
@@ -120,4 +135,4 @@ public class SubProject2Stub
     </plugins>
   </build>
 </project>
------
++----+

Modified: maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt
URL: http://svn.apache.org/viewvc/maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt?rev=1345439&r1=1345438&r2=1345439&view=diff
==============================================================================
--- maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt (original)
+++ maven/plugin-testing/trunk/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt Sat Jun  2 04:53:53 2012
@@ -30,31 +30,26 @@ Testing Using Repositories
  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 @@ public class MyMojo
         ...
      }
 }
------
++----+
 
 * Create Stubs
 
  Stub for the test project:
 
------
++----+
 public class MyProjectStub
     extends MavenProjectStub
 {
@@ -106,11 +101,11 @@ public class MyProjectStub
         return Collections.singletonList( repository );
     }
 }
------
++----+
 
 * Configure <<<project-to-test>>> pom
 
------
++----+
 <project>
   ...
   <build>
@@ -131,7 +126,7 @@ public class MyProjectStub
     </plugins>
   </build>
 </project>
------
++----+
 
 ** Execute test