[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
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/branches/MPLUGIN-189@1337273 13f79535-47bb-0310-9956-ffa450edef68
master
parent
ba66d8def7
commit
4ec2eaf3a5
|
|
@ -111,6 +111,24 @@
|
||||||
<artifactId>plexus-archiver</artifactId>
|
<artifactId>plexus-archiver</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>2.1.1</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
@ -218,6 +236,23 @@
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-utils</artifactId>
|
<artifactId>plexus-utils</artifactId>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ under the License.
|
||||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
<artifactId>maven-plugin-annotations</artifactId>
|
<artifactId>maven-plugin-annotations</artifactId>
|
||||||
<version>@project.version@</version>
|
<version>@project.version@</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ under the License.
|
||||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
<artifactId>maven-plugin-annotations</artifactId>
|
<artifactId>maven-plugin-annotations</artifactId>
|
||||||
<version>@project.version@</version>
|
<version>@project.version@</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
invoker.goals.1 = install
|
invoker.goals.1 = clean install -DskipTests
|
||||||
invoker.goals.2 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0:it0014
|
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:first
|
invoker.goals.3 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:first
|
||||||
#FIXME disabled need to find a solution for the chicken and eggs issue.
|
invoker.goals.4 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:help
|
||||||
#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
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ under the License.
|
||||||
|
|
||||||
<groupId>org.apache.maven.its.annotation-with-inheritance</groupId>
|
<groupId>org.apache.maven.its.annotation-with-inheritance</groupId>
|
||||||
<artifactId>annotation-with-inheritance</artifactId>
|
<artifactId>annotation-with-inheritance</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>maven-plugin</packaging>
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
<name>Maven Integration Test :: annotation-with-inheritance</name>
|
<name>Maven Integration Test :: annotation-with-inheritance</name>
|
||||||
|
|
@ -54,6 +54,7 @@ under the License.
|
||||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
<artifactId>maven-plugin-annotations</artifactId>
|
<artifactId>maven-plugin-annotations</artifactId>
|
||||||
<version>@project.version@</version>
|
<version>@project.version@</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
|
@ -96,6 +97,12 @@ under the License.
|
||||||
<goal>descriptor</goal>
|
<goal>descriptor</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>help-goal</id>
|
||||||
|
<goals>
|
||||||
|
<goal>helpmojo</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
|
||||||
|
|
@ -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
|
invoker.goals.2 = org.apache.maven.its.plugin:help:1.0:help
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ under the License.
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-utils</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
invoker.goals = compile
|
invoker.goals = clean compile
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ under the License.
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-utils</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
invoker.goals.1 = clean install
|
invoker.goals.1 = clean install -DskipTests
|
||||||
invoker.profiles.1 = setup
|
invoker.profiles.1 = setup
|
||||||
|
|
||||||
invoker.goals.2 = clean process-classes
|
invoker.goals.2 = clean process-classes
|
||||||
|
|
|
||||||
|
|
@ -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
|
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.
|
#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
|
#help sources are generated @generated-sources but need descriptor which need compile phase first for classes scanning
|
||||||
|
|
|
||||||
|
|
@ -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
|
invoker.goals.2 = org.apache.maven.its.it0013:maven-it-it0013:1.0:it0013
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
invoker.goals = clean plugin:report
|
invoker.goals = clean plugin:report -DskipTests
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
invoker.goals = clean site
|
invoker.goals = clean site -DskipTests
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
invoker.goals = clean site
|
invoker.goals = clean site -DskipTests
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
invoker.goals = install
|
invoker.goals = install -DskipTests
|
||||||
invoker.mavenOpts = -Dmaven.plugin.skip=true
|
invoker.mavenOpts = -Dmaven.plugin.skip=true
|
||||||
|
|
@ -30,12 +30,14 @@ import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||||
import org.apache.maven.tools.plugin.generator.Generator;
|
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.scanner.MojoScanner;
|
||||||
import org.apache.maven.tools.plugin.util.PluginUtils;
|
import org.apache.maven.tools.plugin.util.PluginUtils;
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
@ -248,7 +250,7 @@ public abstract class AbstractGeneratorMojo
|
||||||
|
|
||||||
createGenerator().execute( getOutputDirectory(), request );
|
createGenerator().execute( getOutputDirectory(), request );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( GeneratorException e )
|
||||||
{
|
{
|
||||||
throw new MojoExecutionException( "Error writing plugin descriptor", e );
|
throw new MojoExecutionException( "Error writing plugin descriptor", e );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,21 @@ package org.apache.maven.plugin.plugin;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.tools.plugin.generator.Generator;
|
import org.apache.maven.tools.plugin.generator.Generator;
|
||||||
import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
|
import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
|
||||||
|
import org.codehaus.plexus.velocity.VelocityComponent;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a <code>HelpMojo</code> class.
|
* Generates a <code>HelpMojo</code> class.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @since 2.4
|
|
||||||
* @goal helpmojo
|
* @goal helpmojo
|
||||||
* @phase generate-sources
|
* @phase generate-sources
|
||||||
|
* @since 2.4
|
||||||
*/
|
*/
|
||||||
public class HelpGeneratorMojo
|
public class HelpGeneratorMojo
|
||||||
extends AbstractGeneratorMojo
|
extends AbstractGeneratorMojo
|
||||||
|
|
@ -61,19 +62,35 @@ public class HelpGeneratorMojo
|
||||||
*/
|
*/
|
||||||
private boolean useJava5;
|
private boolean useJava5;
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* Velocity component.
|
||||||
|
*
|
||||||
|
* @component
|
||||||
|
* @readonly
|
||||||
|
* @required
|
||||||
|
*/
|
||||||
|
private VelocityComponent velocity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
protected File getOutputDirectory()
|
protected File getOutputDirectory()
|
||||||
{
|
{
|
||||||
return outputDirectory;
|
return outputDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
protected Generator createGenerator()
|
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()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
|
@ -83,5 +100,7 @@ public class HelpGeneratorMojo
|
||||||
{
|
{
|
||||||
project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
|
project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,6 @@ package org.apache.maven.plugin.plugin;
|
||||||
* under the License.
|
* 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.sink.Sink;
|
||||||
import org.apache.maven.doxia.siterenderer.Renderer;
|
import org.apache.maven.doxia.siterenderer.Renderer;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
|
|
@ -42,21 +33,30 @@ import org.apache.maven.reporting.MavenReportException;
|
||||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
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.generator.PluginXdocGenerator;
|
||||||
import org.apache.maven.tools.plugin.scanner.MojoScanner;
|
import org.apache.maven.tools.plugin.scanner.MojoScanner;
|
||||||
import org.apache.maven.tools.plugin.util.PluginUtils;
|
import org.apache.maven.tools.plugin.util.PluginUtils;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
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.
|
* Generates the Plugin's documentation report.
|
||||||
*
|
*
|
||||||
* @author <a href="snicoll@apache.org">Stephane Nicoll</a>
|
* @author <a href="snicoll@apache.org">Stephane Nicoll</a>
|
||||||
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @since 2.0
|
|
||||||
* @goal report
|
* @goal report
|
||||||
* @execute phase="compile"
|
* @execute phase="compile"
|
||||||
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class PluginReport
|
public class PluginReport
|
||||||
extends AbstractMavenReport
|
extends AbstractMavenReport
|
||||||
|
|
@ -95,7 +95,6 @@ public class PluginReport
|
||||||
* The file encoding of the source files.
|
* The file encoding of the source files.
|
||||||
*
|
*
|
||||||
* @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
|
* @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
|
||||||
*
|
|
||||||
* @since 2.7
|
* @since 2.7
|
||||||
*/
|
*/
|
||||||
private String encoding;
|
private String encoding;
|
||||||
|
|
@ -127,7 +126,7 @@ public class PluginReport
|
||||||
* The goal prefix that will appear before the ":".
|
* The goal prefix that will appear before the ":".
|
||||||
* By default, this plugin applies a heuristic to derive a heuristic from
|
* By default, this plugin applies a heuristic to derive a heuristic from
|
||||||
* the plugin's artifactId.
|
* the plugin's artifactId.
|
||||||
*
|
* <p/>
|
||||||
* It removes any occurrences of the regular expression <strong>-?maven-?</strong>,
|
* It removes any occurrences of the regular expression <strong>-?maven-?</strong>,
|
||||||
* and then removes any occurrences of <strong>-?plugin-?</strong>.
|
* and then removes any occurrences of <strong>-?plugin-?</strong>.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -158,31 +157,41 @@ public class PluginReport
|
||||||
*/
|
*/
|
||||||
private boolean skipReport;
|
private boolean skipReport;
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
protected Renderer getSiteRenderer()
|
protected Renderer getSiteRenderer()
|
||||||
{
|
{
|
||||||
return siteRenderer;
|
return siteRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
protected String getOutputDirectory()
|
protected String getOutputDirectory()
|
||||||
{
|
{
|
||||||
return outputDirectory.getPath();
|
return outputDirectory.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
protected MavenProject getProject()
|
protected MavenProject getProject()
|
||||||
{
|
{
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public boolean canGenerateReport()
|
public boolean canGenerateReport()
|
||||||
{
|
{
|
||||||
return "maven-plugin".equals( project.getPackaging() );
|
return "maven-plugin".equals( project.getPackaging() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
protected void executeReport( Locale locale )
|
protected void executeReport( Locale locale )
|
||||||
throws MavenReportException
|
throws MavenReportException
|
||||||
|
|
@ -205,8 +214,7 @@ public class PluginReport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getLog().warn(
|
getLog().warn( "\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '"
|
||||||
"\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '"
|
|
||||||
+ defaultGoalPrefix + "'.\n" );
|
+ defaultGoalPrefix + "'.\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,8 +251,8 @@ public class PluginReport
|
||||||
generatePluginDocumentation( pluginDescriptor, locale );
|
generatePluginDocumentation( pluginDescriptor, locale );
|
||||||
|
|
||||||
// Write the overview
|
// Write the overview
|
||||||
PluginOverviewRenderer r = new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor,
|
PluginOverviewRenderer r =
|
||||||
locale );
|
new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor, locale );
|
||||||
r.render();
|
r.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,19 +263,25 @@ public class PluginReport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public String getDescription( Locale locale )
|
public String getDescription( Locale locale )
|
||||||
{
|
{
|
||||||
return getBundle( locale ).getString( "report.plugin.description" );
|
return getBundle( locale ).getString( "report.plugin.description" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public String getName( Locale locale )
|
public String getName( Locale locale )
|
||||||
{
|
{
|
||||||
return getBundle( locale ).getString( "report.plugin.name" );
|
return getBundle( locale ).getString( "report.plugin.name" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public String getOutputName()
|
public String getOutputName()
|
||||||
{
|
{
|
||||||
return "plugin-info";
|
return "plugin-info";
|
||||||
|
|
@ -287,9 +301,10 @@ public class PluginReport
|
||||||
outputDir.mkdirs();
|
outputDir.mkdirs();
|
||||||
|
|
||||||
PluginXdocGenerator generator = new PluginXdocGenerator( project, locale );
|
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 );
|
throw new MavenReportException( "Error writing plugin documentation", e );
|
||||||
}
|
}
|
||||||
|
|
@ -341,13 +356,17 @@ public class PluginReport
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
return getBundle( locale ).getString( "report.plugin.title" );
|
return getBundle( locale ).getString( "report.plugin.title" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||||
public void renderBody()
|
public void renderBody()
|
||||||
{
|
{
|
||||||
|
|
@ -362,7 +381,6 @@ public class PluginReport
|
||||||
|
|
||||||
paragraph( getBundle( locale ).getString( "report.plugin.goals.intro" ) );
|
paragraph( getBundle( locale ).getString( "report.plugin.goals.intro" ) );
|
||||||
|
|
||||||
|
|
||||||
boolean hasMavenReport = false;
|
boolean hasMavenReport = false;
|
||||||
for ( Iterator<MojoDescriptor> i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
|
for ( Iterator<MojoDescriptor> i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
|
@ -449,15 +467,16 @@ public class PluginReport
|
||||||
String maven = discoverMavenRequirement( project, requirements );
|
String maven = discoverMavenRequirement( project, requirements );
|
||||||
sink.tableRow();
|
sink.tableRow();
|
||||||
tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.maven" ) );
|
tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.maven" ) );
|
||||||
tableCell( ( maven != null ? maven : getBundle( locale )
|
tableCell( ( maven != null
|
||||||
.getString( "report.plugin.systemrequirements.nominimum" ) ) );
|
? maven
|
||||||
|
: getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
|
||||||
sink.tableRow_();
|
sink.tableRow_();
|
||||||
|
|
||||||
String jdk = discoverJdkRequirement( project, requirements );
|
String jdk = discoverJdkRequirement( project, requirements );
|
||||||
sink.tableRow();
|
sink.tableRow();
|
||||||
tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.jdk" ) );
|
tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.jdk" ) );
|
||||||
tableCell( ( jdk != null ? jdk : getBundle( locale )
|
tableCell(
|
||||||
.getString( "report.plugin.systemrequirements.nominimum" ) ) );
|
( jdk != null ? jdk : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
|
||||||
sink.tableRow_();
|
sink.tableRow_();
|
||||||
|
|
||||||
sink.tableRow();
|
sink.tableRow();
|
||||||
|
|
@ -482,9 +501,9 @@ public class PluginReport
|
||||||
|
|
||||||
sink.tableRow();
|
sink.tableRow();
|
||||||
tableCell( key );
|
tableCell( key );
|
||||||
tableCell( ( StringUtils.isNotEmpty( requirements.getOthers().getProperty( key ) ) ? requirements
|
tableCell( ( StringUtils.isNotEmpty( requirements.getOthers().getProperty( key ) )
|
||||||
.getOthers().getProperty( key ) : getBundle( locale )
|
? requirements.getOthers().getProperty( key )
|
||||||
.getString( "report.plugin.systemrequirements.nominimum" ) ) );
|
: getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
|
||||||
sink.tableRow_();
|
sink.tableRow_();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -515,31 +534,32 @@ public class PluginReport
|
||||||
sb.append( "<project>" ).append( '\n' );
|
sb.append( "<project>" ).append( '\n' );
|
||||||
sb.append( " ..." ).append( '\n' );
|
sb.append( " ..." ).append( '\n' );
|
||||||
sb.append( " <build>" ).append( '\n' );
|
sb.append( " <build>" ).append( '\n' );
|
||||||
sb.append( " <!-- " + getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) + " -->" )
|
sb.append(
|
||||||
.append( '\n' );
|
" <!-- " + getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) + " -->" ).append(
|
||||||
|
'\n' );
|
||||||
sb.append( " <pluginManagement>" ).append( '\n' );
|
sb.append( " <pluginManagement>" ).append( '\n' );
|
||||||
sb.append( " <plugins>" ).append( '\n' );
|
sb.append( " <plugins>" ).append( '\n' );
|
||||||
sb.append( " <plugin>" ).append( '\n' );
|
sb.append( " <plugin>" ).append( '\n' );
|
||||||
sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
|
sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append(
|
||||||
.append( '\n' );
|
'\n' );
|
||||||
sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
|
sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append(
|
||||||
.append( '\n' );
|
"</artifactId>" ).append( '\n' );
|
||||||
sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
|
sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
|
||||||
.append( '\n' );
|
'\n' );
|
||||||
sb.append( " </plugin>" ).append( '\n' );
|
sb.append( " </plugin>" ).append( '\n' );
|
||||||
sb.append( " ..." ).append( '\n' );
|
sb.append( " ..." ).append( '\n' );
|
||||||
sb.append( " </plugins>" ).append( '\n' );
|
sb.append( " </plugins>" ).append( '\n' );
|
||||||
sb.append( " </pluginManagement>" ).append( '\n' );
|
sb.append( " </pluginManagement>" ).append( '\n' );
|
||||||
sb.append( " <!-- " + getBundle( locale ).getString( "report.plugin.usage.plugins" ) + " -->" )
|
sb.append( " <!-- " + getBundle( locale ).getString( "report.plugin.usage.plugins" ) + " -->" ).append(
|
||||||
.append( '\n' );
|
'\n' );
|
||||||
sb.append( " <plugins>" ).append( '\n' );
|
sb.append( " <plugins>" ).append( '\n' );
|
||||||
sb.append( " <plugin>" ).append( '\n' );
|
sb.append( " <plugin>" ).append( '\n' );
|
||||||
sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
|
sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append(
|
||||||
.append( '\n' );
|
'\n' );
|
||||||
sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
|
sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append(
|
||||||
.append( '\n' );
|
"</artifactId>" ).append( '\n' );
|
||||||
sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
|
sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
|
||||||
.append( '\n' );
|
'\n' );
|
||||||
sb.append( " </plugin>" ).append( '\n' );
|
sb.append( " </plugin>" ).append( '\n' );
|
||||||
sb.append( " ..." ).append( '\n' );
|
sb.append( " ..." ).append( '\n' );
|
||||||
sb.append( " </plugins>" ).append( '\n' );
|
sb.append( " </plugins>" ).append( '\n' );
|
||||||
|
|
@ -548,17 +568,18 @@ public class PluginReport
|
||||||
if ( hasMavenReport )
|
if ( hasMavenReport )
|
||||||
{
|
{
|
||||||
sb.append( " ..." ).append( '\n' );
|
sb.append( " ..." ).append( '\n' );
|
||||||
sb.append( " <!-- " + getBundle( locale ).getString( "report.plugin.usage.reporting" ) + " -->" )
|
sb.append(
|
||||||
.append( '\n' );
|
" <!-- " + getBundle( locale ).getString( "report.plugin.usage.reporting" ) + " -->" ).append(
|
||||||
|
'\n' );
|
||||||
sb.append( " <reporting>" ).append( '\n' );
|
sb.append( " <reporting>" ).append( '\n' );
|
||||||
sb.append( " <plugins>" ).append( '\n' );
|
sb.append( " <plugins>" ).append( '\n' );
|
||||||
sb.append( " <plugin>" ).append( '\n' );
|
sb.append( " <plugin>" ).append( '\n' );
|
||||||
sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
|
sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append(
|
||||||
.append( '\n' );
|
'\n' );
|
||||||
sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
|
sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append(
|
||||||
.append( '\n' );
|
"</artifactId>" ).append( '\n' );
|
||||||
sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
|
sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
|
||||||
.append( '\n' );
|
'\n' );
|
||||||
sb.append( " </plugin>" ).append( '\n' );
|
sb.append( " </plugin>" ).append( '\n' );
|
||||||
sb.append( " ..." ).append( '\n' );
|
sb.append( " ..." ).append( '\n' );
|
||||||
sb.append( " </plugins>" ).append( '\n' );
|
sb.append( " </plugins>" ).append( '\n' );
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,22 @@
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-container-default</artifactId>
|
<artifactId>plexus-container-default</artifactId>
|
||||||
</dependency>
|
</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 -->
|
<!-- misc -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
@ -93,6 +109,20 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</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>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>reporting</id>
|
<id>reporting</id>
|
||||||
|
|
|
||||||
|
|
@ -33,17 +33,6 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public interface Generator
|
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.
|
* Execute the generation for a given plugin descriptor.
|
||||||
|
|
@ -55,5 +44,5 @@ public interface Generator
|
||||||
* @since 2.5
|
* @since 2.5
|
||||||
*/
|
*/
|
||||||
void execute( File destinationDirectory, PluginToolsRequest request )
|
void execute( File destinationDirectory, PluginToolsRequest request )
|
||||||
throws IOException;
|
throws GeneratorException;
|
||||||
}
|
}
|
||||||
|
|
@ -19,11 +19,12 @@ package org.apache.maven.tools.plugin.generator;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.descriptor.DuplicateMojoDescriptorException;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.Parameter;
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.Requirement;
|
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.ExtendedMojoDescriptor;
|
||||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.util.PluginUtils;
|
import org.apache.maven.tools.plugin.util.PluginUtils;
|
||||||
|
|
@ -33,53 +34,91 @@ import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @version $Id$
|
||||||
* @todo add example usage tag that can be shown in the doco
|
* @todo add example usage tag that can be shown in the doco
|
||||||
* @todo need to add validation directives so that systems embedding maven2 can
|
* @todo need to add validation directives so that systems embedding maven2 can
|
||||||
* get validation directives to help users in IDEs.
|
* get validation directives to help users in IDEs.
|
||||||
*
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
*/
|
||||||
public class PluginDescriptorGenerator
|
public class PluginDescriptorGenerator
|
||||||
implements Generator
|
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 writeDescriptor( File destinationFile, PluginToolsRequest request, boolean cleanDescription )
|
||||||
public void execute( File destinationDirectory, PluginToolsRequest request )
|
throws IOException, DuplicateMojoDescriptorException
|
||||||
throws IOException
|
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
|
||||||
|
|
||||||
String encoding = "UTF-8";
|
File tmpPropertiesFile =
|
||||||
|
new File( request.getProject().getBuild().getDirectory(), "maven-plugin-help.properties" );
|
||||||
|
|
||||||
File f = new File( destinationDirectory, "plugin.xml" );
|
if ( tmpPropertiesFile.exists() )
|
||||||
|
|
||||||
if ( !f.getParentFile().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;
|
Writer writer = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writer = new OutputStreamWriter( new FileOutputStream( f ), encoding );
|
writer = new OutputStreamWriter( new FileOutputStream( destinationFile ), encoding );
|
||||||
|
|
||||||
XMLWriter w = new PrettyPrintXMLWriter( writer, encoding, null );
|
XMLWriter w = new PrettyPrintXMLWriter( writer, encoding, null );
|
||||||
|
|
||||||
|
|
@ -105,11 +144,11 @@ public class PluginDescriptorGenerator
|
||||||
|
|
||||||
if ( pluginDescriptor.getMojos() != null )
|
if ( pluginDescriptor.getMojos() != null )
|
||||||
{
|
{
|
||||||
for ( @SuppressWarnings( "unchecked" )
|
for ( @SuppressWarnings( "unchecked" ) Iterator<MojoDescriptor> it =
|
||||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
MojoDescriptor descriptor = it.next();
|
MojoDescriptor descriptor = it.next();
|
||||||
processMojoDescriptor( descriptor, w );
|
processMojoDescriptor( descriptor, w, cleanDescription );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,6 +159,7 @@ public class PluginDescriptorGenerator
|
||||||
w.endElement();
|
w.endElement();
|
||||||
|
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
@ -127,11 +167,143 @@ public class PluginDescriptorGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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=<goal-name></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 mojoDescriptor not null
|
||||||
* @param w not null
|
* @param w not null
|
||||||
|
* @param cleanDescription will clean html content from description fields
|
||||||
*/
|
*/
|
||||||
protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w )
|
protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, boolean cleanDescription )
|
||||||
{
|
{
|
||||||
w.startElement( "mojo" );
|
w.startElement( "mojo" );
|
||||||
|
|
||||||
|
|
@ -152,7 +324,14 @@ public class PluginDescriptorGenerator
|
||||||
if ( description != null )
|
if ( description != null )
|
||||||
{
|
{
|
||||||
w.startElement( "description" );
|
w.startElement( "description" );
|
||||||
|
if ( cleanDescription )
|
||||||
|
{
|
||||||
|
w.writeText( PluginUtils.toText( mojoDescriptor.getDescription() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
w.writeText( mojoDescriptor.getDescription() );
|
w.writeText( mojoDescriptor.getDescription() );
|
||||||
|
}
|
||||||
w.endElement();
|
w.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -323,8 +502,7 @@ public class PluginDescriptorGenerator
|
||||||
// Parameters
|
// Parameters
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" ) List<Parameter> parameters = mojoDescriptor.getParameters();
|
||||||
List<Parameter> parameters = mojoDescriptor.getParameters();
|
|
||||||
|
|
||||||
w.startElement( "parameters" );
|
w.startElement( "parameters" );
|
||||||
|
|
||||||
|
|
@ -397,11 +575,17 @@ public class PluginDescriptorGenerator
|
||||||
PluginUtils.element( w, "required", Boolean.toString( parameter.isRequired() ) );
|
PluginUtils.element( w, "required", Boolean.toString( parameter.isRequired() ) );
|
||||||
|
|
||||||
PluginUtils.element( w, "editable", Boolean.toString( parameter.isEditable() ) );
|
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() )
|
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) || StringUtils.isNotEmpty(
|
||||||
|| StringUtils.isNotEmpty( parameter.getExpression() ) )
|
parameter.getExpression() ) )
|
||||||
{
|
{
|
||||||
configuration.add( parameter );
|
configuration.add( parameter );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,31 +19,31 @@ package org.apache.maven.tools.plugin.generator;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.Parameter;
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||||
import org.apache.maven.tools.plugin.util.PluginUtils;
|
import org.apache.velocity.VelocityContext;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
import org.codehaus.plexus.velocity.VelocityComponent;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an <code>HelpMojo</code> class.
|
* Generates an <code>HelpMojo</code> class.
|
||||||
|
|
@ -56,20 +56,30 @@ public class PluginHelpGenerator
|
||||||
extends AbstractLogEnabled
|
extends AbstractLogEnabled
|
||||||
implements Generator
|
implements Generator
|
||||||
{
|
{
|
||||||
/** Line separator */
|
/**
|
||||||
|
* Line separator
|
||||||
|
*/
|
||||||
private static final String LS = System.getProperty( "line.separator" );
|
private static final String LS = System.getProperty( "line.separator" );
|
||||||
|
|
||||||
/** Default generated class name */
|
/**
|
||||||
|
* Default generated class name
|
||||||
|
*/
|
||||||
private static final String HELP_MOJO_CLASS_NAME = "HelpMojo";
|
private static final String HELP_MOJO_CLASS_NAME = "HelpMojo";
|
||||||
|
|
||||||
/** Default goal */
|
/**
|
||||||
|
* Default goal
|
||||||
|
*/
|
||||||
private static final String HELP_GOAL = "help";
|
private static final String HELP_GOAL = "help";
|
||||||
|
|
||||||
private String helpPackageName;
|
private String helpPackageName;
|
||||||
|
|
||||||
/** Flag to indicate if the generated help mojo should use Java 5 features */
|
/**
|
||||||
|
* Flag to indicate if the generated help mojo should use Java 5 features
|
||||||
|
*/
|
||||||
private boolean useJava5;
|
private boolean useJava5;
|
||||||
|
|
||||||
|
private VelocityComponent velocityComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
|
|
@ -82,39 +92,29 @@ public class PluginHelpGenerator
|
||||||
// Public methods
|
// Public methods
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
execute( destinationDirectory, new DefaultPluginToolsRequest( null, pluginDescriptor ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public void execute( File destinationDirectory, PluginToolsRequest request )
|
public void execute( File destinationDirectory, PluginToolsRequest request )
|
||||||
throws IOException
|
throws GeneratorException
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
|
||||||
|
|
||||||
if ( pluginDescriptor.getMojos() == null || pluginDescriptor.getMojos().size() < 1 )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MojoDescriptor helpDescriptor = makeHelpDescriptor( pluginDescriptor );
|
MojoDescriptor helpDescriptor = makeHelpDescriptor( pluginDescriptor );
|
||||||
|
|
||||||
// Verify that no help goal already exists
|
// Verify that no help goal already exists
|
||||||
for ( @SuppressWarnings( "unchecked" )
|
for ( @SuppressWarnings( "unchecked" ) Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator();
|
||||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
it.hasNext(); )
|
||||||
{
|
{
|
||||||
MojoDescriptor descriptor = it.next();
|
MojoDescriptor descriptor = it.next();
|
||||||
|
|
||||||
if ( descriptor.getGoal().equals( helpDescriptor.getGoal() )
|
if ( descriptor.getGoal().equals( helpDescriptor.getGoal() ) && !descriptor.getImplementation().equals(
|
||||||
&& !descriptor.getImplementation().equals( helpDescriptor.getImplementation() ) )
|
helpDescriptor.getImplementation() ) )
|
||||||
{
|
{
|
||||||
if ( getLogger().isWarnEnabled() )
|
if ( getLogger().isWarnEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().warn(
|
getLogger().warn( "\n\nA help goal (" + descriptor.getImplementation()
|
||||||
"\n\nA help goal (" + descriptor.getImplementation()
|
|
||||||
+ ") already exists in this plugin. SKIPPED THE "
|
+ ") already exists in this plugin. SKIPPED THE "
|
||||||
+ helpDescriptor.getImplementation() + " GENERATION.\n" );
|
+ helpDescriptor.getImplementation() + " GENERATION.\n" );
|
||||||
}
|
}
|
||||||
|
|
@ -123,6 +123,36 @@ public class PluginHelpGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properties.put( "helpPackageName", helpPackageName == null ? "" : helpPackageName );
|
||||||
|
|
||||||
|
MavenProject mavenProject = request.getProject();
|
||||||
|
|
||||||
|
String propertiesFilePath = "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId();
|
||||||
|
|
||||||
|
File tmpPropertiesFile =
|
||||||
|
new File( request.getProject().getBuild().getDirectory(), "maven-plugin-help.properties" );
|
||||||
|
if ( tmpPropertiesFile.exists() )
|
||||||
|
{
|
||||||
|
tmpPropertiesFile.delete();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !tmpPropertiesFile.getParentFile().exists() )
|
||||||
|
{
|
||||||
|
tmpPropertiesFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
properties.store( new FileOutputStream( tmpPropertiesFile ), "maven plugin help generation informations" );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new GeneratorException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
String sourcePath = helpDescriptor.getImplementation().replace( '.', File.separatorChar ) + ".java";
|
String sourcePath = helpDescriptor.getImplementation().replace( '.', File.separatorChar ) + ".java";
|
||||||
File helpClass = new File( destinationDirectory, sourcePath );
|
File helpClass = new File( destinationDirectory, sourcePath );
|
||||||
helpClass.getParentFile().mkdirs();
|
helpClass.getParentFile().mkdirs();
|
||||||
|
|
@ -131,13 +161,19 @@ public class PluginHelpGenerator
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writer = new OutputStreamWriter( new FileOutputStream( helpClass ), request.getEncoding() );
|
writer = new OutputStreamWriter( new FileOutputStream( helpClass ), request.getEncoding() );
|
||||||
writeClass( writer, pluginDescriptor, helpDescriptor, useJava5 );
|
writer.write( getHelpClassSources( propertiesFilePath ) );
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new GeneratorException( e.getMessage(), e );
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtil.close( writer );
|
IOUtil.close( writer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginHelpGenerator setHelpPackageName( String helpPackageName )
|
public PluginHelpGenerator setHelpPackageName( String helpPackageName )
|
||||||
|
|
@ -152,10 +188,47 @@ public class PluginHelpGenerator
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VelocityComponent getVelocityComponent()
|
||||||
|
{
|
||||||
|
return velocityComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginHelpGenerator setVelocityComponent( VelocityComponent velocityComponent )
|
||||||
|
{
|
||||||
|
this.velocityComponent = velocityComponent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Private methods
|
// Private methods
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
protected String getHelpClassSources( String propertiesFilePath )
|
||||||
|
{
|
||||||
|
Properties properties = new Properties();
|
||||||
|
VelocityContext context = new VelocityContext( properties );
|
||||||
|
if ( this.helpPackageName != null )
|
||||||
|
{
|
||||||
|
properties.put( "helpPackageName", this.helpPackageName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
properties.put( "helpPackageName", "" );
|
||||||
|
}
|
||||||
|
properties.put( "propertiesFilePath", propertiesFilePath + "/plugin-description.xml" );
|
||||||
|
// FIXME encoding !
|
||||||
|
|
||||||
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
|
||||||
|
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "help-class-source.vm" );
|
||||||
|
InputStreamReader isReader = new InputStreamReader( is );
|
||||||
|
velocityComponent.getEngine().evaluate( context, stringWriter, "", isReader );
|
||||||
|
|
||||||
|
return stringWriter.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a minimalistic mojo descriptor for the generated help goal.
|
* Creates a minimalistic mojo descriptor for the generated help goal.
|
||||||
*
|
*
|
||||||
|
|
@ -187,8 +260,9 @@ public class PluginHelpGenerator
|
||||||
descriptor.setImplementation( HELP_MOJO_CLASS_NAME );
|
descriptor.setImplementation( HELP_MOJO_CLASS_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptor.setDescription( "Display help information on " + pluginDescriptor.getArtifactId()
|
descriptor.setDescription(
|
||||||
+ ".<br/> Call <pre> mvn " + descriptor.getFullGoalName()
|
"Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre> mvn "
|
||||||
|
+ descriptor.getFullGoalName()
|
||||||
+ " -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details." );
|
+ " -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details." );
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -204,8 +278,8 @@ public class PluginHelpGenerator
|
||||||
param = new Parameter();
|
param = new Parameter();
|
||||||
param.setName( "goal" );
|
param.setName( "goal" );
|
||||||
param.setType( "java.lang.String" );
|
param.setType( "java.lang.String" );
|
||||||
param.setDescription( "The name of the goal for which to show help."
|
param.setDescription(
|
||||||
+ " If unspecified, all goals will be displayed." );
|
"The name of the goal for which to show help." + " If unspecified, all goals will be displayed." );
|
||||||
param.setExpression( "${goal}" );
|
param.setExpression( "${goal}" );
|
||||||
descriptor.addParameter( param );
|
descriptor.addParameter( param );
|
||||||
|
|
||||||
|
|
@ -241,595 +315,45 @@ public class PluginHelpGenerator
|
||||||
*/
|
*/
|
||||||
private static String discoverPackageName( PluginDescriptor pluginDescriptor )
|
private static String discoverPackageName( PluginDescriptor pluginDescriptor )
|
||||||
{
|
{
|
||||||
Map<String, Integer> packageNames = new HashMap<String, Integer>();
|
Map packageNames = new HashMap();
|
||||||
for ( @SuppressWarnings( "unchecked" )
|
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
|
||||||
{
|
{
|
||||||
MojoDescriptor descriptor = it.next();
|
MojoDescriptor descriptor = (MojoDescriptor) it.next();
|
||||||
|
|
||||||
String name = "";
|
|
||||||
int next = 1;
|
|
||||||
|
|
||||||
String impl = descriptor.getImplementation();
|
String impl = descriptor.getImplementation();
|
||||||
if ( impl.lastIndexOf( '.' ) != -1 )
|
if ( impl.lastIndexOf( '.' ) != -1 )
|
||||||
{
|
{
|
||||||
name = impl.substring( 0, impl.lastIndexOf( '.' ) );
|
String name = impl.substring( 0, impl.lastIndexOf( '.' ) );
|
||||||
Integer count = packageNames.get( name );
|
if ( packageNames.get( name ) != null )
|
||||||
|
|
||||||
if ( count != null )
|
|
||||||
{
|
{
|
||||||
next = count.intValue() + 1;
|
int next = ( (Integer) packageNames.get( name ) ).intValue() + 1;
|
||||||
|
packageNames.put( name, new Integer( next ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packageNames.put( name, new Integer( 1 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
packageNames.put( name, next );
|
{
|
||||||
|
packageNames.put( "", new Integer( 1 ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String packageName = "";
|
String packageName = "";
|
||||||
int max = 0;
|
int max = 0;
|
||||||
for ( Map.Entry<String, Integer> entry : packageNames.entrySet() )
|
for ( Iterator it = packageNames.keySet().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
int value = entry.getValue().intValue();
|
String key = it.next().toString();
|
||||||
|
int value = ( (Integer) packageNames.get( key ) ).intValue();
|
||||||
if ( value > max )
|
if ( value > max )
|
||||||
{
|
{
|
||||||
max = value;
|
max = value;
|
||||||
packageName = entry.getKey();
|
packageName = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return packageName;
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates the <code>HelpMojo</code> class.
|
|
||||||
*
|
|
||||||
* @param writer not null
|
|
||||||
* @param pluginDescriptor not null
|
|
||||||
* @param helpDescriptor not null
|
|
||||||
* @param useJava5 If the generated code should use Java5 features
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeClass( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor,
|
|
||||||
boolean useJava5 )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
String packageName = "";
|
|
||||||
String simpleName = helpDescriptor.getImplementation();
|
|
||||||
int dot = simpleName.lastIndexOf( '.' );
|
|
||||||
if ( dot >= 0 )
|
|
||||||
{
|
|
||||||
packageName = simpleName.substring( 0, dot );
|
|
||||||
simpleName = simpleName.substring( dot + 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( packageName.length() > 0 )
|
|
||||||
{
|
|
||||||
writer.write( "package " + packageName + ";" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
writeImports( writer );
|
|
||||||
writer.write( LS );
|
|
||||||
|
|
||||||
writeMojoJavadoc( writer, pluginDescriptor, helpDescriptor );
|
|
||||||
|
|
||||||
if ( useJava5 )
|
|
||||||
{
|
|
||||||
writer.write( "@SuppressWarnings( \"all\" )" + LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.write( "public class " + simpleName + LS );
|
|
||||||
writer.write( " extends AbstractMojo" + LS );
|
|
||||||
writer.write( "{" + LS );
|
|
||||||
|
|
||||||
writeVariables( writer, helpDescriptor );
|
|
||||||
|
|
||||||
writer.write( LS );
|
|
||||||
|
|
||||||
writeExecute( writer, pluginDescriptor, helpDescriptor );
|
|
||||||
|
|
||||||
writer.write( LS );
|
|
||||||
writeUtilities( writer, useJava5 );
|
|
||||||
writer.write( "}" + LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param writer not null
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeImports( Writer writer )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
writer.write( "import java.util.ArrayList;" + LS );
|
|
||||||
writer.write( "import java.util.Iterator;" + LS );
|
|
||||||
writer.write( "import java.util.List;" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( "import org.apache.maven.plugin.AbstractMojo;" + LS );
|
|
||||||
writer.write( "import org.apache.maven.plugin.MojoExecutionException;" + LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param writer not null
|
|
||||||
* @param pluginDescriptor not null
|
|
||||||
* @param helpDescriptor not null
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeMojoJavadoc( Writer writer, PluginDescriptor pluginDescriptor,
|
|
||||||
MojoDescriptor helpDescriptor )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
StringBuffer author = new StringBuffer();
|
|
||||||
author.append( PluginHelpGenerator.class.getName() );
|
|
||||||
|
|
||||||
String resource = "META-INF/maven/org.apache.maven.plugin-tools/maven-plugin-tools-api/pom.properties";
|
|
||||||
InputStream resourceAsStream = PluginHelpGenerator.class.getClassLoader().getResourceAsStream( resource );
|
|
||||||
|
|
||||||
if ( resourceAsStream != null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Properties properties = new Properties();
|
|
||||||
properties.load( resourceAsStream );
|
|
||||||
|
|
||||||
author.append( " (version " ).append( properties.getProperty( "version", "unknown" ) ).append( ")" );
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
// nope
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( resourceAsStream );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.write( "/**" + LS );
|
|
||||||
writer.write( " * " + helpDescriptor.getDescription() + LS );
|
|
||||||
writer.write( " *" + LS );
|
|
||||||
writer.write( " * @version generated on " + new Date() + LS );
|
|
||||||
writer.write( " * @author " + author.toString() + LS );
|
|
||||||
writer.write( " * @goal " + helpDescriptor.getGoal() + LS );
|
|
||||||
writer.write( " * @requiresProject false" + LS );
|
|
||||||
writer.write( " * @threadSafe" + LS );
|
|
||||||
writer.write( " */" + LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param writer not null
|
|
||||||
* @param helpDescriptor not null
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeVariables( Writer writer, MojoDescriptor helpDescriptor )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
for ( @SuppressWarnings( "unchecked" )
|
|
||||||
Iterator<Parameter> it = helpDescriptor.getParameters().iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
Parameter param = it.next();
|
|
||||||
writer.write( " /**" + LS );
|
|
||||||
writer.write( " * " + StringUtils.escape( param.getDescription() ) + LS );
|
|
||||||
writer.write( " * " + LS );
|
|
||||||
writer.write( " * @parameter" );
|
|
||||||
if ( StringUtils.isNotEmpty( param.getExpression() ) )
|
|
||||||
{
|
|
||||||
writer.write( " expression=\"" );
|
|
||||||
writer.write( StringUtils.escape( param.getExpression() ) );
|
|
||||||
writer.write( "\"" );
|
|
||||||
}
|
|
||||||
if ( StringUtils.isNotEmpty( param.getDefaultValue() ) )
|
|
||||||
{
|
|
||||||
writer.write( " default-value=\"" );
|
|
||||||
writer.write( StringUtils.escape( param.getDefaultValue() ) );
|
|
||||||
writer.write( "\"" );
|
|
||||||
}
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " */" + LS );
|
|
||||||
writer.write( " private " + param.getType() + " " + param.getName() + ";" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param writer not null
|
|
||||||
* @param pluginDescriptor not null
|
|
||||||
* @param helpDescriptor not null
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeExecute( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>();
|
|
||||||
|
|
||||||
mojoDescriptors.add( helpDescriptor );
|
|
||||||
for ( @SuppressWarnings( "unchecked" )
|
|
||||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
|
||||||
{
|
|
||||||
MojoDescriptor mojoDescriptor = it.next();
|
|
||||||
|
|
||||||
if ( !helpDescriptor.getGoal().equals( mojoDescriptor.getGoal() ) )
|
|
||||||
{
|
|
||||||
mojoDescriptors.add( mojoDescriptor );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginUtils.sortMojos( mojoDescriptors );
|
|
||||||
|
|
||||||
writer.write( " /** {@inheritDoc} */" + LS );
|
|
||||||
writer.write( " public void execute()" + LS );
|
|
||||||
writer.write( " throws MojoExecutionException" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
|
|
||||||
writer.write( " if ( lineLength <= 0 )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " getLog().warn( \"The parameter 'lineLength' should be positive, using '80' as "
|
|
||||||
+ "default.\" );" + LS );
|
|
||||||
writer.write( " lineLength = 80;" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " if ( indentSize <= 0 )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " getLog().warn( \"The parameter 'indentSize' should be positive, using '2' as "
|
|
||||||
+ "default.\" );" + LS );
|
|
||||||
writer.write( " indentSize = 2;" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
|
|
||||||
writer.write( " StringBuffer sb = new StringBuffer();" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
|
|
||||||
writer.write( " append( sb, \"" + StringUtils.escape( pluginDescriptor.getId() ) + "\", 0 );" + LS );
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
|
|
||||||
if ( StringUtils.isNotEmpty( pluginDescriptor.getName() )
|
|
||||||
&& ( pluginDescriptor.getName().indexOf( pluginDescriptor.getId() ) != -1 ) )
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \""
|
|
||||||
+ StringUtils.escape( pluginDescriptor.getName() + " " + pluginDescriptor.getVersion() )
|
|
||||||
+ "\", 0 );" + LS );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( StringUtils.isNotEmpty( pluginDescriptor.getName() ) )
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \"" + StringUtils.escape( pluginDescriptor.getName() )
|
|
||||||
+ "\", 0 );" + LS );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \"" + StringUtils.escape( pluginDescriptor.getId() )
|
|
||||||
+ "\", 0 );" + LS );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writer.write( " append( sb, \"" + toDescription( pluginDescriptor.getDescription() ) + "\", 1 );"
|
|
||||||
+ LS );
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
|
|
||||||
writer.write( " if ( goal == null || goal.length() <= 0 )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " append( sb, \"This plugin has " + mojoDescriptors.size() + " "
|
|
||||||
+ ( mojoDescriptors.size() > 1 ? "goals" : "goal" ) + ":\", 0 );" + LS );
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
|
|
||||||
writer.write( LS );
|
|
||||||
|
|
||||||
for ( MojoDescriptor descriptor : mojoDescriptors )
|
|
||||||
{
|
|
||||||
writeGoal( writer, descriptor );
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.write( " if ( getLog().isInfoEnabled() )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " getLog().info( sb.toString() );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param writer not null
|
|
||||||
* @param descriptor not null
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeGoal( Writer writer, MojoDescriptor descriptor )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
String goalDescription = toDescription( descriptor.getDescription() );
|
|
||||||
|
|
||||||
writer.write( " if ( goal == null || goal.length() <= 0 || \""
|
|
||||||
+ StringUtils.escape( descriptor.getGoal() ) + "\".equals( goal ) )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " append( sb, \"" + StringUtils.escape( descriptor.getFullGoalName() ) + "\", 0 );"
|
|
||||||
+ LS );
|
|
||||||
if ( StringUtils.isNotEmpty( descriptor.getDeprecated() ) )
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \"Deprecated. " + toDescription( descriptor.getDeprecated() )
|
|
||||||
+ "\", 1 );" + LS );
|
|
||||||
writer.write( " if ( detail )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
writer.write( " append( sb, \"" + goalDescription + "\", 1 );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \"" + goalDescription + "\", 1 );" + LS );
|
|
||||||
}
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
|
|
||||||
if ( descriptor.getParameters() != null && descriptor.getParameters().size() > 0 )
|
|
||||||
{
|
|
||||||
@SuppressWarnings( "unchecked" )
|
|
||||||
List<Parameter> params = descriptor.getParameters();
|
|
||||||
|
|
||||||
PluginUtils.sortMojoParameters( params );
|
|
||||||
|
|
||||||
writer.write( " if ( detail )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
|
|
||||||
writer.write( " append( sb, \"Available parameters:\", 1 );" + LS );
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
|
|
||||||
for ( Parameter parameter : params )
|
|
||||||
{
|
|
||||||
if ( parameter.isEditable() )
|
|
||||||
{
|
|
||||||
writer.write( LS );
|
|
||||||
writeParameter( writer, parameter );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param writer not null
|
|
||||||
* @param parameter not null
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeParameter( Writer writer, Parameter parameter )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
String expression = parameter.getExpression();
|
|
||||||
|
|
||||||
if ( expression == null || !expression.startsWith( "${component." ) )
|
|
||||||
{
|
|
||||||
String parameterName = StringUtils.escape( parameter.getName() );
|
|
||||||
String parameterDescription = toDescription( parameter.getDescription() );
|
|
||||||
String parameterDefaultValue = "";
|
|
||||||
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) )
|
|
||||||
{
|
|
||||||
parameterDefaultValue = " (Default: " + StringUtils.escape( parameter.getDefaultValue() ) + ")";
|
|
||||||
}
|
|
||||||
writer.write( " append( sb, \"" + parameterName + parameterDefaultValue + "\", 2 );" + LS );
|
|
||||||
if ( StringUtils.isNotEmpty( parameter.getDeprecated() ) )
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \"Deprecated. " + toDescription( parameter.getDeprecated() )
|
|
||||||
+ "\", 3 );" + LS );
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
}
|
|
||||||
writer.write( " append( sb, \"" + parameterDescription + "\", 3 );" + LS );
|
|
||||||
if ( parameter.isRequired() )
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \"Required: Yes\", 3 );" + LS );
|
|
||||||
}
|
|
||||||
if ( StringUtils.isNotEmpty( parameter.getExpression() ) )
|
|
||||||
{
|
|
||||||
writer.write( " append( sb, \"Expression: "
|
|
||||||
+ StringUtils.escape( parameter.getExpression() ) + "\", 3 );" + LS );
|
|
||||||
}
|
|
||||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param writer not null
|
|
||||||
* @param useJava5 If the generated code should use Java5 features
|
|
||||||
* @throws IOException if any
|
|
||||||
*/
|
|
||||||
private static void writeUtilities( Writer writer, boolean useJava5 )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
writer.write( " /**" + LS );
|
|
||||||
writer.write( " * <p>Repeat a String <code>n</code> times to form a new string.</p>" + LS );
|
|
||||||
writer.write( " *" + LS );
|
|
||||||
writer.write( " * @param str String to repeat" + LS );
|
|
||||||
writer.write( " * @param repeat number of times to repeat str" + LS );
|
|
||||||
writer.write( " * @return String with repeated String" + LS );
|
|
||||||
writer.write( " * @throws NegativeArraySizeException if <code>repeat < 0</code>" + LS );
|
|
||||||
writer.write( " * @throws NullPointerException if str is <code>null</code>" + LS );
|
|
||||||
writer.write( " */" + LS );
|
|
||||||
writer.write( " private static String repeat( String str, int repeat )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " StringBuffer buffer = new StringBuffer( repeat * str.length() );" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " for ( int i = 0; i < repeat; i++ )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " buffer.append( str );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " return buffer.toString();" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " /** " + LS );
|
|
||||||
writer.write( " * Append a description to the buffer by respecting the indentSize and lineLength "
|
|
||||||
+ "parameters." + LS );
|
|
||||||
writer.write( " * <b>Note</b>: The last character is always a new line." + LS );
|
|
||||||
writer.write( " * " + LS );
|
|
||||||
writer.write( " * @param sb The buffer to append the description, not <code>null</code>." + LS );
|
|
||||||
writer.write( " * @param description The description, not <code>null</code>." + LS );
|
|
||||||
writer.write( " * @param indent The base indentation level of each line, must not be negative." + LS );
|
|
||||||
writer.write( " */" + LS );
|
|
||||||
writer.write( " private void append( StringBuffer sb, String description, int indent )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " for ( Iterator it = toLines( description, indent, indentSize, lineLength )"
|
|
||||||
+ ".iterator(); it.hasNext(); )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " sb.append( it.next().toString() ).append( '\\n' );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " /** " + LS );
|
|
||||||
writer.write( " * Splits the specified text into lines of convenient display length." + LS );
|
|
||||||
writer.write( " * " + LS );
|
|
||||||
writer.write( " * @param text The text to split into lines, must not be <code>null</code>." + LS );
|
|
||||||
writer.write( " * @param indent The base indentation level of each line, must not be negative." + LS );
|
|
||||||
writer.write( " * @param indentSize The size of each indentation, must not be negative." + LS );
|
|
||||||
writer.write( " * @param lineLength The length of the line, must not be negative." + LS );
|
|
||||||
writer.write( " * @return The sequence of display lines, never <code>null</code>." + LS );
|
|
||||||
writer.write( " * @throws NegativeArraySizeException if <code>indent < 0</code>" + LS );
|
|
||||||
writer.write( " */" + LS );
|
|
||||||
writer.write( " private static List toLines( String text, int indent, int indentSize, int lineLength )"
|
|
||||||
+ LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
if ( useJava5 )
|
|
||||||
{
|
|
||||||
writer.write( " List<String> lines = new ArrayList<String>();" + LS );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writer.write( " List lines = new ArrayList();" + LS );
|
|
||||||
}
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " String ind = repeat( \"\\t\", indent );" + LS );
|
|
||||||
writer.write( " String[] plainLines = text.split( \"(\\r\\n)|(\\r)|(\\n)\" );" + LS );
|
|
||||||
writer.write( " for ( int i = 0; i < plainLines.length; i++ )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " toLines( lines, ind + plainLines[i], indentSize, lineLength );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " return lines;" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " /** " + LS );
|
|
||||||
writer.write( " * Adds the specified line to the output sequence, performing line wrapping if necessary."
|
|
||||||
+ LS );
|
|
||||||
writer.write( " * " + LS );
|
|
||||||
writer.write( " * @param lines The sequence of display lines, must not be <code>null</code>." + LS );
|
|
||||||
writer.write( " * @param line The line to add, must not be <code>null</code>." + LS );
|
|
||||||
writer.write( " * @param indentSize The size of each indentation, must not be negative." + LS );
|
|
||||||
writer.write( " * @param lineLength The length of the line, must not be negative." + LS );
|
|
||||||
writer.write( " */" + LS );
|
|
||||||
if ( useJava5 )
|
|
||||||
{
|
|
||||||
writer.write( " private static void toLines( List<String> lines, String line, int indentSize, int lineLength )"
|
|
||||||
+ LS );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writer.write( " private static void toLines( List lines, String line, int indentSize, int lineLength )"
|
|
||||||
+ LS );
|
|
||||||
}
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " int lineIndent = getIndentLevel( line );" + LS );
|
|
||||||
writer.write( " StringBuffer buf = new StringBuffer( 256 );" + LS );
|
|
||||||
writer.write( " String[] tokens = line.split( \" +\" );" + LS );
|
|
||||||
writer.write( " for ( int i = 0; i < tokens.length; i++ )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " String token = tokens[i];" + LS );
|
|
||||||
writer.write( " if ( i > 0 )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " if ( buf.length() + token.length() >= lineLength )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " lines.add( buf.toString() );" + LS );
|
|
||||||
writer.write( " buf.setLength( 0 );" + LS );
|
|
||||||
writer.write( " buf.append( repeat( \" \", lineIndent * indentSize ) );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " else" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " buf.append( ' ' );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " for ( int j = 0; j < token.length(); j++ )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " char c = token.charAt( j );" + LS );
|
|
||||||
writer.write( " if ( c == '\\t' )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " buf.append( repeat( \" \", indentSize - buf.length() % indentSize ) );"
|
|
||||||
+ LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " else if ( c == '\\u00A0' )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " buf.append( ' ' );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " else" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " buf.append( c );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " lines.add( buf.toString() );" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
|
|
||||||
writer.write( LS );
|
|
||||||
writer.write( " /** " + LS );
|
|
||||||
writer.write( " * Gets the indentation level of the specified line." + LS );
|
|
||||||
writer.write( " * " + LS );
|
|
||||||
writer.write( " * @param line The line whose indentation level should be retrieved, must not be "
|
|
||||||
+ "<code>null</code>." + LS );
|
|
||||||
writer.write( " * @return The indentation level of the line." + LS );
|
|
||||||
writer.write( " */" + LS );
|
|
||||||
writer.write( " private static int getIndentLevel( String line )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " int level = 0;" + LS );
|
|
||||||
writer.write( " for ( int i = 0; i < line.length() && line.charAt( i ) == '\\t'; i++ )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " level++;" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " if ( line.charAt( i ) == '\\t' )" + LS );
|
|
||||||
writer.write( " {" + LS );
|
|
||||||
writer.write( " level++;" + LS );
|
|
||||||
writer.write( " break;" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
writer.write( " return level;" + LS );
|
|
||||||
writer.write( " }" + LS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the effective string to use for the plugin/mojo/parameter description.
|
|
||||||
*
|
|
||||||
* @param description The description of the element, may be <code>null</code>.
|
|
||||||
* @return The effective description string, never <code>null</code>.
|
|
||||||
*/
|
|
||||||
private static String toDescription( String description )
|
|
||||||
{
|
|
||||||
if ( StringUtils.isNotEmpty( description ) )
|
|
||||||
{
|
|
||||||
return StringUtils.escape( PluginUtils.toText( description ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return "(no description available)";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a HTML fragment as extracted from a javadoc comment to a plain text string. This method tries to retain
|
|
||||||
* as much of the text formatting as possible by means of the following transformations:
|
|
||||||
* <ul>
|
|
||||||
* <li>List items are converted to leading tabs (U+0009), followed by the item number/bullet, another tab and
|
|
||||||
* finally the item contents. Each tab denotes an increase of indentation.</li>
|
|
||||||
* <li>Flow breaking elements as well as literal line terminators in preformatted text are converted to a newline
|
|
||||||
* (U+000A) to denote a mandatory line break.</li>
|
|
||||||
* <li>Consecutive spaces and line terminators from character data outside of preformatted text will be normalized
|
|
||||||
* to a single space. The resulting space denotes a possible point for line wrapping.</li>
|
|
||||||
* <li>Each space in preformatted text will be converted to a non-breaking space (U+00A0).</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @param html The HTML fragment to convert to plain text, may be <code>null</code>.
|
|
||||||
* @return A string with HTML tags converted into pure text, never <code>null</code>.
|
|
||||||
* @deprecated since 2.4.3, using {@link PluginUtils#toText(String)} instead of.
|
|
||||||
*/
|
|
||||||
protected static String toText( String html )
|
|
||||||
{
|
|
||||||
return PluginUtils.toText( html );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,17 @@ package org.apache.maven.tools.plugin.generator;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
|
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;
|
||||||
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||||
|
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -32,30 +43,21 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
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.project.MavenProject;
|
|
||||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
|
||||||
import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
|
|
||||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
|
||||||
import org.apache.maven.tools.plugin.util.PluginUtils;
|
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
|
||||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
|
||||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo add example usage tag that can be shown in the doco
|
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
* @todo add example usage tag that can be shown in the doco
|
||||||
*/
|
*/
|
||||||
public class PluginXdocGenerator
|
public class PluginXdocGenerator
|
||||||
implements Generator
|
implements Generator
|
||||||
{
|
{
|
||||||
/** locale */
|
/**
|
||||||
|
* locale
|
||||||
|
*/
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
|
|
||||||
/** project */
|
/**
|
||||||
|
* project
|
||||||
|
*/
|
||||||
private final MavenProject project;
|
private final MavenProject project;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,21 +98,19 @@ public class PluginXdocGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
public void execute( File destinationDirectory, PluginDescriptor pluginDescriptor )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
execute( destinationDirectory, new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public void execute( File destinationDirectory, PluginToolsRequest request )
|
public void execute( File destinationDirectory, PluginToolsRequest request )
|
||||||
throws IOException
|
throws GeneratorException
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if ( request.getPluginDescriptor().getMojos() != null )
|
if ( request.getPluginDescriptor().getMojos() != null )
|
||||||
{
|
{
|
||||||
for ( @SuppressWarnings( "unchecked" )
|
for ( @SuppressWarnings( "unchecked" ) Iterator<MojoDescriptor> it =
|
||||||
Iterator<MojoDescriptor> it = request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); )
|
request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
MojoDescriptor descriptor = it.next();
|
MojoDescriptor descriptor = it.next();
|
||||||
|
|
||||||
|
|
@ -118,6 +118,12 @@ public class PluginXdocGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new GeneratorException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mojoDescriptor not null
|
* @param mojoDescriptor not null
|
||||||
|
|
@ -455,8 +461,7 @@ public class PluginXdocGenerator
|
||||||
*/
|
*/
|
||||||
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
|
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
|
||||||
{
|
{
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" ) List<Parameter> parameterList = mojoDescriptor.getParameters();
|
||||||
List<Parameter> parameterList = mojoDescriptor.getParameters();
|
|
||||||
|
|
||||||
//remove components and read-only parameters
|
//remove components and read-only parameters
|
||||||
List<Parameter> list = filterParameters( parameterList );
|
List<Parameter> list = filterParameters( parameterList );
|
||||||
|
|
@ -570,8 +575,8 @@ public class PluginXdocGenerator
|
||||||
w.startElement( "ul" );
|
w.startElement( "ul" );
|
||||||
addedUl = true;
|
addedUl = true;
|
||||||
}
|
}
|
||||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.since" ),
|
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.since" ), mojoDescriptor.getSince(),
|
||||||
mojoDescriptor.getSince(), w );
|
w );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -582,8 +587,8 @@ public class PluginXdocGenerator
|
||||||
w.startElement( "ul" );
|
w.startElement( "ul" );
|
||||||
addedUl = true;
|
addedUl = true;
|
||||||
}
|
}
|
||||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ),
|
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ), getString( "pluginxdoc.yes" ),
|
||||||
getString( "pluginxdoc.yes" ), w );
|
w );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -592,8 +597,8 @@ public class PluginXdocGenerator
|
||||||
w.startElement( "ul" );
|
w.startElement( "ul" );
|
||||||
addedUl = true;
|
addedUl = true;
|
||||||
}
|
}
|
||||||
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ),
|
writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.required" ), getString( "pluginxdoc.no" ),
|
||||||
getString( "pluginxdoc.no" ), w );
|
w );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !addedUl && StringUtils.isNotEmpty( parameter.getExpression() ) )
|
if ( !addedUl && StringUtils.isNotEmpty( parameter.getExpression() ) )
|
||||||
|
|
@ -668,7 +673,8 @@ public class PluginXdocGenerator
|
||||||
* @param parameterList not null
|
* @param parameterList not null
|
||||||
* @param w not null
|
* @param w not null
|
||||||
*/
|
*/
|
||||||
private void writeParameterList( MojoDescriptor mojoDescriptor, String title, List<Parameter> parameterList, XMLWriter w )
|
private void writeParameterList( MojoDescriptor mojoDescriptor, String title, List<Parameter> parameterList,
|
||||||
|
XMLWriter w )
|
||||||
{
|
{
|
||||||
w.startElement( "subsection" );
|
w.startElement( "subsection" );
|
||||||
w.addAttribute( "name", title );
|
w.addAttribute( "name", title );
|
||||||
|
|
@ -722,8 +728,7 @@ public class PluginXdocGenerator
|
||||||
String description;
|
String description;
|
||||||
if ( StringUtils.isNotEmpty( parameter.getDeprecated() ) )
|
if ( StringUtils.isNotEmpty( parameter.getDeprecated() ) )
|
||||||
{
|
{
|
||||||
description =
|
description = format( "pluginxdoc.mojodescriptor.parameter.deprecated",
|
||||||
format( "pluginxdoc.mojodescriptor.parameter.deprecated",
|
|
||||||
PluginUtils.makeHtmlValid( parameter.getDeprecated() ) );
|
PluginUtils.makeHtmlValid( parameter.getDeprecated() ) );
|
||||||
}
|
}
|
||||||
else if ( StringUtils.isNotEmpty( parameter.getDescription() ) )
|
else if ( StringUtils.isNotEmpty( parameter.getDescription() ) )
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ package org.apache.maven.tools.plugin.generator;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.Parameter;
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||||
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
import org.codehaus.plexus.component.repository.ComponentDependency;
|
import org.codehaus.plexus.component.repository.ComponentDependency;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
|
|
@ -38,7 +40,7 @@ import java.util.List;
|
||||||
* jdcasey Exp $
|
* jdcasey Exp $
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractGeneratorTestCase
|
public abstract class AbstractGeneratorTestCase
|
||||||
extends TestCase
|
extends PlexusTestCase
|
||||||
{
|
{
|
||||||
protected Generator generator;
|
protected Generator generator;
|
||||||
|
|
||||||
|
|
@ -47,6 +49,7 @@ public abstract class AbstractGeneratorTestCase
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
super.setUp();
|
||||||
basedir = System.getProperty( "basedir" );
|
basedir = System.getProperty( "basedir" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +96,25 @@ public abstract class AbstractGeneratorTestCase
|
||||||
FileUtils.deleteDirectory( destinationDirectory );
|
FileUtils.deleteDirectory( destinationDirectory );
|
||||||
destinationDirectory.mkdir();
|
destinationDirectory.mkdir();
|
||||||
|
|
||||||
generator.execute( destinationDirectory, new DefaultPluginToolsRequest( null, pluginDescriptor ) );
|
MavenProject mavenProject = new MavenProject();
|
||||||
|
mavenProject.setGroupId( "foo" );
|
||||||
|
mavenProject.setArtifactId( "bar" );
|
||||||
|
mavenProject.setBuild( new Build()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String getDirectory()
|
||||||
|
{
|
||||||
|
return basedir + "/target";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOutputDirectory()
|
||||||
|
{
|
||||||
|
return basedir + "/target";
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
generator.execute( destinationDirectory, new DefaultPluginToolsRequest( mavenProject, pluginDescriptor ) );
|
||||||
|
|
||||||
validate( destinationDirectory );
|
validate( destinationDirectory );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ package org.apache.maven.tools.plugin.generator;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.codehaus.plexus.velocity.VelocityComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
|
@ -27,4 +29,12 @@ public class PluginHelpGeneratorTest
|
||||||
extends AbstractGeneratorTestCase
|
extends AbstractGeneratorTestCase
|
||||||
{
|
{
|
||||||
// inherits tests from base class
|
// inherits tests from base class
|
||||||
|
protected void setupGenerator()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
generator =
|
||||||
|
new PluginHelpGenerator().setVelocityComponent( (VelocityComponent) lookup( VelocityComponent.ROLE ) );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
pom.xml
18
pom.xml
|
|
@ -233,6 +233,24 @@
|
||||||
<artifactId>plexus-archiver</artifactId>
|
<artifactId>plexus-archiver</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>2.1.1</version>
|
||||||
</dependency>
|
</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>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.thoughtworks.qdox</groupId>
|
<groupId>com.thoughtworks.qdox</groupId>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue