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 04:52:46 UTC

svn commit: r415878 - in /maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck: ./ reports/

Author: epunzalan
Date: Tue Jun 20 19:52:46 2006
New Revision: 415878

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

Committing what I currently have in progress...

 - created reporter classes
 - implemented POM minimum requirements for docs except the plugin reports section
 - implemented FAQ requirement in src/site
 - added support for offline mode during http url verification
 - some refactoring

Added:
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/AbstractDocumentationReport.java   (with props)
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReport.java   (with props)
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java   (with props)
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/ErrorDocumentationReport.java   (with props)
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/InfoDocumentationReport.java   (with props)
    maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/WarningDocumentationReport.java   (with props)
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=415878&r1=415877&r2=415878&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 Tue Jun 20 19:52:46 2006
@@ -20,20 +20,26 @@
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.methods.HeadMethod;
 import org.apache.maven.model.License;
+import org.apache.maven.model.IssueManagement;
+import org.apache.maven.model.Prerequisites;
+import org.apache.maven.model.Scm;
+import org.apache.maven.model.Organization;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.docck.reports.DocumentationReporter;
+import org.apache.maven.plugin.docck.reports.DocumentationReport;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.model.fileset.FileSet;
 import org.apache.maven.shared.model.fileset.util.FileSetManager;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -48,7 +54,6 @@
 public abstract class AbstractCheckDocumentationMojo
     extends AbstractMojo
 {
-
     /**
      * @parameter default-value="${reactorProjects}"
      * @readonly
@@ -63,6 +68,22 @@
      */
     private File output;
 
+    /**
+     * Directory to search for files used by maven-site-plugin
+     *
+     * @parameter expression="${siteDirectory}" default-value="src/site"
+     * @todo should be determined programmatically
+     */
+    private File siteDirectory;
+
+    /**
+     * Sets whether this plugin is running in offline or online mode. Also useful when you don't want
+     * to verify http URLs.
+     *
+     * @parameter expression="${offline}" default-value="false"
+     */
+    private boolean offline;
+
     private HttpClient httpClient;
 
     private FileSetManager fileSetManager = new FileSetManager();
@@ -99,44 +120,25 @@
                 continue;
             }
 
-            List projectErrors = checkProject( project );
+            getLog().info( "Checking project: " + project.getName() );
+
+            DocumentationReporter reporter = new DocumentationReporter();
 
-            hasErrors = hasErrors || !projectErrors.isEmpty();
+            checkProject( project, reporter );
+
+            if ( !hasErrors && reporter.hasErrors() )
+            {
+                hasErrors = true;
+            }
 
-            errors.put( project, projectErrors );
+            errors.put( project, reporter );
         }
 
         String messages;
 
         if ( hasErrors )
         {
-            StringBuffer buffer = new StringBuffer();
-            buffer.append( "\nThe following documentation problems were found:\n" );
-
-            for ( Iterator it = errors.entrySet().iterator(); it.hasNext(); )
-            {
-                Map.Entry entry = (Map.Entry) it.next();
-
-                MavenProject project = (MavenProject) entry.getKey();
-                List projectErrors = (List) entry.getValue();
-
-                if ( !projectErrors.isEmpty() )
-                {
-                    buffer.append( "\no " ).append( project.getName() );
-                    buffer.append( " (" ).append( projectErrors.size() ).append( " errors)" );
-
-                    for ( Iterator errorIterator = projectErrors.iterator(); errorIterator.hasNext(); )
-                    {
-                        String error = (String) errorIterator.next();
-
-                        buffer.append( "\n\t- " ).append( error );
-                    }
-
-                    buffer.append( "\n" );
-                }
-            }
-
-            messages = buffer.toString();
+            messages = buildErrorMessages( errors );
         }
         else
         {
@@ -168,6 +170,41 @@
         }
     }
 
+    private String buildErrorMessages( Map errors )
+    {
+        String messages;
+        StringBuffer buffer = new StringBuffer();
+        buffer.append( "\nThe following documentation problems were found:\n" );
+
+        for ( Iterator it = errors.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            MavenProject project = (MavenProject) entry.getKey();
+            DocumentationReporter reporter = (DocumentationReporter) entry.getValue();
+
+            if ( !reporter.getMessages().isEmpty() )
+            {
+                buffer.append( "\no " ).append( project.getName() );
+                buffer.append( " (" ).append( reporter.getMessagesByType( DocumentationReport.TYPE_ERROR ).size() )
+                      .append( " errors," );
+                buffer.append( " " ).append( reporter.getMessagesByType( DocumentationReport.TYPE_WARN ).size() )
+                      .append( " warnings)" );
+                for ( Iterator errorIterator = reporter.getMessages().iterator(); errorIterator.hasNext(); )
+                {
+                    String error = (String) errorIterator.next();
+
+                    buffer.append( "\n\t" ).append( error );
+                }
+
+                buffer.append( "\n" );
+            }
+        }
+
+        messages = buffer.toString();
+        return messages;
+    }
+
     protected abstract boolean approveProjectPackaging( String packaging );
 
     private void writeMessages( String messages )
@@ -194,18 +231,166 @@
         }
     }
 
-    private List checkProject( MavenProject project )
+    private void checkProject( MavenProject project, DocumentationReporter reporter )
+    {
+        checkPomRequirements( project, reporter );
+
+        checkProjectSite( project, reporter );
+
+        checkPackagingSpecificDocumentation( project, reporter );
+    }
+
+    private void checkPomRequirements( MavenProject project, DocumentationReporter reporter )
     {
-        getLog().info( "Checking project: " + project.getName() );
+        checkProjectLicenses( project, reporter );
 
-        List errors = new ArrayList();
+        if ( StringUtils.isEmpty( project.getName() ) )
+        {
+            reporter.error( "Missing tag <name>." );
+        }
 
-        // check for licenses
+        if ( StringUtils.isEmpty( project.getDescription() ) )
+        {
+            reporter.error( "Missing tag <description>." );
+        }
+
+        if ( StringUtils.isEmpty( project.getUrl() ) )
+        {
+            reporter.error( "Missing tag <url>." );
+        }
+        else
+        {
+            checkURL( project.getUrl(), "project site", reporter);
+        }
+
+        if ( project.getIssueManagement() == null )
+        {
+            reporter.error( "Missing tag <issueManagement>." );
+        }
+        else
+        {
+            IssueManagement issueMngt = project.getIssueManagement();
+            if ( StringUtils.isEmpty( issueMngt.getUrl() ) )
+            {
+                reporter.error( "Missing <url> tag in <issueManagement>." );
+            }
+            else
+            {
+                checkURL( issueMngt.getUrl(), "Issue Management", reporter );
+            }
+        }
+
+        if ( project.getPrerequisites() == null )
+        {
+            reporter.error( "Missing tag <prerequisites>" );
+        }
+        else
+        {
+            Prerequisites prereq = project.getPrerequisites();
+            if ( StringUtils.isEmpty( prereq.getMaven() ) )
+            {
+                reporter.error( "Missing <maven> tag in <prerequisites>");
+            }
+        }
+
+        if ( StringUtils.isEmpty( project.getInceptionYear() ) )
+        {
+            reporter.error( "Missing tag <inceptionYear>" );
+        }
+
+        if ( project.getMailingLists() == null )
+        {
+            reporter.warn( "Missing tag <mailingList>" );
+        }
+        else if ( project.getMailingLists().size() == 0 )
+        {
+            reporter.warn( "Empty tag <mailingList>" );
+        }
+
+        if ( project.getScm() == null )
+        {
+            reporter.warn( "Missing tag <scm>" );
+        }
+        else
+        {
+            Scm scm = project.getScm();
+            if ( StringUtils.isEmpty( scm.getConnection() ) &&
+                 StringUtils.isEmpty( scm.getDeveloperConnection() ) &&
+                 StringUtils.isEmpty( scm.getUrl() ) )
+            {
+                reporter.warn( "Missing children under the <scm> tag " );
+            }
+            else if ( scm.getUrl() != null )
+            {
+                checkURL( scm.getUrl(), "scm", reporter );
+            }
+        }
+
+        if ( project.getOrganization() == null )
+        {
+            reporter.error( "Missing tag <organization>" );
+        }
+        else
+        {
+            Organization org = project.getOrganization();
+            if ( StringUtils.isEmpty( org.getName() ) )
+            {
+                reporter.error( "Missing <name> tag in <organization>" );
+            }
+            else if ( org.getUrl() != null )
+            {
+                checkURL( org.getUrl(), org.getName() + " site", reporter );
+            }
+        }
+
+        //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();
 
         if ( licenses == null || licenses.isEmpty() )
         {
-            errors.add( "No license(s) specified." );
+            reporter.error( "No license(s) specified." );
         }
         else
         {
@@ -213,28 +398,51 @@
             {
                 License license = (License) it.next();
 
-                String url = license.getUrl();
-
-                String protocol = null;
-
-                try
+                if ( StringUtils.isEmpty( license.getName() ) )
                 {
-                    URL licenseUrl = new URL( url );
-
-                    protocol = licenseUrl.getProtocol();
-
-                    if ( protocol != null )
-                    {
-                        protocol = protocol.toLowerCase();
-                    }
+                    reporter.error( "Missing <name> tag in <license>" );
                 }
-                catch ( MalformedURLException e )
+                else
                 {
-                    getLog().debug( "License: " + license.getName() + " with appears to have an invalid URL: \'" + url +
-                        "\'.\nError: " + e.getMessage() + "\n\nTrying to access it as a file instead." );
+                    String url = license.getUrl();
+                    if ( StringUtils.isEmpty( url ) )
+                    {
+                        reporter.error( "No license URL provided for license " + license.getName() );
+                    }
+                    else
+                    {
+                        checkURL( url, "license " + license.getName(), reporter );
+                    }
                 }
+            }
+        }
+    }
+
+    private String getURLProtocol( String url )
+        throws MalformedURLException
+    {
+        String protocol;
+
+        URL licenseUrl = new URL( url );
+        protocol = licenseUrl.getProtocol();
+
+        if ( protocol != null )
+        {
+            protocol = protocol.toLowerCase();
+        }
+
+        return protocol;
+    }
 
-                if ( protocol != null && protocol.startsWith( "http" ) )
+    private void checkURL( String url, String description, DocumentationReporter reporter )
+    {
+        try
+        {
+            String protocol = getURLProtocol( url );
+
+            if ( protocol.startsWith( "http" ) )
+            {
+                if ( !offline )
                 {
                     HeadMethod headMethod = new HeadMethod( url );
                     headMethod.setFollowRedirects( true );
@@ -242,78 +450,56 @@
 
                     try
                     {
+                        getLog().debug( "Verifying http url: " + url );
                         if ( httpClient.executeMethod( headMethod ) != 200 )
                         {
-                            errors.add( "Cannot reach license: " + license.getName() + " with URL: \'" + url + "\'." );
+                            reporter.error( "Cannot reach " + description + " with URL: \'" + url + "\'." );
                         }
                     }
                     catch ( HttpException e )
                     {
-                        errors.add( "Cannot reach license: " + license.getName() + " with URL: \'" + url +
+                        reporter.error( "Cannot reach " + description + " with URL: \'" + url +
                             "\'.\nError: " + e.getMessage() );
                     }
                     catch ( IOException e )
                     {
-                        errors.add( "Cannot reach license: " + license.getName() + " with URL: \'" + url +
+                        reporter.error( "Cannot reach " + description + " with URL: \'" + url +
                             "\'.\nError: " + e.getMessage() );
                     }
                     finally
                     {
-                        if ( headMethod != null )
-                        {
-                            headMethod.releaseConnection();
-                        }
+                        headMethod.releaseConnection();
                     }
                 }
                 else
                 {
-                    // try looking for the file.
-                    File licenseFile = new File( url );
-                    if ( !licenseFile.exists() )
-                    {
-                        errors.add( "License file: \'" + licenseFile.getPath() + " does not exist." );
-                    }
+                    reporter.warn( "Cannot verify " + description + " in offline mode with URL: \'" + url + "\'." );
                 }
             }
+            else
+            {
+                reporter.warn( "Non-HTTP " + description + " URL not verified." );
+            }
         }
-
-        File siteDirectory = new File( project.getBasedir(), "src/site" );
-
-        // check for site.xml
-        File siteXml = new File( siteDirectory, "site.xml" );
-
-        if ( !siteXml.exists() )
-        {
-            errors.add( "site.xml is missing." );
-        }
-
-        /* disabled bec site:site generates a duplicate file error
-        // check for index.(xml|apt|html)
-        if ( !findFiles( siteDirectory, "index" ) )
+        catch ( MalformedURLException e )
         {
-            errors.add( "Missing site index.(html|xml|apt)." );
-        }
-        */
+            reporter.warn( description + " appears to have an invalid URL: \'" + url +
+                "\'.\nError: " + e.getMessage() + "\n\nTrying to access it as a file instead." );
 
-        // check for usage.(xml|apt|html)
-        if ( !findFiles( siteDirectory, "usage" ) )
-        {
-            errors.add( "Missing base usage.(html|xml|apt)." );
+            checkFile( url, description, reporter );
         }
+    }
 
-        // check for **/examples/**.(xml|apt|html)
-        if ( !findFiles( siteDirectory, "**/examples/*" ) && !findFiles( siteDirectory, "**/example*" ) )
+    private void checkFile( String url, String description, DocumentationReporter reporter )
+    {
+        File licenseFile = new File( url );
+        if ( !licenseFile.exists() )
         {
-            errors.add( "Missing examples." );
+            reporter.error( description + " file: \'" + licenseFile.getPath() + " does not exist." );
         }
-
-        checkPackagingSpecificDocumentation( project, errors, siteDirectory );
-
-        return errors;
     }
 
-    protected abstract void checkPackagingSpecificDocumentation( MavenProject project, List errors,
-                                                                 File siteDirectory );
+    protected abstract void checkPackagingSpecificDocumentation( MavenProject project, DocumentationReporter reporter );
 
     private boolean findFiles( File siteDirectory, String pattern )
     {

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=415878&r1=415877&r2=415878&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 19:52:46 2006
@@ -20,11 +20,11 @@
 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.plugin.docck.reports.DocumentationReporter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.tools.plugin.extractor.ExtractionException;
 import org.apache.maven.tools.plugin.scanner.MojoScanner;
 
-import java.io.File;
 import java.util.Iterator;
 import java.util.List;
 
@@ -47,7 +47,7 @@
      */
     protected MojoScanner mojoScanner;
 
-    protected void checkPackagingSpecificDocumentation( MavenProject project, List errors, File siteDirectory )
+    protected void checkPackagingSpecificDocumentation( MavenProject project, DocumentationReporter reporter )
     {
         PluginDescriptor descriptor = new PluginDescriptor();
 
@@ -57,12 +57,12 @@
         }
         catch ( InvalidPluginDescriptorException e )
         {
-            errors.add( "Failed to parse mojo descriptors.\nError: " + e.getMessage() );
+            reporter.error( "Failed to parse mojo descriptors.\nError: " + e.getMessage() );
             descriptor = null;
         }
         catch ( ExtractionException e )
         {
-            errors.add( "Failed to parse mojo descriptors.\nError: " + e.getMessage() );
+            reporter.error( "Failed to parse mojo descriptors.\nError: " + e.getMessage() );
             descriptor = null;
         }
 
@@ -82,7 +82,7 @@
                     // TODO: really a description of length 1 isn't all that helpful...
                     if ( mojoDescription == null || mojoDescription.trim().length() < 1 )
                     {
-                        errors.add( "Mojo: \'" + mojo.getGoal() + "\' is missing a description." );
+                        reporter.error( "Mojo: \'" + mojo.getGoal() + "\' is missing a description." );
                     }
 
                     List params = mojo.getParameters();
@@ -100,7 +100,7 @@
 
                                 if ( paramDescription == null || paramDescription.trim().length() < 1 )
                                 {
-                                    errors.add( "Parameter: \'" + param.getName() + "\' in mojo: \'" + mojo.getGoal() +
+                                    reporter.error( "Parameter: \'" + param.getName() + "\' in mojo: \'" + mojo.getGoal() +
                                         "\' is missing a description." );
                                 }
                             }
@@ -115,5 +115,4 @@
     {
         return "maven-plugin".equals( packaging );
     }
-
 }

Added: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/AbstractDocumentationReport.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/AbstractDocumentationReport.java?rev=415878&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/AbstractDocumentationReport.java (added)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/AbstractDocumentationReport.java Tue Jun 20 19:52:46 2006
@@ -0,0 +1,36 @@
+package org.apache.maven.plugin.docck.reports;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public abstract class AbstractDocumentationReport
+    implements DocumentationReport
+{
+    private String message;
+
+    public AbstractDocumentationReport( String message )
+    {
+        this.message = message;
+    }
+
+    public String getMessage()
+    {
+        return message;
+    }
+}

Propchange: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/AbstractDocumentationReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReport.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReport.java?rev=415878&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReport.java (added)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReport.java Tue Jun 20 19:52:46 2006
@@ -0,0 +1,31 @@
+package org.apache.maven.plugin.docck.reports;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public interface DocumentationReport
+{
+    static final int TYPE_INFO = 1;
+    static final int TYPE_WARN = 2;
+    static final int TYPE_ERROR = 3;
+
+    String getMessage();
+
+    int getType();
+}

Propchange: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java?rev=415878&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java (added)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java Tue Jun 20 19:52:46 2006
@@ -0,0 +1,96 @@
+package org.apache.maven.plugin.docck.reports;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class DocumentationReporter
+{
+    List reports = new ArrayList();
+
+    public void info( String message )
+    {
+        reports.add( new InfoDocumentationReport( "[INFO]  " + message ) );
+    }
+
+    public void warn( String message )
+    {
+        reports.add( new WarningDocumentationReport( "[WARN]  " + message ) );
+    }
+
+    public void error( String message )
+    {
+        reports.add( new ErrorDocumentationReport( "[ERROR] " + message ) );
+    }
+
+    public List getMessagesByType( int type )
+    {
+        List list = new ArrayList();
+
+        for( Iterator iter = reports.iterator(); iter.hasNext(); )
+        {
+            DocumentationReport report = (DocumentationReport) iter.next();
+
+            if ( report.getType() == type )
+            {
+                list.add( report.getMessage() );
+            }
+        }
+
+        return list;
+    }
+
+    public List getMessages()
+    {
+        List list = new ArrayList();
+
+        for( Iterator iter = reports.iterator(); iter.hasNext(); )
+        {
+            DocumentationReport report = (DocumentationReport) iter.next();
+
+            list.add( report.getMessage() );
+        }
+
+        return list;
+    }
+
+    public boolean hasErrors()
+    {
+        for( Iterator iter = reports.iterator(); iter.hasNext(); )
+        {
+            DocumentationReport report = (DocumentationReport) iter.next();
+
+            if ( report.getType() == DocumentationReport.TYPE_ERROR )
+            {
+                //first occurrence will do
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public void clear()
+    {
+        reports.clear();
+    }
+}

Propchange: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/DocumentationReporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/ErrorDocumentationReport.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/ErrorDocumentationReport.java?rev=415878&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/ErrorDocumentationReport.java (added)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/ErrorDocumentationReport.java Tue Jun 20 19:52:46 2006
@@ -0,0 +1,34 @@
+package org.apache.maven.plugin.docck.reports;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class ErrorDocumentationReport
+    extends AbstractDocumentationReport
+{
+    public ErrorDocumentationReport( String message )
+    {
+        super( message );
+    }
+
+    public int getType()
+    {
+        return DocumentationReport.TYPE_ERROR;
+    }
+}

Propchange: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/ErrorDocumentationReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/InfoDocumentationReport.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/InfoDocumentationReport.java?rev=415878&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/InfoDocumentationReport.java (added)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/InfoDocumentationReport.java Tue Jun 20 19:52:46 2006
@@ -0,0 +1,34 @@
+package org.apache.maven.plugin.docck.reports;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class InfoDocumentationReport
+    extends AbstractDocumentationReport
+{
+    public InfoDocumentationReport( String message )
+    {
+        super( message );
+    }
+
+    public int getType()
+    {
+        return DocumentationReport.TYPE_INFO;
+    }
+}

Propchange: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/InfoDocumentationReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/WarningDocumentationReport.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/WarningDocumentationReport.java?rev=415878&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/WarningDocumentationReport.java (added)
+++ maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/WarningDocumentationReport.java Tue Jun 20 19:52:46 2006
@@ -0,0 +1,34 @@
+package org.apache.maven.plugin.docck.reports;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class WarningDocumentationReport
+    extends AbstractDocumentationReport
+{
+    public WarningDocumentationReport( String message )
+    {
+        super( message );
+    }
+
+    public int getType()
+    {
+        return DocumentationReport.TYPE_WARN;
+    }
+}

Propchange: maven/sandbox/plugins/maven-docck-plugin/src/main/java/org/apache/maven/plugin/docck/reports/WarningDocumentationReport.java
------------------------------------------------------------------------------
    svn:eol-style = native