You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ep...@apache.org on 2006/06/21 08:57:34 UTC
svn commit: r415927 -
/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java
Author: epunzalan
Date: Tue Jun 20 23:57:34 2006
New Revision: 415927
URL: http://svn.apache.org/viewvc?rev=415927&view=rev
Log:
PR: MNG-2397
implemented check for the required report plugins
Modified:
maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java
Modified: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java?rev=415927&r1=415926&r2=415927&view=diff
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java (original)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/CheckPluginDocumentationMojo.java Tue Jun 20 23:57:34 2006
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
@@ -25,6 +26,7 @@
import org.apache.maven.tools.plugin.extractor.ExtractionException;
import org.apache.maven.tools.plugin.scanner.MojoScanner;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -47,6 +49,9 @@
*/
protected MojoScanner mojoScanner;
+ // TODO: really a description of length 1 isn't all that helpful...
+ private static final int MIN_DESCRIPTION_LENGTH = 1;
+
protected void checkPackagingSpecificDocumentation( MavenProject project, DocumentationReporter reporter )
{
PluginDescriptor descriptor = new PluginDescriptor();
@@ -79,8 +84,7 @@
String mojoDescription = mojo.getDescription();
- // TODO: really a description of length 1 isn't all that helpful...
- if ( mojoDescription == null || mojoDescription.trim().length() < 1 )
+ if ( mojoDescription == null || mojoDescription.trim().length() < MIN_DESCRIPTION_LENGTH )
{
reporter.error( "Mojo: \'" + mojo.getGoal() + "\' is missing a description." );
}
@@ -94,11 +98,11 @@
{
Parameter param = (Parameter) paramIterator.next();
- if ( param.isEditable() )
+ if ( param.getRequirement() == null && param.isEditable() )
{
String paramDescription = param.getDescription();
- if ( paramDescription == null || paramDescription.trim().length() < 1 )
+ if ( paramDescription == null || paramDescription.trim().length() < MIN_DESCRIPTION_LENGTH )
{
reporter.error( "Parameter: \'" + param.getName() + "\' in mojo: \'" + mojo.getGoal() +
"\' is missing a description." );
@@ -109,10 +113,60 @@
}
}
}
+
+ checkConfiguredReportPlugins( project, reporter );
}
protected boolean approveProjectPackaging( String packaging )
{
return "maven-plugin".equals( packaging );
+ }
+
+ /**
+ * Checks the project configured plugins if the required report plugins are present
+ *
+ * @param project MavenProject to check
+ * @param reporter listener
+ * @todo maybe this should be checked default for all project?
+ */
+ private void checkConfiguredReportPlugins( MavenProject project, DocumentationReporter reporter )
+ {
+ List expectedPlugins = getRequiredPlugins();
+
+ List reportPlugins = project.getReportPlugins();
+ if ( reportPlugins != null && reportPlugins.size() > 0 )
+ {
+ for ( Iterator plugins = reportPlugins.iterator(); plugins.hasNext(); )
+ {
+ ReportPlugin plugin = (ReportPlugin) plugins.next();
+
+ expectedPlugins.remove( plugin.getArtifactId() );
+ }
+ }
+ else
+ {
+ reporter.error( "No report plugins configured." );
+ }
+
+ for ( Iterator plugins = expectedPlugins.iterator(); plugins.hasNext(); )
+ {
+ reporter.error( "Report plugin not found: " + plugins.next().toString() );
+ }
+ }
+
+ /**
+ * Returns a List of Strings of required report plugins
+ *
+ * @return List of report plugin artifactIds
+ */
+ private List getRequiredPlugins()
+ {
+ List list = new ArrayList();
+
+ list.add( "maven-javadoc-plugin" );
+ list.add( "maven-jxr-plugin" );
+ list.add( "maven-changelog-plugin" );
+
+ return list;
}
}