You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2008/08/28 11:47:19 UTC
svn commit: r689770 -
/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/
Author: vsiveton
Date: Thu Aug 28 02:47:18 2008
New Revision: 689770
URL: http://svn.apache.org/viewvc?rev=689770&view=rev
Log:
o fixed checkstyle
Modified:
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java Thu Aug 28 02:47:18 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.plugins.help;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.plugins.help;
import java.io.File;
import java.io.IOException;
@@ -58,10 +59,10 @@
extends AbstractHelpMojo
{
/** The POM XSD URL */
- private static final String POM_XSD_URL ="http://maven.apache.org/maven-v4_0_0.xsd";
+ private static final String POM_XSD_URL = "http://maven.apache.org/maven-v4_0_0.xsd";
/** The Settings XSD URL */
- private static final String SETTINGS_XSD_URL ="http://maven.apache.org/xsd/settings-1.0.0.xsd";
+ private static final String SETTINGS_XSD_URL = "http://maven.apache.org/xsd/settings-1.0.0.xsd";
/**
* Utility method to write an XML content in a given file.
@@ -200,6 +201,7 @@
protected static class SortedProperties
extends Properties
{
+ /** serialVersionUID */
static final long serialVersionUID = -8985316072702233744L;
/** {@inheritDoc} */
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java Thu Aug 28 02:47:18 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.plugins.help;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.plugins.help;
import java.io.File;
import java.io.IOException;
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java Thu Aug 28 02:47:18 2008
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.StringTokenizer;
-import org.apache.maven.BuildFailureException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
@@ -181,7 +180,8 @@
/**
* The goal name of a Mojo to describe within the specified Maven Plugin.
- * If this parameter is specified, only the corresponding Mojo (goal) will be described, rather than the whole Plugin.
+ * If this parameter is specified, only the corresponding Mojo (goal) will be described,
+ * rather than the whole Plugin.
*
* @parameter expression="${mojo}"
*/
@@ -269,7 +269,7 @@
* Method to write the Mojo description into the output file
*
* @param descriptionBuffer contains the description to be written to the file
- * @throws MojoExecutionException
+ * @throws MojoExecutionException if any
*/
private void writeDescription( StringBuffer descriptionBuffer )
throws MojoExecutionException
@@ -314,31 +314,31 @@
Plugin forLookup = null;
- if ( StringUtils.isNotEmpty( pi.prefix ) )
+ if ( StringUtils.isNotEmpty( pi.getPrefix() ) )
{
- descriptor = pluginManager.getPluginDescriptorForPrefix( pi.prefix );
+ descriptor = pluginManager.getPluginDescriptorForPrefix( pi.getPrefix() );
if ( descriptor == null )
{
- forLookup = pluginManager.getPluginDefinitionForPrefix( pi.prefix, session, project );
+ forLookup = pluginManager.getPluginDefinitionForPrefix( pi.getPrefix(), session, project );
}
}
- else if ( StringUtils.isNotEmpty( pi.groupId ) && StringUtils.isNotEmpty( pi.artifactId ) )
+ else if ( StringUtils.isNotEmpty( pi.getGroupId() ) && StringUtils.isNotEmpty( pi.getArtifactId() ) )
{
forLookup = new Plugin();
- forLookup.setGroupId( pi.groupId );
- forLookup.setArtifactId( pi.artifactId );
+ forLookup.setGroupId( pi.getGroupId() );
+ forLookup.setArtifactId( pi.getArtifactId() );
- if ( StringUtils.isNotEmpty( pi.version ) )
+ if ( StringUtils.isNotEmpty( pi.getVersion() ) )
{
- forLookup.setVersion( pi.version );
+ forLookup.setVersion( pi.getVersion() );
}
}
else
{
StringBuffer msg = new StringBuffer();
- msg.append( "You must either specify 'groupId' and 'artifactId' both parameters, or a valid 'plugin' " +
- "parameter. For instance:\n" );
+ msg.append( "You must either specify 'groupId' and 'artifactId' both parameters, or a valid 'plugin' "
+ + "parameter. For instance:\n" );
msg.append( " # mvn help:describe -Dplugin=org.apache.maven.plugins:maven-help-plugin\n" );
msg.append( "or\n" );
msg.append( " # mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-help-plugin\n\n" );
@@ -428,16 +428,16 @@
switch ( pluginParts.length )
{
case ( 1 ):
- pi.prefix = pluginParts[0];
+ pi.setPrefix( pluginParts[0] );
break;
case ( 2 ):
- pi.groupId = pluginParts[0];
- pi.artifactId = pluginParts[1];
+ pi.setGroupId( pluginParts[0] );
+ pi.setArtifactId( pluginParts[1] );
break;
case ( 3 ):
- pi.groupId = pluginParts[0];
- pi.artifactId = pluginParts[1];
- pi.version = pluginParts[2];
+ pi.setGroupId( pluginParts[0] );
+ pi.setArtifactId( pluginParts[1] );
+ pi.setVersion( pluginParts[2] );
break;
default:
throw new MojoFailureException( "plugin parameter must be a plugin prefix,"
@@ -446,14 +446,14 @@
}
else
{
- pi.prefix = plugin;
+ pi.setPrefix( plugin );
}
}
else
{
- pi.groupId = groupId;
- pi.artifactId = artifactId;
- pi.version = version;
+ pi.setGroupId( groupId );
+ pi.setArtifactId( artifactId );
+ pi.setVersion( version );
}
}
@@ -578,7 +578,7 @@
if ( StringUtils.isNotEmpty( eGoal ) || StringUtils.isNotEmpty( ePhase ) )
{
- append( buffer, "Before this mojo executes, it will call:", 1);
+ append( buffer, "Before this mojo executes, it will call:", 1 );
if ( StringUtils.isNotEmpty( eGoal ) )
{
@@ -747,17 +747,15 @@
if ( lifecycleMapping.getPhases( "default" ).get( key ) != null )
{
- descriptionBuffer.append( lifecycleMapping.getPhases( "default" ).get( key ) ).append(
- "\n" );
+ descriptionBuffer.append( lifecycleMapping.getPhases( "default" ).get( key ) );
+ descriptionBuffer.append( "\n" );
}
}
descriptionBuffer.append( "\n" );
- descriptionBuffer.append(
- "It is a part of the lifecycle for the POM packaging '"
- + project.getPackaging()
- + "'. This lifecycle includes the following phases:" ).append(
- "\n" );
+ descriptionBuffer.append( "It is a part of the lifecycle for the POM packaging '"
+ + project.getPackaging() + "'. This lifecycle includes the following phases:" );
+ descriptionBuffer.append( "\n" );
for ( Iterator it = lifecycle.getPhases().iterator(); it.hasNext(); )
{
String key = (String) it.next();
@@ -954,7 +952,8 @@
* <b>Note</b>: The last character is always a new line.
*
* @param sb The buffer to append the description, not <code>null</code>.
- * @param description The description, not <code>null</code>.
+ * @param key The key, not <code>null</code>.
+ * @param value The value, could be <code>null</code>.
* @param indent The base indentation level of each line, must not be negative.
* @throws MojoFailureException if any reflection exceptions occur.
* @throws MojoExecutionException if any
@@ -1000,20 +999,135 @@
return "(no description available)";
}
- protected static class PluginInfo
+ /**
+ * Class to wrap Plugin information.
+ */
+ static class PluginInfo
{
- String prefix;
+ private String prefix;
+
+ private String groupId;
+
+ private String artifactId;
+
+ private String version;
+
+ private String mojo;
+
+ private Plugin plugin;
+
+ private PluginDescriptor pluginDescriptor;
+
+ /**
+ * @return the prefix
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ /**
+ * @param prefix the prefix to set
+ */
+ public void setPrefix( String prefix )
+ {
+ this.prefix = prefix;
+ }
+
+ /**
+ * @return the groupId
+ */
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ /**
+ * @param groupId the groupId to set
+ */
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
- String groupId;
+ /**
+ * @return the artifactId
+ */
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ /**
+ * @param artifactId the artifactId to set
+ */
+ public void setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ }
+
+ /**
+ * @return the version
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * @param version the version to set
+ */
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+ /**
+ * @return the mojo
+ */
+ public String getMojo()
+ {
+ return mojo;
+ }
- String artifactId;
+ /**
+ * @param mojo the mojo to set
+ */
+ public void setMojo( String mojo )
+ {
+ this.mojo = mojo;
+ }
- String version;
+ /**
+ * @return the plugin
+ */
+ public Plugin getPlugin()
+ {
+ return plugin;
+ }
- String mojo;
+ /**
+ * @param plugin the plugin to set
+ */
+ public void setPlugin( Plugin plugin )
+ {
+ this.plugin = plugin;
+ }
- Plugin plugin;
+ /**
+ * @return the pluginDescriptor
+ */
+ public PluginDescriptor getPluginDescriptor()
+ {
+ return pluginDescriptor;
+ }
- PluginDescriptor pluginDescriptor;
+ /**
+ * @param pluginDescriptor the pluginDescriptor to set
+ */
+ public void setPluginDescriptor( PluginDescriptor pluginDescriptor )
+ {
+ this.pluginDescriptor = pluginDescriptor;
+ }
}
}
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java Thu Aug 28 02:47:18 2008
@@ -265,7 +265,7 @@
private static String getUserName()
{
String userName = System.getProperty( "user.name" );
- if ( StringUtils.isEmpty( userName ))
+ if ( StringUtils.isEmpty( userName ) )
{
return "unknown";
}
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java Thu Aug 28 02:47:18 2008
@@ -472,7 +472,12 @@
getLog().info( "\n" + response.toString() );
}
- private String toXML( String question, Object obj )
+ /**
+ * @param expression the user expression.
+ * @param obj a not null.
+ * @return the XML for the given object.
+ */
+ private String toXML( String expression, Object obj )
{
XStream currentXStream = getXStream();
@@ -490,9 +495,9 @@
else
{
// try to detect the alias from question
- if ( question.indexOf( "." ) != -1 )
+ if ( expression.indexOf( "." ) != -1 )
{
- String name = question.substring( question.indexOf( "." ) + 1, question.indexOf( "}" ) );
+ String name = expression.substring( expression.indexOf( "." ) + 1, expression.indexOf( "}" ) );
currentXStream.alias( name, List.class );
}
}
@@ -611,9 +616,8 @@
try
{
Class clazz = ClassUtils.getClass( name );
- xstreamObject.alias(
- StringUtils.lowercaseFirstLetter( ClassUtils.getShortClassName( clazz ) ),
- clazz );
+ String alias = StringUtils.lowercaseFirstLetter( ClassUtils.getShortClassName( clazz ) );
+ xstreamObject.alias( alias, clazz );
if ( !clazz.equals( Model.class ) )
{
xstreamObject.omitField( clazz, "modelEncoding" ); // unnecessary field
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java Thu Aug 28 02:47:18 2008
@@ -45,6 +45,7 @@
public class ExpressionsMojo
extends AbstractHelpMojo
{
+ /** English sentence when no description exists */
private static final String NO_DESCRIPTION_AVAILABLE = "No description available.";
// ----------------------------------------------------------------------
@@ -71,17 +72,19 @@
{
String expression = (String) it.next();
- sb.append( "${" ).append( expression ).append( "}: " ).append( NO_DESCRIPTION_AVAILABLE );
+ sb.append( "${" ).append( expression ).append( "}: " );
+ sb.append( NO_DESCRIPTION_AVAILABLE );
sb.append( "\n\n" );
}
for ( Iterator it = m.keySet().iterator(); it.hasNext(); )
{
String key = (String) it.next();
-
Expression expression = (Expression) m.get( key );
- sb.append( "${" ).append( key ).append( "}: " ).append( trimCDATA( expression.getDescription() ) ).append(
- "\n\n" );
+
+ sb.append( "${" ).append( key ).append( "}: " );
+ sb.append( trimCDATA( expression.getDescription() ) );
+ sb.append( "\n\n" );
}
if ( output != null )
@@ -117,7 +120,7 @@
/**
* @return the value of the private static field <code>ExpressionDocumenter#EXPRESSION_ROOTS</code>.
* @throws MojoFailureException if any reflection exceptions occur
- * @throws MojoFailureException if no value exists for <code>ExpressionDocumenter#EXPRESSION_ROOTS</code>
+ * @throws MojoExecutionException if no value exists for <code>ExpressionDocumenter#EXPRESSION_ROOTS</code>
*/
private static List getExpressionsRoot()
throws MojoFailureException, MojoExecutionException
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java Thu Aug 28 02:47:18 2008
@@ -45,8 +45,8 @@
public class HelpUtil
{
/**
- * Invoke the following private method
- * <code>DefaultLifecycleExecutor#getMojoDescriptor(String, MavenSession, MavenProject, String, boolean, boolean)</code>
+ * Invoke the following private method <code>
+ * DefaultLifecycleExecutor#getMojoDescriptor(String, MavenSession, MavenProject, String, boolean, boolean)</code>
*
* @param task not null
* @param session not null
Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java?rev=689770&r1=689769&r2=689770&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java (original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java Thu Aug 28 02:47:18 2008
@@ -40,6 +40,9 @@
public class SystemMojo
extends AbstractHelpMojo
{
+ /** Magic number to beautify the output */
+ private static final int REPEAT = 25;
+
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@@ -52,9 +55,9 @@
message.append( '\n' );
message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
- message.append( StringUtils.repeat( "=", 25 ) );
+ message.append( StringUtils.repeat( "=", REPEAT ) );
message.append( " Platform Properties Details " );
- message.append( StringUtils.repeat( "=", 25 ) ).append( '\n' );
+ message.append( StringUtils.repeat( "=", REPEAT ) ).append( '\n' );
message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
message.append( '\n' );