You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/05/11 18:45:00 UTC

svn commit: r1337273 [1/2] - in /maven/plugin-tools/branches/MPLUGIN-189: ./ maven-plugin-plugin/ maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/ maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/ maven-plugin-plugin/src/...

Author: olamy
Date: Fri May 11 16:44:59 2012
New Revision: 1337273

URL: http://svn.apache.org/viewvc?rev=1337273&view=rev
Log:
[MPLUGIN-189] push some stuff on help for annotations
the goal is to have a generic class which will read the descriptor.
Copy of the descriptor with cleaning html for description fields (copy in a path META-INF/maven/${groupId}/${artifactId}/plugin-description.xml

Modified:
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/mplugin-187/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-report/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/skip/invoker.properties
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/pom.xml
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
    maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
    maven/plugin-tools/branches/MPLUGIN-189/pom.xml

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/pom.xml Fri May 11 16:44:59 2012
@@ -111,6 +111,24 @@
         <artifactId>plexus-archiver</artifactId>
         <version>2.1.1</version>
       </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-velocity</artifactId>
+        <version>1.1.8</version>
+        <exclusions>
+          <exclusion>
+            <groupId>velocity</groupId>
+            <artifactId>velocity</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+
+      <!-- other -->
+      <dependency>
+        <groupId>org.apache.velocity</groupId>
+        <artifactId>velocity</artifactId>
+        <version>1.7</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
@@ -218,6 +236,23 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-velocity</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>velocity</groupId>
+          <artifactId>velocity</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <!-- other -->
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+    </dependency>
+
   </dependencies>
 
   <build>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml Fri May 11 16:44:59 2012
@@ -54,6 +54,7 @@ under the License.
       <groupId>org.apache.maven.plugin-tools</groupId>
       <artifactId>maven-plugin-annotations</artifactId>
       <version>@project.version@</version>
+      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml Fri May 11 16:44:59 2012
@@ -59,6 +59,7 @@ under the License.
       <groupId>org.apache.maven.plugin-tools</groupId>
       <artifactId>maven-plugin-annotations</artifactId>
       <version>@project.version@</version>
+      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties Fri May 11 16:44:59 2012
@@ -1,6 +1,4 @@
-invoker.goals.1 = install
-invoker.goals.2 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0:it0014
-invoker.goals.3 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0:first
-#FIXME disabled need to find a solution for the chicken and eggs issue.
-#help sources are generated @generated-sources but need descriptor which need compile phase first for classes scanning
-#invoker.goals.3 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0::help
+invoker.goals.1 = clean install -DskipTests
+invoker.goals.2 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:it0014
+invoker.goals.3 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:first
+invoker.goals.4 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:help

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml Fri May 11 16:44:59 2012
@@ -24,7 +24,7 @@ under the License.
 
   <groupId>org.apache.maven.its.annotation-with-inheritance</groupId>
   <artifactId>annotation-with-inheritance</artifactId>
-  <version>1.0</version>
+  <version>1.0-SNAPSHOT</version>
   <packaging>maven-plugin</packaging>
 
   <name>Maven Integration Test :: annotation-with-inheritance</name>
@@ -54,6 +54,7 @@ under the License.
       <groupId>org.apache.maven.plugin-tools</groupId>
       <artifactId>maven-plugin-annotations</artifactId>
       <version>@project.version@</version>
+      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
@@ -96,6 +97,12 @@ under the License.
               <goal>descriptor</goal>
             </goals>
           </execution>
+          <execution>
+            <id>help-goal</id>
+            <goals>
+              <goal>helpmojo</goal>
+            </goals>
+          </execution>
         </executions>
       </plugin>
     </plugins>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java Fri May 11 16:44:59 2012
@@ -32,7 +32,7 @@ import org.apache.maven.plugins.annotati
  * @since 1.2
  * @deprecated Don't use!
  */
-@Mojo( name = "first", requiresDependencyResolution = "test", defaultPhase = LifecyclePhase.INTEGRATION_TEST )
+@Mojo( name = "first", requiresDependencyResolution = "test", defaultPhase = LifecyclePhase.INTEGRATION_TEST)
 @Execute( phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura" )
 public class FirstMojo
     extends AbstractFirstMojo

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties Fri May 11 16:44:59 2012
@@ -1,2 +1,2 @@
-invoker.goals.1 = install -DskipTests
+invoker.goals.1 = clean install -DskipTests
 invoker.goals.2 = org.apache.maven.its.plugin:help:1.0:help

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/pom.xml?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/pom.xml Fri May 11 16:44:59 2012
@@ -41,6 +41,12 @@ under the License.
       <artifactId>maven-plugin-api</artifactId>
       <version>2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>3.0.1</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
   <build>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/invoker.properties Fri May 11 16:44:59 2012
@@ -1 +1 @@
-invoker.goals = compile
+invoker.goals = clean compile

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/pom.xml?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-package/pom.xml Fri May 11 16:44:59 2012
@@ -41,6 +41,12 @@ under the License.
       <artifactId>maven-plugin-api</artifactId>
       <version>2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>3.0.1</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
   <build>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties Fri May 11 16:44:59 2012
@@ -1,4 +1,4 @@
-invoker.goals.1 = clean install
+invoker.goals.1 = clean install -DskipTests
 invoker.profiles.1 = setup
 
 invoker.goals.2 = clean process-classes

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties Fri May 11 16:44:59 2012
@@ -1,4 +1,4 @@
-invoker.goals.1 = install
+invoker.goals.1 = clean install -DskipTests
 invoker.goals.2 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0:it0014
 #FIXME disabled need to find a solution for the chicken and eggs issue.
 #help sources are generated @generated-sources but need descriptor which need compile phase first for classes scanning

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic/invoker.properties Fri May 11 16:44:59 2012
@@ -1,3 +1,3 @@
-invoker.goals.1 = install
+invoker.goals.1 = install -DskipTests
 invoker.goals.2 = org.apache.maven.its.it0013:maven-it-it0013:1.0:it0013
 

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/mplugin-187/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/mplugin-187/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/mplugin-187/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/mplugin-187/invoker.properties Fri May 11 16:44:59 2012
@@ -1 +1 @@
-invoker.goals = clean plugin:report
+invoker.goals = clean plugin:report -DskipTests

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/invoker.properties Fri May 11 16:44:59 2012
@@ -1 +1 @@
-invoker.goals = clean site
+invoker.goals = clean site -DskipTests

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-report/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-report/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-report/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/plugin-report/invoker.properties Fri May 11 16:44:59 2012
@@ -1 +1 @@
-invoker.goals = clean site
+invoker.goals = clean site -DskipTests

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/skip/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/skip/invoker.properties?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/skip/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/skip/invoker.properties Fri May 11 16:44:59 2012
@@ -1,2 +1,2 @@
-invoker.goals = install
+invoker.goals = install -DskipTests
 invoker.mavenOpts = -Dmaven.plugin.skip=true
\ No newline at end of file

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java Fri May 11 16:44:59 2012
@@ -30,12 +30,14 @@ import org.apache.maven.tools.plugin.Def
 import org.apache.maven.tools.plugin.PluginToolsRequest;
 import org.apache.maven.tools.plugin.extractor.ExtractionException;
 import org.apache.maven.tools.plugin.generator.Generator;
+import org.apache.maven.tools.plugin.generator.GeneratorException;
 import org.apache.maven.tools.plugin.scanner.MojoScanner;
 import org.apache.maven.tools.plugin.util.PluginUtils;
 import org.codehaus.plexus.util.ReaderFactory;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.annotation.Documented;
 import java.util.List;
 import java.util.Set;
 
@@ -248,7 +250,7 @@ public abstract class AbstractGeneratorM
 
             createGenerator().execute( getOutputDirectory(), request );
         }
-        catch ( IOException e )
+        catch ( GeneratorException e )
         {
             throw new MojoExecutionException( "Error writing plugin descriptor", e );
         }

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java Fri May 11 16:44:59 2012
@@ -19,20 +19,21 @@ package org.apache.maven.plugin.plugin;
  * under the License.
  */
 
-import java.io.File;
-
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.tools.plugin.generator.Generator;
 import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+import java.io.File;
 
 /**
  * Generates a <code>HelpMojo</code> class.
  *
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
  * @version $Id$
- * @since 2.4
  * @goal helpmojo
  * @phase generate-sources
+ * @since 2.4
  */
 public class HelpGeneratorMojo
     extends AbstractGeneratorMojo
@@ -47,7 +48,7 @@ public class HelpGeneratorMojo
     /**
      * The name of the package for the generated <code>HelpMojo</code>. By default, the package will be calculated based
      * on the packages of the other plugin goals.
-     * 
+     *
      * @parameter
      * @since 2.6
      */
@@ -61,19 +62,35 @@ public class HelpGeneratorMojo
      */
     private boolean useJava5;
 
-    /** {@inheritDoc} */
+    /**
+     * Velocity component.
+     *
+     * @component
+     * @readonly
+     * @required
+     */
+    private VelocityComponent velocity;
+
+    /**
+     * {@inheritDoc}
+     */
     protected File getOutputDirectory()
     {
         return outputDirectory;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected Generator createGenerator()
     {
-        return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseJava5( useJava5 );
+        return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseJava5(
+            useJava5 ).setVelocityComponent( this.velocity );
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public void execute()
         throws MojoExecutionException
     {
@@ -83,5 +100,7 @@ public class HelpGeneratorMojo
         {
             project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
         }
+
     }
+
 }

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java Fri May 11 16:44:59 2012
@@ -19,15 +19,6 @@ package org.apache.maven.plugin.plugin;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.siterenderer.Renderer;
 import org.apache.maven.model.Plugin;
@@ -42,21 +33,30 @@ import org.apache.maven.reporting.MavenR
 import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
 import org.apache.maven.tools.plugin.PluginToolsRequest;
 import org.apache.maven.tools.plugin.extractor.ExtractionException;
+import org.apache.maven.tools.plugin.generator.GeneratorException;
 import org.apache.maven.tools.plugin.generator.PluginXdocGenerator;
 import org.apache.maven.tools.plugin.scanner.MojoScanner;
 import org.apache.maven.tools.plugin.util.PluginUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
 /**
  * Generates the Plugin's documentation report.
  *
  * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
  * @version $Id$
- * @since 2.0
  * @goal report
  * @execute phase="compile"
+ * @since 2.0
  */
 public class PluginReport
     extends AbstractMavenReport
@@ -91,13 +91,12 @@ public class PluginReport
      */
     protected MojoScanner mojoScanner;
 
-   /**
-    * The file encoding of the source files.
-    *
-    * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
-    *
-    * @since 2.7
-    */
+    /**
+     * The file encoding of the source files.
+     *
+     * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
+     * @since 2.7
+     */
     private String encoding;
 
 
@@ -124,10 +123,10 @@ public class PluginReport
     private Requirements requirements;
 
     /**
-     * The goal prefix that will appear before the ":". 
-     * By default, this plugin applies a heuristic to derive a heuristic from 
-     * the plugin's artifactId. 
-     * 
+     * The goal prefix that will appear before the ":".
+     * By default, this plugin applies a heuristic to derive a heuristic from
+     * the plugin's artifactId.
+     * <p/>
      * It removes any occurrences of the regular expression <strong>-?maven-?</strong>,
      * and then removes any occurrences of <strong>-?plugin-?</strong>.
      * <p>
@@ -158,31 +157,41 @@ public class PluginReport
      */
     private boolean skipReport;
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected Renderer getSiteRenderer()
     {
         return siteRenderer;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected String getOutputDirectory()
     {
         return outputDirectory.getPath();
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected MavenProject getProject()
     {
         return project;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public boolean canGenerateReport()
     {
         return "maven-plugin".equals( project.getPackaging() );
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     @SuppressWarnings( "unchecked" )
     protected void executeReport( Locale locale )
         throws MavenReportException
@@ -205,8 +214,7 @@ public class PluginReport
         }
         else
         {
-            getLog().warn(
-                           "\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '"
+            getLog().warn( "\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '"
                                + defaultGoalPrefix + "'.\n" );
         }
 
@@ -224,11 +232,11 @@ public class PluginReport
         try
         {
             pluginDescriptor.setDependencies( PluginUtils.toComponentDependencies( project.getRuntimeDependencies() ) );
-            
+
             PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
             request.setEncoding( encoding );
 
-            try 
+            try
             {
                 mojoScanner.populatePluginDescriptor( request );
             }
@@ -243,11 +251,11 @@ public class PluginReport
             generatePluginDocumentation( pluginDescriptor, locale );
 
             // Write the overview
-            PluginOverviewRenderer r = new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor,
-                                                                   locale );
+            PluginOverviewRenderer r =
+                new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor, locale );
             r.render();
         }
-        
+
         catch ( ExtractionException e )
         {
             throw new MavenReportException( "Error extracting plugin descriptor: \'" + e.getLocalizedMessage() + "\'",
@@ -255,19 +263,25 @@ public class PluginReport
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getDescription( Locale locale )
     {
         return getBundle( locale ).getString( "report.plugin.description" );
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getName( Locale locale )
     {
         return getBundle( locale ).getString( "report.plugin.name" );
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getOutputName()
     {
         return "plugin-info";
@@ -275,7 +289,7 @@ public class PluginReport
 
     /**
      * @param pluginDescriptor not null
-     * @param locale not null
+     * @param locale           not null
      * @throws MavenReportException if any
      */
     private void generatePluginDocumentation( PluginDescriptor pluginDescriptor, Locale locale )
@@ -287,9 +301,10 @@ public class PluginReport
             outputDir.mkdirs();
 
             PluginXdocGenerator generator = new PluginXdocGenerator( project, locale );
-            generator.execute( outputDir, pluginDescriptor );
+            PluginToolsRequest pluginToolsRequest = new DefaultPluginToolsRequest( project, pluginDescriptor );
+            generator.execute( outputDir, pluginToolsRequest );
         }
-        catch ( IOException e )
+        catch ( GeneratorException e )
         {
             throw new MavenReportException( "Error writing plugin documentation", e );
         }
@@ -321,11 +336,11 @@ public class PluginReport
         private final Locale locale;
 
         /**
-         * @param project not null
-         * @param requirements not null
-         * @param sink not null
+         * @param project          not null
+         * @param requirements     not null
+         * @param sink             not null
          * @param pluginDescriptor not null
-         * @param locale not null
+         * @param locale           not null
          */
         public PluginOverviewRenderer( MavenProject project, Requirements requirements, Sink sink,
                                        PluginDescriptor pluginDescriptor, Locale locale )
@@ -341,13 +356,17 @@ public class PluginReport
             this.locale = locale;
         }
 
-        /** {@inheritDoc} */
+        /**
+         * {@inheritDoc}
+         */
         public String getTitle()
         {
             return getBundle( locale ).getString( "report.plugin.title" );
         }
 
-        /** {@inheritDoc} */
+        /**
+         * {@inheritDoc}
+         */
         @SuppressWarnings( { "unchecked", "rawtypes" } )
         public void renderBody()
         {
@@ -362,7 +381,6 @@ public class PluginReport
 
             paragraph( getBundle( locale ).getString( "report.plugin.goals.intro" ) );
 
-
             boolean hasMavenReport = false;
             for ( Iterator<MojoDescriptor> i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
             {
@@ -381,11 +399,11 @@ public class PluginReport
             String descriptionColumnName = getBundle( locale ).getString( "report.plugin.goals.column.description" );
             if ( hasMavenReport )
             {
-                tableHeader( new String[] { goalColumnName, isMavenReport, descriptionColumnName } );
+                tableHeader( new String[]{ goalColumnName, isMavenReport, descriptionColumnName } );
             }
             else
             {
-                tableHeader( new String[] { goalColumnName, descriptionColumnName } );
+                tableHeader( new String[]{ goalColumnName, descriptionColumnName } );
             }
 
             List<MojoDescriptor> mojos = new ArrayList<MojoDescriptor>();
@@ -449,15 +467,16 @@ public class PluginReport
             String maven = discoverMavenRequirement( project, requirements );
             sink.tableRow();
             tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.maven" ) );
-            tableCell( ( maven != null ? maven : getBundle( locale )
-                .getString( "report.plugin.systemrequirements.nominimum" ) ) );
+            tableCell( ( maven != null
+                ? maven
+                : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
             sink.tableRow_();
 
             String jdk = discoverJdkRequirement( project, requirements );
             sink.tableRow();
             tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.jdk" ) );
-            tableCell( ( jdk != null ? jdk : getBundle( locale )
-                .getString( "report.plugin.systemrequirements.nominimum" ) ) );
+            tableCell(
+                ( jdk != null ? jdk : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
             sink.tableRow_();
 
             sink.tableRow();
@@ -482,9 +501,9 @@ public class PluginReport
 
                     sink.tableRow();
                     tableCell( key );
-                    tableCell( ( StringUtils.isNotEmpty( requirements.getOthers().getProperty( key ) ) ? requirements
-                        .getOthers().getProperty( key ) : getBundle( locale )
-                        .getString( "report.plugin.systemrequirements.nominimum" ) ) );
+                    tableCell( ( StringUtils.isNotEmpty( requirements.getOthers().getProperty( key ) )
+                        ? requirements.getOthers().getProperty( key )
+                        : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
                     sink.tableRow_();
                 }
             }
@@ -515,31 +534,32 @@ public class PluginReport
             sb.append( "<project>" ).append( '\n' );
             sb.append( "  ..." ).append( '\n' );
             sb.append( "  <build>" ).append( '\n' );
-            sb.append( "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) + " -->" )
-                .append( '\n' );
+            sb.append(
+                "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) + " -->" ).append(
+                '\n' );
             sb.append( "    <pluginManagement>" ).append( '\n' );
             sb.append( "      <plugins>" ).append( '\n' );
             sb.append( "        <plugin>" ).append( '\n' );
-            sb.append( "          <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
-                .append( '\n' );
-            sb.append( "          <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
-                .append( '\n' );
-            sb.append( "          <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
-                .append( '\n' );
+            sb.append( "          <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append(
+                '\n' );
+            sb.append( "          <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append(
+                "</artifactId>" ).append( '\n' );
+            sb.append( "          <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
+                '\n' );
             sb.append( "        </plugin>" ).append( '\n' );
             sb.append( "        ..." ).append( '\n' );
             sb.append( "      </plugins>" ).append( '\n' );
             sb.append( "    </pluginManagement>" ).append( '\n' );
-            sb.append( "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.plugins" ) + " -->" )
-                .append( '\n' );
+            sb.append( "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.plugins" ) + " -->" ).append(
+                '\n' );
             sb.append( "    <plugins>" ).append( '\n' );
             sb.append( "      <plugin>" ).append( '\n' );
-            sb.append( "        <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
-                .append( '\n' );
-            sb.append( "        <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
-                .append( '\n' );
-            sb.append( "        <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
-            .append( '\n' );
+            sb.append( "        <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append(
+                '\n' );
+            sb.append( "        <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append(
+                "</artifactId>" ).append( '\n' );
+            sb.append( "        <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
+                '\n' );
             sb.append( "      </plugin>" ).append( '\n' );
             sb.append( "      ..." ).append( '\n' );
             sb.append( "    </plugins>" ).append( '\n' );
@@ -548,17 +568,18 @@ public class PluginReport
             if ( hasMavenReport )
             {
                 sb.append( "  ..." ).append( '\n' );
-                sb.append( "  <!-- " + getBundle( locale ).getString( "report.plugin.usage.reporting" ) + " -->" )
-                    .append( '\n' );
+                sb.append(
+                    "  <!-- " + getBundle( locale ).getString( "report.plugin.usage.reporting" ) + " -->" ).append(
+                    '\n' );
                 sb.append( "  <reporting>" ).append( '\n' );
                 sb.append( "    <plugins>" ).append( '\n' );
                 sb.append( "      <plugin>" ).append( '\n' );
-                sb.append( "        <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
-                    .append( '\n' );
-                sb.append( "        <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
-                    .append( '\n' );
-                sb.append( "        <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
-                    .append( '\n' );
+                sb.append( "        <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append(
+                    '\n' );
+                sb.append( "        <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append(
+                    "</artifactId>" ).append( '\n' );
+                sb.append( "        <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
+                    '\n' );
                 sb.append( "      </plugin>" ).append( '\n' );
                 sb.append( "      ..." ).append( '\n' );
                 sb.append( "    </plugins>" ).append( '\n' );
@@ -581,7 +602,7 @@ public class PluginReport
          * Try to lookup on the Maven prerequisites property.
          * If not specified, uses the value defined by the user.
          *
-         * @param project not null
+         * @param project      not null
          * @param requirements not null
          * @return the Maven version
          */
@@ -606,7 +627,7 @@ public class PluginReport
          * If not specified, uses the value defined by the user.
          * If not specified, uses the value of the system property <code>java.specification.version</code>.
          *
-         * @param project not null
+         * @param project      not null
          * @param requirements not null
          * @return the JDK version
          */
@@ -686,11 +707,11 @@ public class PluginReport
                 jdk = pluginConf.getChild( "target" ).getValue();
             }
 
-            if ( jdk == null ) 
+            if ( jdk == null )
             {
                 return backupJdk;
             }
-            else 
+            else
             {
                 return jdk;
             }

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/pom.xml?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/pom.xml (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/pom.xml Fri May 11 16:44:59 2012
@@ -71,6 +71,22 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-container-default</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-velocity</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>velocity</groupId>
+          <artifactId>velocity</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <!-- other -->
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+    </dependency>
 
     <!-- misc -->
     <dependency>
@@ -93,6 +109,20 @@
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <systemPropertyVariables>
+            <java.io.tmpdir>${project.build.outputDirectory}</java.io.tmpdir>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
   <profiles>
     <profile>
       <id>reporting</id>

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/Generator.java Fri May 11 16:44:59 2012
@@ -33,18 +33,7 @@ import java.io.IOException;
  */
 public interface Generator
 {
-    /**
-     * Execute the generation for a given plugin descriptor.
-     *
-     * @param destinationDirectory required
-     * @param pluginDescriptor required
-     * @throws IOException if any
-     * 
-     * @deprecated Use {@link Generator#execute(File, PluginToolsRequest)} instead.
-     */
-    void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
-        throws IOException;
-    
+
     /**
      * Execute the generation for a given plugin descriptor.
      *
@@ -55,5 +44,5 @@ public interface Generator
      * @since 2.5
      */
     void execute( File destinationDirectory, PluginToolsRequest request )
-        throws IOException;
+        throws GeneratorException;
 }
\ No newline at end of file

Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java?rev=1337273&r1=1337272&r2=1337273&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Fri May 11 16:44:59 2012
@@ -19,11 +19,12 @@ package org.apache.maven.tools.plugin.ge
  * under the License.
  */
 
+import org.apache.maven.plugin.descriptor.DuplicateMojoDescriptorException;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.plugin.descriptor.Parameter;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.plugin.descriptor.Requirement;
-import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
 import org.apache.maven.tools.plugin.PluginToolsRequest;
 import org.apache.maven.tools.plugin.util.PluginUtils;
@@ -33,53 +34,91 @@ import org.codehaus.plexus.util.xml.Pret
 import org.codehaus.plexus.util.xml.XMLWriter;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 /**
+ * @version $Id$
  * @todo add example usage tag that can be shown in the doco
  * @todo need to add validation directives so that systems embedding maven2 can
  * get validation directives to help users in IDEs.
- *
- * @version $Id$
  */
 public class PluginDescriptorGenerator
     implements Generator
 {
-    /** {@inheritDoc} */
-    public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
-        throws IOException
+
+    /**
+     * {@inheritDoc}
+     */
+    public void execute( File destinationDirectory, PluginToolsRequest request )
+        throws GeneratorException
     {
-        execute( destinationDirectory, new DefaultPluginToolsRequest( null, pluginDescriptor ) );
+        try
+        {
+            File f = new File( destinationDirectory, "plugin.xml" );
+            writeDescriptor( f, request, false );
+            MavenProject mavenProject = request.getProject();
+            String pluginDescriptionFilePath =
+                "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId()
+                    + "/plugin-description.xml";
+            f = new File( request.getProject().getBuild().getOutputDirectory(), pluginDescriptionFilePath );
+            writeDescriptor( f, request, true );
+        }
+        catch ( IOException e )
+        {
+            throw new GeneratorException( e.getMessage(), e );
+        }
+        catch ( DuplicateMojoDescriptorException e )
+        {
+            throw new GeneratorException( e.getMessage(), e );
+        }
     }
-    
-    /** {@inheritDoc} */
-    public void execute( File destinationDirectory, PluginToolsRequest request )
-        throws IOException
+
+    public void writeDescriptor( File destinationFile, PluginToolsRequest request, boolean cleanDescription )
+        throws IOException, DuplicateMojoDescriptorException
     {
         PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
-        
-        String encoding = "UTF-8";
 
-        File f = new File( destinationDirectory, "plugin.xml" );
+        File tmpPropertiesFile =
+            new File( request.getProject().getBuild().getDirectory(), "maven-plugin-help.properties" );
 
-        if ( !f.getParentFile().exists() )
+        if ( tmpPropertiesFile.exists() )
         {
-            f.getParentFile().mkdirs();
+            Properties properties = new Properties();
+            properties.load( new FileInputStream( tmpPropertiesFile ) );
+            //MojoDescriptor mojoDescriptor =
+            //    makeHelpDescriptor( pluginDescriptor, properties.getProperty( "helpPackageName" ) );
+            //pluginDescriptor.addMojo( mojoDescriptor );
+        }
+        if ( destinationFile.exists() )
+        {
+            destinationFile.delete();
+        }
+        else
+        {
+            if ( !destinationFile.getParentFile().exists() )
+            {
+                destinationFile.getParentFile().mkdirs();
+            }
         }
 
+        String encoding = "UTF-8";
+
         Writer writer = null;
         try
         {
-            writer = new OutputStreamWriter( new FileOutputStream( f ), encoding );
+            writer = new OutputStreamWriter( new FileOutputStream( destinationFile ), encoding );
 
             XMLWriter w = new PrettyPrintXMLWriter( writer, encoding, null );
 
@@ -105,11 +144,11 @@ public class PluginDescriptorGenerator
 
             if ( pluginDescriptor.getMojos() != null )
             {
-                for ( @SuppressWarnings( "unchecked" )
-                Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
+                for ( @SuppressWarnings( "unchecked" ) Iterator<MojoDescriptor> it =
+                          pluginDescriptor.getMojos().iterator(); it.hasNext(); )
                 {
                     MojoDescriptor descriptor = it.next();
-                    processMojoDescriptor( descriptor, w );
+                    processMojoDescriptor( descriptor, w, cleanDescription );
                 }
             }
 
@@ -120,6 +159,7 @@ public class PluginDescriptorGenerator
             w.endElement();
 
             writer.flush();
+
         }
         finally
         {
@@ -128,11 +168,143 @@ public class PluginDescriptorGenerator
     }
 
     /**
-     * @param mojoDescriptor not null
-     * @param w not null
+     * Creates a minimalistic mojo descriptor for the generated help goal.
+     *
+     * @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be
+     *                         <code>null</code>.
+     * @return The mojo descriptor for the generated help goal, never <code>null</code>.
+     */
+    private MojoDescriptor makeHelpDescriptor( PluginDescriptor pluginDescriptor, String packageName )
+    {
+        MojoDescriptor descriptor = new MojoDescriptor();
+
+        descriptor.setPluginDescriptor( pluginDescriptor );
+
+        descriptor.setLanguage( "java" );
+
+        descriptor.setGoal( "help" );
+
+        if ( StringUtils.isEmpty( packageName ) )
+        {
+            packageName = discoverPackageName( pluginDescriptor );
+        }
+        if ( StringUtils.isNotEmpty( packageName ) )
+        {
+            descriptor.setImplementation( packageName + '.' + "HelpMojo" );
+        }
+        else
+        {
+            descriptor.setImplementation( "HelpMojo" );
+        }
+
+        descriptor.setDescription(
+            "Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre>  mvn "
+                + descriptor.getFullGoalName()
+                + " -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details." );
+
+        try
+        {
+            Parameter param = new Parameter();
+            param.setName( "detail" );
+            param.setType( "boolean" );
+            param.setDescription( "If <code>true</code>, display all settable properties for each goal." );
+            param.setDefaultValue( "false" );
+            param.setExpression( "${detail}" );
+            descriptor.addParameter( param );
+
+            param = new Parameter();
+            param.setName( "goal" );
+            param.setType( "java.lang.String" );
+            param.setDescription(
+                "The name of the goal for which to show help." + " If unspecified, all goals will be displayed." );
+            param.setExpression( "${goal}" );
+            descriptor.addParameter( param );
+
+            param = new Parameter();
+            param.setName( "lineLength" );
+            param.setType( "int" );
+            param.setDescription( "The maximum length of a display line, should be positive." );
+            param.setDefaultValue( "80" );
+            param.setExpression( "${lineLength}" );
+            descriptor.addParameter( param );
+
+            param = new Parameter();
+            param.setName( "indentSize" );
+            param.setType( "int" );
+            param.setDescription( "The number of spaces per indentation level, should be positive." );
+            param.setDefaultValue( "2" );
+            param.setExpression( "${indentSize}" );
+            descriptor.addParameter( param );
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException( "Failed to setup parameters for help goal", e );
+        }
+
+        return descriptor;
+    }
+
+    /**
+     * Find the best package name, based on the number of hits of actual Mojo classes.
+     *
+     * @param pluginDescriptor not null
+     * @return the best name of the package for the generated mojo
      */
+    private static String discoverPackageName( PluginDescriptor pluginDescriptor )
+    {
+        Map packageNames = new HashMap();
+        for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
+        {
+            MojoDescriptor descriptor = (MojoDescriptor) it.next();
+
+            String impl = descriptor.getImplementation();
+            if ( impl.lastIndexOf( '.' ) != -1 )
+            {
+                String name = impl.substring( 0, impl.lastIndexOf( '.' ) );
+                if ( packageNames.get( name ) != null )
+                {
+                    int next = ( (Integer) packageNames.get( name ) ).intValue() + 1;
+                    packageNames.put( name, new Integer( next ) );
+                }
+                else
+                {
+                    packageNames.put( name, new Integer( 1 ) );
+                }
+            }
+            else
+            {
+                packageNames.put( "", new Integer( 1 ) );
+            }
+        }
+
+        String packageName = "";
+        int max = 0;
+        for ( Iterator it = packageNames.keySet().iterator(); it.hasNext(); )
+        {
+            String key = it.next().toString();
+            int value = ( (Integer) packageNames.get( key ) ).intValue();
+            if ( value > max )
+            {
+                max = value;
+                packageName = key;
+            }
+        }
+
+        return packageName;
+    }
+
     protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w )
     {
+        processMojoDescriptor( mojoDescriptor, w, false );
+    }
+
+    /**
+     * @param mojoDescriptor   not null
+     * @param w                not null
+     * @param cleanDescription will clean html content from description fields
+     */
+    protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, boolean cleanDescription )
+    {
         w.startElement( "mojo" );
 
         // ----------------------------------------------------------------------
@@ -152,7 +324,14 @@ public class PluginDescriptorGenerator
         if ( description != null )
         {
             w.startElement( "description" );
-            w.writeText( mojoDescriptor.getDescription() );
+            if ( cleanDescription )
+            {
+                w.writeText( PluginUtils.toText( mojoDescriptor.getDescription() ) );
+            }
+            else
+            {
+                w.writeText( mojoDescriptor.getDescription() );
+            }
             w.endElement();
         }
 
@@ -323,8 +502,7 @@ public class PluginDescriptorGenerator
         // Parameters
         // ----------------------------------------------------------------------
 
-        @SuppressWarnings( "unchecked" )
-        List<Parameter> parameters = mojoDescriptor.getParameters();
+        @SuppressWarnings( "unchecked" ) List<Parameter> parameters = mojoDescriptor.getParameters();
 
         w.startElement( "parameters" );
 
@@ -397,11 +575,17 @@ public class PluginDescriptorGenerator
                     PluginUtils.element( w, "required", Boolean.toString( parameter.isRequired() ) );
 
                     PluginUtils.element( w, "editable", Boolean.toString( parameter.isEditable() ) );
+                    if ( cleanDescription )
+                    {
+                        PluginUtils.element( w, "description", PluginUtils.toText( parameter.getDescription() ) );
+                    }
+                    else
+                    {
+                        PluginUtils.element( w, "description", parameter.getDescription() );
+                    }
 
-                    PluginUtils.element( w, "description", parameter.getDescription() );
-
-                    if ( StringUtils.isNotEmpty( parameter.getDefaultValue() )
-                        || StringUtils.isNotEmpty( parameter.getExpression() ) )
+                    if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) || StringUtils.isNotEmpty(
+                        parameter.getExpression() ) )
                     {
                         configuration.add( parameter );
                     }