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 2006/09/13 15:28:27 UTC

svn commit: r442981 [1/3] - in /maven/plugins/trunk/maven-antlr-plugin: ./ src/main/java/org/apache/maven/plugin/antlr/ src/main/resources/ src/site/apt/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/mav...

Author: vsiveton
Date: Wed Sep 13 06:28:25 2006
New Revision: 442981

URL: http://svn.apache.org/viewvc?view=rev&rev=442981
Log:
MANTLR-9: Adding Antlr report

o refactoring to add report support
o added test cases
o updated documentation
o updated dependencies
- bumped dependencies (maven-plugin-api => 2.0.4)
- added dependencies (maven-reporting-impl, maven-plugin-testing-harness)

Added:
    maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AbstractAntlrMojo.java   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrHtmlReport.java   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/NoExitSecurityManager.java   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/main/resources/
    maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report.properties   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report_fr.properties   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/test/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/AntlrTest.java   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/DefaultArtifactHandlerStub.java   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/JavaGrammarTestMavenProjectStub.java   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/java-grammar-report-test-plugin-config.xml   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/src/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/src/main/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/src/main/antlr/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/src/main/antlr/java15.g   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-test/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-test/java-grammar-test-plugin-config.xml   (with props)
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-test/src/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-test/src/main/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-test/src/main/antlr/
    maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-test/src/main/antlr/java15.g   (with props)
Modified:
    maven/plugins/trunk/maven-antlr-plugin/pom.xml
    maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrPlugin.java
    maven/plugins/trunk/maven-antlr-plugin/src/site/apt/index.apt
    maven/plugins/trunk/maven-antlr-plugin/src/site/apt/usage.apt

Modified: maven/plugins/trunk/maven-antlr-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/pom.xml?view=diff&rev=442981&r1=442980&r2=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-antlr-plugin/pom.xml Wed Sep 13 06:28:25 2006
@@ -38,18 +38,24 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.0</version>
+      <version>2.0.4</version>
     </dependency>
     <dependency>
       <groupId>antlr</groupId>
       <artifactId>antlrall</artifactId>
       <version>2.7.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.reporting</groupId>
+      <artifactId>maven-reporting-impl</artifactId>
+      <version>2.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-plugin-testing-harness</artifactId>
+      <version>1.0-beta-2-SNAPSHOT</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 </project>

Added: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AbstractAntlrMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AbstractAntlrMojo.java?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AbstractAntlrMojo.java (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AbstractAntlrMojo.java Wed Sep 13 06:28:25 2006
@@ -0,0 +1,324 @@
+package org.apache.maven.plugin.antlr;
+
+/*
+ * 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.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+
+import antlr.Tool;
+
+/**
+ * Base class with majority of Antlr functionalities.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public abstract class AbstractAntlrMojo
+    extends AbstractMojo
+{
+    // ----------------------------------------------------------------------
+    // Mojo parameters
+    // ----------------------------------------------------------------------
+
+    /**
+     * Specifies the Antlr directory containing grammar files.
+     *
+     * @parameter expression="${basedir}/src/main/antlr"
+     * @required
+     */
+    protected File sourceDirectory;
+
+    /**
+     * The Maven Project Object
+     *
+     * @parameter expression="${project}"
+     * @required
+     */
+    protected MavenProject project;
+
+    // ----------------------------------------------------------------------
+    // Antlr parameters
+    // @see http://www.antlr.org/doc/options.html#Command%20Line%20Options
+    // ----------------------------------------------------------------------
+
+    /**
+     * Specifies the destination directory where Antlr should generate files.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${project.build.directory}/generated-sources/antlr"
+     * @required
+     */
+    protected File outputDirectory;
+
+    /**
+     * Comma separated grammar file names present in the <code>sourceDirectory</code> directory.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${grammars}"
+     * @required
+     */
+    protected String grammars;
+
+    /**
+     * Launch the ParseView debugger upon parser invocation.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${debug}" default-value="false"
+     */
+    private boolean debug;
+
+    /**
+     * Generate a text file from your grammar with a lot of debugging info.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${diagnostic}" default-value="false"
+     */
+    private boolean diagnostic;
+
+    /**
+     * Have all rules call traceIn/traceOut.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${trace}" default-value="false"
+     */
+    private boolean trace;
+
+    /**
+     * Have parser rules call traceIn/traceOut.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${traceParser}" default-value="false"
+     */
+    private boolean traceParser;
+
+    /**
+     * Have lexer rules call traceIn/traceOut.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${traceLexer}" default-value="false"
+     */
+    private boolean traceLexer;
+
+    /**
+     * Have tree rules call traceIn/traceOut.
+     * <br/>
+     * See <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+     *
+     * @parameter expression="${traceTreeParser}" default-value="false"
+     */
+    private boolean traceTreeParser;
+
+    /**
+     * @throws MojoExecutionException
+     */
+    protected void executeAntlr()
+        throws MojoExecutionException
+    {
+        // ----------------------------------------------------------------------
+        // Call Antlr for each grammar
+        // ----------------------------------------------------------------------
+
+        StringTokenizer st = new StringTokenizer( grammars, ", " );
+
+        while ( st.hasMoreTokens() )
+        {
+            String eachGrammar = st.nextToken().trim();
+
+            File grammar = new File( sourceDirectory, eachGrammar );
+
+            getLog().info( "grammar: " + grammar );
+
+            File generated = null;
+
+            try
+            {
+                generated = getGeneratedFile( grammar.getPath(), outputDirectory );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Failed to get generated file: " + e.getMessage(), e );
+            }
+
+            if ( generated.exists() )
+            {
+                if ( generated.lastModified() > grammar.lastModified() )
+                {
+                    // it's more recent, skip.
+                    getLog().info( "The grammar is already generated" );
+                    continue;
+                }
+            }
+
+            if ( !generated.getParentFile().exists() )
+            {
+                generated.getParentFile().mkdirs();
+            }
+
+            // ----------------------------------------------------------------------
+            // Wrap arguments
+            // Note: grammar file should be last
+            // ----------------------------------------------------------------------
+
+            List arguments = new LinkedList();
+            addArgIf( arguments, debug, "-debug" );
+            addArgIf( arguments, diagnostic, "-diagnostic" );
+            addArgIf( arguments, trace, "-trace" );
+            addArgIf( arguments, traceParser, "-traceParser" );
+            addArgIf( arguments, traceLexer, "-traceLexer" );
+            addArgIf( arguments, traceTreeParser, "-traceTreeParser" );
+            addArgs( arguments );
+            arguments.add( "-o" );
+            arguments.add( generated.getParentFile().getPath() );
+            arguments.add( grammar.getPath() );
+
+            String[] args = (String[]) arguments.toArray( new String[0] );
+
+            if ( getLog().isDebugEnabled() )
+            {
+                getLog().debug( "antlr args=\n" + StringUtils.join( args, "\n" ) );
+            }
+
+            SecurityManager oldSm = System.getSecurityManager();
+
+            System.setSecurityManager( NoExitSecurityManager.INSTANCE );
+
+            // ----------------------------------------------------------------------
+            // Call Antlr
+            // ----------------------------------------------------------------------
+
+            try
+            {
+                Tool.main( (String[]) arguments.toArray( new String[0] ) );
+            }
+            catch ( SecurityException e )
+            {
+                if ( !e.getMessage().equals( "exitVM-0" ) )
+                {
+                    throw new MojoExecutionException( "Execution failed", e );
+                }
+            }
+            finally
+            {
+                System.setSecurityManager( oldSm );
+            }
+        }
+
+        if ( project != null )
+        {
+            project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
+        }
+    }
+
+    /**
+     * Add arguments to be included in Antlr call
+     *
+     * @param arguments
+     */
+    protected abstract void addArgs( List arguments );
+
+    /**
+     * Convenience method to add an argument
+     *
+     * @param arguments
+     * @param b
+     * @param value
+     */
+    protected static void addArgIf( List arguments, boolean b, String value )
+    {
+        if ( b )
+        {
+            arguments.add( value );
+        }
+    }
+
+    /**
+     * @param grammar
+     * @param outputDir
+     * @return generated file
+     * @throws IOException
+     */
+    private File getGeneratedFile( String grammar, File outputDir )
+        throws IOException
+    {
+        String generatedFileName = null;
+
+        String packageName = "";
+
+        BufferedReader in = new BufferedReader( new FileReader( grammar ) );
+
+        String line;
+
+        while ( ( line = in.readLine() ) != null )
+        {
+            line = line.trim();
+
+            int extendsIndex = line.indexOf( " extends " );
+
+            if ( line.startsWith( "class " ) && extendsIndex > -1 )
+            {
+                generatedFileName = line.substring( 6, extendsIndex ).trim();
+
+                break;
+            }
+            else if ( line.startsWith( "package" ) )
+            {
+                packageName = line.substring( 8 ).trim();
+            }
+        }
+
+        in.close();
+
+        if ( generatedFileName == null )
+        {
+            return null;
+        }
+
+        File genFile = null;
+
+        if ( "".equals( packageName ) )
+        {
+            genFile = new File( outputDir, generatedFileName + ".java" );
+        }
+        else
+        {
+            String packagePath = packageName.replace( '.', File.separatorChar );
+
+            packagePath = packagePath.replace( ';', File.separatorChar );
+
+            genFile = new File( new File( outputDir, packagePath ), generatedFileName + ".java" );
+        }
+
+        return genFile;
+    }
+}

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AbstractAntlrMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AbstractAntlrMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrHtmlReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrHtmlReport.java?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrHtmlReport.java (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrHtmlReport.java Wed Sep 13 06:28:25 2006
@@ -0,0 +1,318 @@
+package org.apache.maven.plugin.antlr;
+
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.doxia.siterenderer.RendererException;
+import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.reporting.AbstractMavenReportRenderer;
+import org.apache.maven.reporting.MavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.apache.maven.wagon.PathUtils;
+import org.codehaus.doxia.sink.Sink;
+import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Generates Antlr documentation from grammar files.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @goal html
+ * @see <a href="http://www.antlr.org/doc/options.html#Command%20Line%20Options">Command Line Options</a>
+ */
+public class AntlrHtmlReport
+    extends AbstractAntlrMojo
+    implements MavenReport
+{
+    // ----------------------------------------------------------------------
+    // Report Parameters
+    // ----------------------------------------------------------------------
+
+    /**
+     * Generates the site report
+     *
+     * @component
+     */
+    private Renderer siteRenderer;
+
+    /**
+     * Internationalization.
+     *
+     * @component
+     */
+    protected I18N i18n;
+
+    /**
+     * Specifies the destination directory where Antlr generates HTML files.
+     *
+     * @parameter expression="${project.build.directory}/generated-site/antlr"
+     * @required
+     */
+    private File reportOutputDirectory;
+
+    /**
+     * The name of the Antlr report.
+     *
+     * @parameter expression="${name}" default-value="Antlr Grammars"
+     */
+    private String name;
+
+    /**
+     * The description of the Antlr report.
+     *
+     * @parameter expression="${description}" default-value="Generated Antlr report from grammars."
+     */
+    private String description;
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
+     */
+    public String getName( Locale locale )
+    {
+        if ( StringUtils.isEmpty( name ) )
+        {
+            return i18n.getString( "antlr-report", locale, "report.name" );
+        }
+
+        return "Antlr Grammars";
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
+     */
+    public String getDescription( Locale locale )
+    {
+        if ( StringUtils.isEmpty( description ) )
+        {
+            return i18n.getString( "antlr-report", locale, "report.description" );
+        }
+
+        return description;
+    }
+
+    /**
+     * @see org.apache.maven.plugin.antlr.AbstractAntlrMojo#addArgs(java.util.List)
+     */
+    protected void addArgs( List arguments )
+    {
+        // ----------------------------------------------------------------------
+        // See http://www.antlr.org/doc/options.html#Command%20Line%20Options
+        // ----------------------------------------------------------------------
+
+        arguments.add( "-html" );
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#generate(org.codehaus.doxia.sink.Sink, java.util.Locale)
+     */
+    public void generate( Sink sink, Locale locale )
+        throws MavenReportException
+    {
+        outputDirectory = getReportOutputDirectory();
+
+        try
+        {
+            executeAntlr();
+        }
+        catch ( MojoExecutionException e )
+        {
+            throw new MavenReportException( "Antlr execution failed: " + e.getMessage(), e );
+        }
+
+        AntlrRenderer r = new AntlrRenderer( sink, outputDirectory, i18n, Locale.ENGLISH );
+        r.render();
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getOutputName()
+     */
+    public String getOutputName()
+    {
+        return "antlr/index";
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#isExternalReport()
+     */
+    public boolean isExternalReport()
+    {
+        return false;
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#canGenerateReport()
+     */
+    public boolean canGenerateReport()
+    {
+        return true;
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getCategoryName()
+     */
+    public String getCategoryName()
+    {
+        return CATEGORY_PROJECT_REPORTS;
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#getReportOutputDirectory()
+     */
+    public File getReportOutputDirectory()
+    {
+        if ( reportOutputDirectory == null )
+        {
+            return outputDirectory;
+        }
+
+        return reportOutputDirectory;
+    }
+
+    /**
+     * @see org.apache.maven.reporting.MavenReport#setReportOutputDirectory(java.io.File)
+     */
+    public void setReportOutputDirectory( File reportOutputDirectory )
+    {
+        if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "antlr" ) ) )
+        {
+            this.reportOutputDirectory = new File( reportOutputDirectory, "antlr" );
+        }
+        else
+        {
+            this.reportOutputDirectory = reportOutputDirectory;
+        }
+    }
+
+    /**
+     * @see org.apache.maven.reporting.AbstractMavenReport#execute()
+     */
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        try
+        {
+            SiteRendererSink sink = siteRenderer.createSink( getReportOutputDirectory(), getOutputName() + ".html" );
+
+            generate( sink, Locale.getDefault() );
+        }
+        catch ( RendererException e )
+        {
+            throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
+                + " report generation.", e );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
+                + " report generation.", e );
+        }
+        catch ( MavenReportException e )
+        {
+            throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
+                + " report generation.", e );
+        }
+    }
+
+    /**
+     * Renderer report
+     */
+    private static class AntlrRenderer
+        extends AbstractMavenReportRenderer
+    {
+        private File outputDirectory;
+
+        private I18N i18n;
+
+        private Locale locale;
+
+        AntlrRenderer( Sink sink, File outputDirectory, I18N i18n, Locale locale )
+        {
+            super( sink );
+
+            this.outputDirectory = outputDirectory;
+
+            this.i18n = i18n;
+
+            this.locale = locale;
+        }
+
+        /**
+         * @see org.apache.maven.reporting.MavenReportRenderer#getTitle()
+         */
+        public String getTitle()
+        {
+            return i18n.getString( "antlr-report", locale, "report.title" );
+        }
+
+        /**
+         * @see org.apache.maven.reporting.AbstractMavenReportRenderer#renderBody()
+         */
+        public void renderBody()
+        {
+            startSection( i18n.getString( "antlr-report", locale, "report.overview.title" ) );
+
+            paragraph( i18n.getString( "antlr-report", locale, "report.overview.intro" ) );
+
+            endSection();
+
+            startSection( i18n.getString( "antlr-report", locale, "report.grammars.title" ) );
+
+            try
+            {
+                List htmlFiles = FileUtils.getFiles( outputDirectory, "**/*.html", "**/*index.html" );
+
+                if ( htmlFiles.isEmpty() )
+                {
+                    sink.text( i18n.getString( "antlr-report", locale, "report.grammars.noreport" ) );
+                }
+                else
+                {
+                    sink.list();
+                    for ( Iterator it = htmlFiles.iterator(); it.hasNext(); )
+                    {
+                        File current = (File) it.next();
+
+                        sink.listItem();
+                        sink.link( PathUtils.toRelative( outputDirectory, current.getAbsolutePath() ) );
+                        sink.text( StringUtils.replace( current.getName(), ".html", "" ) );
+                        sink.link_();
+                        sink.listItem_();
+                    }
+                    sink.list_();
+                }
+            }
+            catch ( IOException e )
+            {
+                throw new RuntimeException( "IOException: " + e.getMessage(), e );
+            }
+
+            endSection();
+
+            sink.flush();
+            sink.close();
+        }
+    }
+}

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrHtmlReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrHtmlReport.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrPlugin.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrPlugin.java?view=diff&rev=442981&r1=442980&r2=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrPlugin.java (original)
+++ maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/AntlrPlugin.java Wed Sep 13 06:28:25 2006
@@ -16,16 +16,9 @@
  * limitations under the License.
  */
 
-import antlr.Tool;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
+import java.util.List;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.security.Permission;
-import java.util.StringTokenizer;
+import org.apache.maven.plugin.MojoExecutionException;
 
 //----------------------------------------------------------------------
 // Don't remove this snippet
@@ -36,210 +29,31 @@
  *
  * @goal generate
  * @phase generate-sources
+ * @requiresDependencyResolution compile
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id: $
  */
 public class AntlrPlugin
-    extends AbstractMojo
+    extends AbstractAntlrMojo
 {
     /**
-     * Comma separated grammar file names present in the <code>sourceDirectory</code> directory.
-     *
-     * @parameter expression="${grammars}"
-     * @required
-     */
-    private String grammars;
-
-    /**
-     * Specifies the Antlr directory containing grammar files.
-     *
-     * @parameter expression="${basedir}/src/main/antlr"
-     * @required
-     */
-    private File sourceDirectory;
-
-    /**
-     * Specifies the destination directory where Antlr should generate files.
-     *
-     * @parameter expression="${project.build.directory}/generated-sources/antlr"
-     * @required
-     */
-    private String outputDirectory;
-
-    /**
-     * The Maven Project Object
-     *
-     * @parameter expression="${project}"
-     * @required
-     */
-    private MavenProject project;
-
-    /**
      * @see org.apache.maven.plugin.Mojo#execute()
      */
     public void execute()
         throws MojoExecutionException
     {
-        StringTokenizer st = new StringTokenizer( grammars, ", " );
-
-        while ( st.hasMoreTokens() )
-        {
-            String eachGrammar = st.nextToken().trim();
-
-            File grammar = new File( sourceDirectory, eachGrammar );
-
-            getLog().info( "grammar: " + grammar );
-
-            File generated = null;
-
-            try
-            {
-                generated = getGeneratedFile( grammar.getPath(), outputDirectory );
-            }
-            catch ( Exception e )
-            {
-                throw new MojoExecutionException( "Failed to get generated file", e );
-            }
-
-            if ( generated.exists() )
-            {
-                if ( generated.lastModified() > grammar.lastModified() )
-                {
-                    // it's more recent, skip.
-                    getLog().info( "The grammar is already generated" );
-                    continue;
-                }
-            }
-
-            if ( !generated.getParentFile().exists() )
-            {
-                generated.getParentFile().mkdirs();
-            }
-
-            // ----------------------------------------------------------------------
-            // @see http://www.antlr.org/doc/options.html#Command%20Line%20Options
-            // ----------------------------------------------------------------------
-
-            String[] args = new String[]{"-o", generated.getParentFile().getPath(), grammar.getPath(),};
-
-            SecurityManager oldSm = System.getSecurityManager();
-
-            System.setSecurityManager( NoExitSecurityManager.INSTANCE );
-
-            try
-            {
-                Tool.main( args );
-            }
-            catch ( SecurityException e )
-            {
-                if ( !e.getMessage().equals( "exitVM-0" ) )
-                {
-                    throw new MojoExecutionException( "Execution failed", e );
-                }
-            }
-            finally
-            {
-                System.setSecurityManager( oldSm );
-            }
-        }
-
-        if ( project != null )
-        {
-            project.addCompileSourceRoot( outputDirectory );
-        }
-    }
-
-    // END SNIPPET: generate-sources-0
-    //  ----------------------------------------------------------------------
-    //   Don't remove this snippet
-    //  ----------------------------------------------------------------------
-
-    /**
-     * @param grammar
-     * @param outputDirectory
-     * @return generated file
-     * @throws Exception
-     */
-    protected File getGeneratedFile( String grammar, String outputDirectory )
-        throws Exception
-    {
-        String generatedFileName = null;
-
-        String packageName = "";
-
-        try
-        {
-            BufferedReader in = new BufferedReader( new FileReader( grammar ) );
-
-            String line;
-
-            while ( ( line = in.readLine() ) != null )
-            {
-                line = line.trim();
-
-                int extendsIndex = line.indexOf( " extends " );
-
-                if ( line.startsWith( "class " ) && extendsIndex > -1 )
-                {
-                    generatedFileName = line.substring( 6, extendsIndex ).trim();
-
-                    break;
-                }
-                else if ( line.startsWith( "package" ) )
-                {
-                    packageName = line.substring( 8 ).trim();
-                }
-            }
-
-            in.close();
-        }
-        catch ( Exception e )
-        {
-            throw new Exception( "Unable to determine generated class", e );
-        }
-        if ( generatedFileName == null )
-        {
-            return null;
-        }
-
-        File genFile = null;
-
-        if ( "".equals( packageName ) )
-        {
-            genFile = new File( outputDirectory, generatedFileName + ".java" );
-        }
-        else
-        {
-            String packagePath = packageName.replace( '.', File.separatorChar );
-
-            packagePath = packagePath.replace( ';', File.separatorChar );
-
-            genFile = new File( new File( outputDirectory, packagePath ), generatedFileName + ".java" );
-        }
-
-        return genFile;
-    }
-}
-
-class NoExitSecurityManager
-    extends SecurityManager
-{
-    static final NoExitSecurityManager INSTANCE = new NoExitSecurityManager();
-
-    private NoExitSecurityManager()
-    {
-    }
-
-    /**
-     * @see java.lang.SecurityManager#checkPermission(java.security.Permission)
-     */
-    public void checkPermission( Permission permission )
-    {
+        executeAntlr();
     }
+// END SNIPPET: generate-sources-0
+//----------------------------------------------------------------------
+// Don't remove this snippet
+//----------------------------------------------------------------------
 
     /**
-     * @see java.lang.SecurityManager#checkExit(int)
+     * @see org.apache.maven.plugin.antlr.AbstractAntlrMojo#addArgs(java.util.List)
      */
-    public void checkExit( int status )
+    protected void addArgs( List arguments )
     {
-        throw new SecurityException( "exitVM-" + status );
+        // nop
     }
 }

Added: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/NoExitSecurityManager.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/NoExitSecurityManager.java?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/NoExitSecurityManager.java (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/NoExitSecurityManager.java Wed Sep 13 06:28:25 2006
@@ -0,0 +1,50 @@
+package org.apache.maven.plugin.antlr;
+
+/*
+ * 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.security.Permission;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class NoExitSecurityManager
+    extends SecurityManager
+{
+    static final NoExitSecurityManager INSTANCE = new NoExitSecurityManager();
+
+    private NoExitSecurityManager()
+    {
+        // nop
+    }
+
+    /**
+     * @see java.lang.SecurityManager#checkPermission(java.security.Permission)
+     */
+    public void checkPermission( Permission permission )
+    {
+        // nop
+    }
+
+    /**
+     * @see java.lang.SecurityManager#checkExit(int)
+     */
+    public void checkExit( int status )
+    {
+        throw new SecurityException( "exitVM-" + status );
+    }
+}

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/NoExitSecurityManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/java/org/apache/maven/plugin/antlr/NoExitSecurityManager.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report.properties?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report.properties (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report.properties Wed Sep 13 06:28:25 2006
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+report.name=Antlr Grammars
+report.description=Generated Antlr report from grammars.
+report.title=Antlr Grammar Report
+report.overview.title=Overview
+report.overview.intro=This project uses Antlr for constructing recognizers, compilers, and translators from grammatical descriptions.
+report.grammars.title=Grammars
+report.grammars.noreport=No grammar report was generated from Antlr.

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report.properties
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report_fr.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report_fr.properties?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report_fr.properties (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report_fr.properties Wed Sep 13 06:28:25 2006
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+report.name=Grammaires Antlr
+report.description=Génère un rapport Antlr des grammaires.
+report.title=Rapport des grammaires Antlr
+report.overview.title=Vue d'ensemble
+report.overview.intro=Ce projet utilise Antlr pour construire des reconnaisseurs, des compilateurs, et des traducteurs de grammaires.
+report.grammars.title=Grammaires
+report.grammars.noreport=Aucun rapport de grammaire n'a été généré par Antlr.

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report_fr.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/main/resources/antlr-report_fr.properties
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/plugins/trunk/maven-antlr-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/site/apt/index.apt?view=diff&rev=442981&r1=442980&r2=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-antlr-plugin/src/site/apt/index.apt Wed Sep 13 06:28:25 2006
@@ -33,9 +33,11 @@
 
 * Goals Overview
 
-   The Antlr Plugin has one goal:
+   The Antlr Plugin has two goals:
 
-   * {{{generate-mojo.html}antlr:generate}} generates file(s) to a target directory based on grammar file(s).
+   * {{{generate-mojo.html}antlr:generate}} Generates file(s) to a target directory based on grammar file(s).
+
+   * {{{html-mojo.html}antlr:html}} Generates Antlr report for grammar file(s).
 
 * Usage
 

Modified: maven/plugins/trunk/maven-antlr-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/site/apt/usage.apt?view=diff&rev=442981&r1=442980&r2=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-antlr-plugin/src/site/apt/usage.apt Wed Sep 13 06:28:25 2006
@@ -29,7 +29,7 @@
  The Antlr Plugin generates files based on grammar file(s). The following examples describe the basic
  usage of the Plugin.
 
-* Generate Sources From Grammar File(s)
+* Generate Files From Antlr Grammar File(s)
 
  You must configure the Antlr Plugin as follow:
 
@@ -63,9 +63,9 @@
 mvn antlr:generate
 +-----+
 
-* Generate Sources From Grammar File(s) As Part Of Your Build
+* Generate Files From Antlr Grammar File(s) As Part Of Your Build
 
- When you compile your project, the Antlr Plugin could be executed. You should add the generate <<<execution>>>
+ When you compile your project, the Antlr Plugin could be executed. You should add the \<execution\> section
  as follow:
 
 +-----+
@@ -100,3 +100,34 @@
 +-----+
 
  When you execute <<<mvn compile>>>, the files will be generated and included in your compile sources.
+
+* Generate Antlr Reports
+
+ To include Antlr reports in your documentation, you must configure the following in the \<reporting\>
+ section of your pom:
+
++-----+
+<project>
+...
+  <reporting>
+    <plugins>
+      ...
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antlr-plugin</artifactId>
+        <configuration>
+          <!--
+            Comma separated list of grammar files.
+            By default, grammar file is in ${basedir}/src/main/antlr
+          -->
+          <grammars>java15.g</grammars>
+        </configuration>
+      </plugin>
+      ...
+    </plugins>
+  </reporting>
+...
+</project>
++-----+
+
+ When you execute <<<mvn site>>>, the report will be generated.

Added: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/AntlrTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/AntlrTest.java?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/AntlrTest.java (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/AntlrTest.java Wed Sep 13 06:28:25 2006
@@ -0,0 +1,182 @@
+package org.apache.maven.plugin.antlr;
+
+/*
+ * 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.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.codehaus.plexus.util.cli.WriterStreamConsumer;
+
+/**
+ * Class to test Antlr plugin
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class AntlrTest
+    extends AbstractMojoTestCase
+{
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp()
+        throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp();
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown()
+        throws Exception
+    {
+        // nop
+    }
+
+    /**
+     * Method to test Antlr generation
+     *
+     * @throws Exception
+     */
+    public void testJavaGrammar()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(),
+                                 "src/test/resources/unit/java-grammar-test/java-grammar-test-plugin-config.xml" );
+        AntlrPlugin mojo = (AntlrPlugin) lookupMojo( "generate", testPom );
+        mojo.execute();
+
+        assertNotNull( new File( getBasedir(),
+                                 "target/test/unit/java-grammar-test/target/generated-sources/antlr/JavaLexer.java" ) );
+        assertNotNull( new File( getBasedir(),
+                                 "target/test/unit/java-grammar-test/target/generated-sources/antlr/JavaRecognizer.java" ) );
+        assertNotNull( new File( getBasedir(),
+                                 "target/test/unit/java-grammar-test/target/generated-sources/antlr/JavaTokenTypes.java" ) );
+        assertNotNull( new File( getBasedir(),
+                                 "target/test/unit/java-grammar-test/target/generated-sources/antlr/JavaTokenTypes.txt" ) );
+    }
+
+    /**
+     * Method to test Antlr Html report
+     *
+     * @throws Exception
+     */
+    public void testJavaGrammarReport()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(),
+                                 "src/test/resources/unit/java-grammar-report-test/java-grammar-report-test-plugin-config.xml" );
+
+        Commandline cmd = new Commandline();
+
+        cmd.setWorkingDirectory( testPom.getParentFile().getAbsolutePath() );
+
+        if ( System.getProperty( "os.name" ).indexOf( "Windows" ) != -1 )
+        {
+            // To know ExitCode
+            cmd.setExecutable( "call mvn" );
+        }
+        else
+        {
+            cmd.setExecutable( "mvn" );
+        }
+
+        // Full trace
+        cmd.createArgument().setValue( "-e" );
+        cmd.createArgument().setValue( "-X" );
+
+        cmd.createArgument().setValue( "clean" );
+        cmd.createArgument().setValue( "site" );
+
+        cmd.addArguments( new String[] { "-f", testPom.getName() } );
+
+        if ( getContainer().getLogger().isDebugEnabled() )
+        {
+            getContainer().getLogger().debug( cmd.toString() );
+        }
+
+        int exitCode;
+
+        Writer output = new StringWriter();
+        StreamConsumer consumer = new WriterStreamConsumer( output );
+        exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, consumer );
+
+        if ( getContainer().getLogger().isDebugEnabled() )
+        {
+            getContainer().getLogger().debug( output.toString() );
+        }
+
+        if ( exitCode != 0 )
+        {
+            // ----------------------------------------------------------------------
+            // Calling mvn from command line could throw an exception if
+            // maven-antlr-plugin is not already deployed
+            // ----------------------------------------------------------------------
+
+            if ( output.toString()
+                .indexOf( "POM 'org.apache.maven.plugins:maven-antlr-plugin' not found in repository" ) != -1 )
+            {
+                getContainer().getLogger().info(
+                                                 "org.apache.maven.plugins:maven-antlr-plugin not already "
+                                                     + "deployed. AntlrTest#testJavaGrammarReport() skipped." );
+                return;
+            }
+
+            StringBuffer msg = new StringBuffer();
+            msg.append( "The command line failed. Exit code: " + exitCode ).append( "\n= call mvn output =\n" );
+            msg.append( output.toString() ).append( "\n" );
+            msg.append( "= End output =\n" );
+
+            throw new CommandLineException( msg.toString() );
+        }
+
+        File index = new File( getBasedir(), "target/test/unit/java-grammar-report-test/target/site/antlr/index.html" );
+        assertNotNull( index );
+        assertTrue( readFile( index ).indexOf( "<a href=\"JavaRecognizer.html\">JavaRecognizer</a>" ) != -1 );
+        assertNotNull( new File( getBasedir(), "target/test/unit/java-grammar-report-test/target/site/antlr/index.html" ) );
+
+        assertNotNull( new File( getBasedir(),
+                                 "target/test/unit/java-grammar-report-test/target/site/antlr/JavaRecognizer.html" ) );
+    }
+
+    /**
+     * Read the contents of the specified file object into a string
+     *
+     * @param file the file to be read
+     * @return a String object that contains the contents of the file
+     * @throws IOException if any
+     */
+    private String readFile( File file )
+        throws IOException
+    {
+        BufferedReader in = new BufferedReader( new FileReader( file ) );
+
+        return IOUtil.toString( in );
+    }
+}

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/AntlrTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/AntlrTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/DefaultArtifactHandlerStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/DefaultArtifactHandlerStub.java?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/DefaultArtifactHandlerStub.java (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/DefaultArtifactHandlerStub.java Wed Sep 13 06:28:25 2006
@@ -0,0 +1,50 @@
+package org.apache.maven.plugin.antlr.stubs;
+
+/*
+ * 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 org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class DefaultArtifactHandlerStub
+    extends DefaultArtifactHandler
+{
+    private String language;
+
+    /**
+     * @see org.apache.maven.artifact.handler.ArtifactHandler#getLanguage()
+     */
+    public String getLanguage()
+    {
+        if ( language == null )
+        {
+            language = "java";
+        }
+
+        return language;
+    }
+
+    /**
+     * @param language
+     */
+    public void setLanguage( String language )
+    {
+        this.language = language;
+    }
+}

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/DefaultArtifactHandlerStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/DefaultArtifactHandlerStub.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/JavaGrammarTestMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/JavaGrammarTestMavenProjectStub.java?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/JavaGrammarTestMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/JavaGrammarTestMavenProjectStub.java Wed Sep 13 06:28:25 2006
@@ -0,0 +1,52 @@
+package org.apache.maven.plugin.antlr.stubs;
+
+/*
+ * 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.io.File;
+import java.io.FileReader;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class JavaGrammarTestMavenProjectStub
+    extends MavenProjectStub
+{
+    /**
+     * Default
+     */
+    public JavaGrammarTestMavenProjectStub()
+    {
+        MavenXpp3Reader pomReader = new MavenXpp3Reader();
+        Model model = null;
+
+        try
+        {
+            model = pomReader.read( new FileReader( new File( getBasedir() +
+            "/src/test/resources/unit/java-grammar-test/java-grammar-test-plugin-config.xml" ) ) );
+            setModel( model );
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+}

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/JavaGrammarTestMavenProjectStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/test/java/org/apache/maven/plugin/antlr/stubs/JavaGrammarTestMavenProjectStub.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/java-grammar-report-test-plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/java-grammar-report-test-plugin-config.xml?view=auto&rev=442981
==============================================================================
--- maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/java-grammar-report-test-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/java-grammar-report-test-plugin-config.xml Wed Sep 13 06:28:25 2006
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>java-grammar-report.test</groupId>
+  <artifactId>java-grammar-report-test</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <inceptionYear>2006</inceptionYear>
+  <name>Maven Antlr Plugin Java-grammar Report Test</name>
+  <url>http://maven.apache.org</url>
+  <reporting>
+    <outputDirectory>${basedir}/../../../../../target/test/unit/java-grammar-report-test/target/site</outputDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antlr-plugin</artifactId>
+        <configuration>
+          <project implementation="org.apache.maven.plugin.antlr.stubs.JavaGrammarTestMavenProjectStub"/>
+          <grammars>java15.g</grammars>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>

Propchange: maven/plugins/trunk/maven-antlr-plugin/src/test/resources/unit/java-grammar-report-test/java-grammar-report-test-plugin-config.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"