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 09:20:29 UTC

svn commit: r415934 - in /maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck: AbstractCheckDocumentationMojo.java CheckPluginDocumentationMojo.java

Author: epunzalan
Date: Wed Jun 21 00:20:29 2006
New Revision: 415934

URL: http://svn.apache.org/viewvc?rev=415934&view=rev
Log:
PR: MNG-2397

- implemented check for usage.html and faq.html links inside site.xml
- removed plugin specific documentation rules from the abstract class

Modified:
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java
    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/AbstractCheckDocumentationMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java?rev=415934&r1=415933&r2=415934&view=diff
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java (original)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/AbstractCheckDocumentationMojo.java Wed Jun 21 00:20:29 2006
@@ -74,7 +74,7 @@
      * @parameter expression="${siteDirectory}" default-value="src/site"
      * @todo should be determined programmatically
      */
-    private File siteDirectory;
+    protected File siteDirectory;
 
     /**
      * Sets whether this plugin is running in offline or online mode. Also useful when you don't want
@@ -114,24 +114,25 @@
         {
             MavenProject project = (MavenProject) it.next();
 
-            if ( !approveProjectPackaging( project.getPackaging() ) )
+            if ( approveProjectPackaging( project.getPackaging() ) )
             {
-                getLog().info( "Skipping non-plugin project: " + project.getName() );
-                continue;
-            }
+                getLog().info( "Checking project: " + project.getName() );
 
-            getLog().info( "Checking project: " + project.getName() );
+                DocumentationReporter reporter = new DocumentationReporter();
 
-            DocumentationReporter reporter = new DocumentationReporter();
+                checkProject( project, reporter );
 
-            checkProject( project, reporter );
+                if ( !hasErrors && reporter.hasErrors() )
+                {
+                    hasErrors = true;
+                }
 
-            if ( !hasErrors && reporter.hasErrors() )
+                errors.put( project, reporter );
+            }
+            else
             {
-                hasErrors = true;
+                getLog().info( "Skipping unsupported project: " + project.getName() );
             }
-
-            errors.put( project, reporter );
         }
 
         String messages;
@@ -235,8 +236,6 @@
     {
         checkPomRequirements( project, reporter );
 
-        checkProjectSite( project, reporter );
-
         checkPackagingSpecificDocumentation( project, reporter );
     }
 
@@ -346,44 +345,6 @@
         //todo plugin report
     }
 
-    private void checkProjectSite( MavenProject project, DocumentationReporter reporter )
-    {
-        // check for site.xml
-        File siteXml = new File( siteDirectory, "site.xml" );
-
-        if ( !siteXml.exists() )
-        {
-            reporter.error( "site.xml is missing." );
-        }
-
-        /* disabled bec site:site generates a duplicate file error
-        // check for index.(xml|apt|html)
-        if ( !findFiles( siteDirectory, "index" ) )
-        {
-            errors.add( "Missing site index.(html|xml|apt)." );
-        }
-        */
-
-        // check for usage.(xml|apt|html)
-        if ( !findFiles( siteDirectory, "usage" ) )
-        {
-            reporter.error( "Missing base usage.(html|xml|apt)." );
-        }
-
-        // check for **/examples/**.(xml|apt|html)
-        if ( !findFiles( siteDirectory, "**/examples/*" ) && !findFiles( siteDirectory, "**/example*" ) )
-        {
-            reporter.error( "Missing examples." );
-        }
-
-        if ( !findFiles( siteDirectory, "faq" ) )
-        {
-            reporter.error( "Missing base FAQ.(fml|html|xml|apt)." );
-        }
-
-        //todo Project Site Descriptor for usage, faq, examples
-    }
-
     private void checkProjectLicenses( MavenProject project, DocumentationReporter reporter )
     {
         List licenses = project.getLicenses();
@@ -501,7 +462,7 @@
 
     protected abstract void checkPackagingSpecificDocumentation( MavenProject project, DocumentationReporter reporter );
 
-    private boolean findFiles( File siteDirectory, String pattern )
+    protected boolean findFiles( File siteDirectory, String pattern )
     {
         FileSet fs = new FileSet();
         fs.setDirectory( siteDirectory.getAbsolutePath() );

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=415934&r1=415933&r2=415934&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 Wed Jun 21 00:20:29 2006
@@ -25,10 +25,13 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.tools.plugin.extractor.ExtractionException;
 import org.apache.maven.tools.plugin.scanner.MojoScanner;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.io.File;
+import java.io.IOException;
 
 /**
  * Checks a plugin's documentation for the standard minimums.
@@ -115,11 +118,73 @@
         }
 
         checkConfiguredReportPlugins( project, reporter );
+
+        checkProjectSite( project, reporter );
     }
 
     protected boolean approveProjectPackaging( String packaging )
     {
         return "maven-plugin".equals( packaging );
+    }
+
+    private void checkProjectSite( MavenProject project, DocumentationReporter reporter )
+    {
+        // check for site.xml
+        File siteXml = new File( siteDirectory, "site.xml" );
+
+        if ( !siteXml.exists() )
+        {
+            reporter.error( "site.xml is missing." );
+        }
+        else
+        {
+            try
+            {
+                String siteHtml = FileUtils.fileRead( siteXml.getAbsolutePath() );
+
+                if ( siteHtml.indexOf( "href=\"usage.html\"" ) < 0 )
+                {
+                    reporter.error( "site.xml is missing link to: usage.html" );
+                }
+
+                if ( siteHtml.indexOf( "href=\"faq.html\"" ) < 0 )
+                {
+                    reporter.error( "site.xml is missing link to: faq.html" );
+                }
+            }
+            catch ( IOException e )
+            {
+                reporter.error( "Unable to read site.xml file: \'" + siteXml.getAbsolutePath() +
+                    "\'.\nError: " + e.getMessage() );
+            }
+        }
+
+        /* disabled bec site:site generates a duplicate file error
+        // check for index.(xml|apt|html)
+        if ( !findFiles( siteDirectory, "index" ) )
+        {
+            errors.add( "Missing site index.(html|xml|apt)." );
+        }
+        */
+
+        // check for usage.(xml|apt|html)
+        if ( !findFiles( siteDirectory, "usage" ) )
+        {
+            reporter.error( "Missing base usage.(html|xml|apt)." );
+        }
+
+        // check for **/examples/**.(xml|apt|html)
+        if ( !findFiles( siteDirectory, "**/examples/*" ) && !findFiles( siteDirectory, "**/example*" ) )
+        {
+            reporter.error( "Missing examples." );
+        }
+
+        if ( !findFiles( siteDirectory, "faq" ) )
+        {
+            reporter.error( "Missing base FAQ.(fml|html|xml|apt)." );
+        }
+
+        //todo Project Site Descriptor for usage, faq, examples
     }
 
     /**