You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2012/05/26 19:06:12 UTC
svn commit: r1342927 -
/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
Author: hboutemy
Date: Sat May 26 17:06:12 2012
New Revision: 1342927
URL: http://svn.apache.org/viewvc?rev=1342927&view=rev
Log:
improved documentation
Modified:
maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
Modified: maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java?rev=1342927&r1=1342926&r2=1342927&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Sat May 26 17:06:12 2012
@@ -28,6 +28,7 @@ import org.apache.maven.project.MavenPro
import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.PropertyUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
@@ -51,7 +52,8 @@ import java.util.Properties;
import java.util.Set;
/**
- * Generate a <a href="/ref/current/maven-plugin-api/plugin.html">Maven Plugin Descriptor XML file</a>.
+ * Generate a <a href="/ref/current/maven-plugin-api/plugin.html">Maven Plugin Descriptor XML file</a> and
+ * corresponding help content.
*
* @version $Id$
* @todo add example usage tag that can be shown in the doco
@@ -74,22 +76,10 @@ public class PluginDescriptorGenerator
if ( tmpPropertiesFile.exists() )
{
- Properties properties = new Properties();
- FileInputStream fis = null;
- try
- {
- fis = new FileInputStream( tmpPropertiesFile );
- properties.load( fis );
- }
- catch ( IOException e )
- {
- throw new GeneratorException( e.getMessage(), e );
- }
- finally
- {
- IOUtil.close( fis );
- }
+ Properties properties = PropertyUtils.loadProperties( tmpPropertiesFile );
+
String helpPackageName = properties.getProperty( "helpPackageName" );
+
// if helpPackageName property is empty we have to rewrite the class with a better package name than empty
if ( StringUtils.isEmpty( helpPackageName ) )
{
@@ -105,8 +95,11 @@ public class PluginDescriptorGenerator
try
{
+ // write complete plugin.xml descriptor
File f = new File( destinationDirectory, "plugin.xml" );
writeDescriptor( f, request, false );
+
+ // write plugin-description.xml help-descriptor
MavenProject mavenProject = request.getProject();
String pluginDescriptionFilePath =
"META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId()
@@ -124,7 +117,7 @@ public class PluginDescriptorGenerator
}
}
- public void writeDescriptor( File destinationFile, PluginToolsRequest request, boolean cleanDescription )
+ public void writeDescriptor( File destinationFile, PluginToolsRequest request, boolean helpDescriptor )
throws IOException, DuplicateMojoDescriptorException
{
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
@@ -153,7 +146,7 @@ public class PluginDescriptorGenerator
w.startElement( "plugin" );
GeneratorUtils.element( w, "name", pluginDescriptor.getName() );
- if ( cleanDescription )
+ if ( helpDescriptor )
{
GeneratorUtils.element( w, "description", GeneratorUtils.toText( pluginDescriptor.getDescription() ) );
}
@@ -181,7 +174,7 @@ public class PluginDescriptorGenerator
@SuppressWarnings( "unchecked" ) List<MojoDescriptor> descriptors = pluginDescriptor.getMojos();
for ( MojoDescriptor descriptor : descriptors )
{
- processMojoDescriptor( descriptor, w, cleanDescription );
+ processMojoDescriptor( descriptor, w, helpDescriptor );
}
}
@@ -208,9 +201,9 @@ public class PluginDescriptorGenerator
/**
* @param mojoDescriptor not null
* @param w not null
- * @param cleanDescription will clean html content from description fields
+ * @param helpDescriptor will clean html content from description fields
*/
- protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, boolean cleanDescription )
+ protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, boolean helpDescriptor )
{
w.startElement( "mojo" );
@@ -231,7 +224,7 @@ public class PluginDescriptorGenerator
if ( description != null )
{
w.startElement( "description" );
- if ( cleanDescription )
+ if ( helpDescriptor )
{
w.writeText( GeneratorUtils.toText( mojoDescriptor.getDescription() ) );
}
@@ -482,7 +475,7 @@ public class PluginDescriptorGenerator
GeneratorUtils.element( w, "required", Boolean.toString( parameter.isRequired() ) );
GeneratorUtils.element( w, "editable", Boolean.toString( parameter.isEditable() ) );
- if ( cleanDescription )
+ if ( helpDescriptor )
{
GeneratorUtils.element( w, "description", GeneratorUtils.toText( parameter.getDescription() ) );
}