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 2007/10/15 23:48:33 UTC

svn commit: r584931 [1/2] - in /maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant: ./ src/main/java/org/apache/maven/jxr/ant/doc/ src/main/resources/touchgraph/ src/main/resources/vizant/ src/site/ src/site/apt/ src/site/apt/examples/ src/test/java/org/a...

Author: vsiveton
Date: Mon Oct 15 14:48:25 2007
New Revision: 584931

URL: http://svn.apache.org/viewvc?rev=584931&view=rev
Log:
o added GenerateHTMLDoc class that implements the (old) ant.xml logic and added the associated Ant task
o added a new Dot (http://www.graphviz.org) Ant task
o added some Maven dependencies (plexus-utils and ant-trax)
o added test cases
o added documentation

Added:
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/AntDocTask.java   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/DotTask.java   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/GenerateHTMLDoc.java   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/touchgraph/resources.txt   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/vizant/resources.txt   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/ant.apt   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/index.apt   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/site.xml   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/AntDocTaskTest.java   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/DotTaskTest.java   (with props)
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/resources/dot/
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/resources/dot/graph.dot
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/resources/dot/target.dot
Modified:
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/pom.xml

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/pom.xml?rev=584931&r1=584930&r2=584931&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/pom.xml (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/pom.xml Mon Oct 15 14:48:25 2007
@@ -45,5 +45,18 @@
       <artifactId>xml-apis</artifactId>
       <version>1.3.03</version>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.4.6</version>
+    </dependency>
+
+    <!-- XSLT task -->
+    <dependency>
+      <groupId>ant</groupId>
+      <artifactId>ant-trax</artifactId>
+      <version>1.6.5</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/AntDocTask.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/AntDocTask.java?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/AntDocTask.java (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/AntDocTask.java Mon Oct 15 14:48:25 2007
@@ -0,0 +1,154 @@
+package org.apache.maven.jxr.ant.doc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * <a href="http://ant.apache.org/">Ant</a> task to generate Ant code documentation.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class AntDocTask
+    extends Task
+{
+    /** An ant file */
+    private File antFile;
+
+    /** Destination directory */
+    private File destDir;
+
+    /** Terminate Ant build */
+    private boolean failOnError;
+
+    /**
+     * Set the ant file to generate documentation.
+     *
+     * @param f Path to the Ant file.
+     */
+    public void setAntFile( File f )
+    {
+        this.antFile = f;
+    }
+
+    /**
+     * Set the destination directory.
+     *
+     * @param d Path to the directory.
+     */
+    public void setDestDir( File d )
+    {
+        this.destDir = d;
+    }
+
+    /**
+     * Set fail on an error.
+     *
+     * @param b true to fail on an error.
+     */
+    public void setFailonerror( boolean b )
+    {
+        this.failOnError = b;
+    }
+
+    /** {@inheritDoc} */
+    public void init()
+        throws BuildException
+    {
+        super.init();
+    }
+
+    /** {@inheritDoc} */
+    public String getTaskName()
+    {
+        return "antdoc";
+    }
+
+    /** {@inheritDoc} */
+    public String getDescription()
+    {
+        return "Generate Ant documentation";
+    }
+
+    /** {@inheritDoc} */
+    public void execute()
+        throws BuildException
+    {
+        try
+        {
+            GenerateHTMLDoc generator = new GenerateHTMLDoc( getAntFile(), getDestDir() );
+            generator.generateDoc();
+        }
+        catch ( IllegalArgumentException e )
+        {
+            if ( !failOnError )
+            {
+                throw new BuildException( "IllegalArgumentException: " + e.getMessage(), e, getLocation() );
+            }
+
+            log( "IllegalArgumentException: " + e.getMessage(), Project.MSG_ERR );
+        }
+        catch ( IOException e )
+        {
+            if ( !failOnError )
+            {
+                throw new BuildException( "IOException: " + e.getMessage(), e, getLocation() );
+            }
+
+            log( "IOException: " + e.getMessage(), Project.MSG_ERR );
+        }
+        catch ( BuildException e )
+        {
+            e.printStackTrace();
+            if ( !failOnError )
+            {
+                throw new BuildException( "RuntimeException: " + e.getMessage(), e, getLocation() );
+            }
+
+            log( e.getMessage(), Project.MSG_ERR );
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    // Private
+    // ----------------------------------------------------------------------
+
+    /**
+     * @return the Ant file which be parsed.
+     */
+    private File getAntFile()
+    {
+        return this.antFile;
+    }
+
+    /**
+     * @return the dest dir
+     */
+    private File getDestDir()
+    {
+        return this.destDir;
+    }
+}

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/AntDocTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/AntDocTask.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/DotTask.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/DotTask.java?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/DotTask.java (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/DotTask.java Mon Oct 15 14:48:25 2007
@@ -0,0 +1,447 @@
+package org.apache.maven.jxr.ant.doc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.ExecTask;
+import org.apache.tools.ant.taskdefs.GUnzip;
+import org.apache.tools.ant.taskdefs.Get;
+import org.apache.tools.ant.taskdefs.Untar;
+
+/**
+ * <a href="http://ant.apache.org/">Ant</a> task for <a href="http://www.graphviz.org/">Graphviz</a> program.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class DotTask
+    extends Task
+{
+    /** Windows Graphviz download URL **/
+    public static final String GRAPHVIZ_WINDOWS_URL = "http://www.graphviz.org/pub/graphviz/ARCHIVE/graphviz-win-2.14.1.bin.tar.gz";
+
+    private static final String TARGZ = GRAPHVIZ_WINDOWS_URL.substring( GRAPHVIZ_WINDOWS_URL.lastIndexOf( '/' ) + 1 );
+
+    private static final String TAR = TARGZ.substring( 0, TARGZ.lastIndexOf( '.' ) );
+
+    private static final String GRAPHVIZ_DIR = "graphviz-2.14.1"; // inside the tar.gz
+
+    private static final String DEFAULT_OUTPUT_FORMAT = "svg";
+
+    /** The dot executable. */
+    private File dotExe;
+
+    /** The input file. */
+    private File in;
+
+    /** The output file. */
+    private File out;
+
+    /** The dest dir. */
+    private File destDir;
+
+    /** The output format. */
+    private String format = DEFAULT_OUTPUT_FORMAT;
+
+    /**
+     * Set the dot executable.
+     *
+     * @param dotExe the new dot executable.
+     */
+    public void setDotExe( File dotExe )
+    {
+        this.dotExe = dotExe;
+    }
+
+    /**
+     * Set the input file.
+     *
+     * @param in the new input file.
+     */
+    public void setIn( File in )
+    {
+        this.in = in;
+    }
+
+    /**
+     * Set the output file.
+     *
+     * @param out the new out file.
+     */
+    public void setOut( File out )
+    {
+        this.out = out;
+    }
+
+    /**
+     * Set the output directory.
+     *
+     * @param dest the new output directory.
+     */
+    public void setDestDir( File dest )
+    {
+        this.destDir = dest;
+    }
+
+    /**
+     * Set the wanted format.
+     *
+     * @param format the new format.
+     */
+    public void setFormat( String format )
+    {
+        this.format = format;
+    }
+
+    /** {@inheritDoc} */
+    public String getTaskName()
+    {
+        return "dot";
+    }
+
+    /** {@inheritDoc} */
+    public String getDescription()
+    {
+        return "Process Graphviz DOT file.";
+    }
+
+    /** {@inheritDoc} */
+    public void init()
+        throws BuildException
+    {
+        super.init();
+    }
+
+    /**
+     * {@inheritDoc}
+     * @throws BuildException if any
+     * @throws DotNotPresentInPathBuildException if DOT not present in the path.
+     */
+    public void execute()
+        throws BuildException
+    {
+        // Input checks
+        if ( getIn() == null )
+        {
+            throw new BuildException( "Missing mandatory attribute 'in'.", getLocation() );
+        }
+        if ( !getIn().exists() || !getIn().isFile() )
+        {
+            throw new BuildException( "Input file '" + getIn() + "' not found or not a file.", getLocation() );
+        }
+
+        if ( getDestDir() == null )
+        {
+            if ( getOut() == null )
+            {
+                throw new BuildException( "Missing mandatory attribute 'out'.", getLocation() );
+            }
+            if ( getOut().exists() && getOut().isDirectory() )
+            {
+                throw new BuildException( "Output file '" + getOut() + "' is a dir.", getLocation() );
+            }
+        }
+        else
+        {
+            if ( getDestDir().exists() && !getDestDir().isDirectory() )
+            {
+                throw new BuildException( "Dest directory is a file.", getLocation() );
+            }
+            if ( !getDestDir().exists() && !getDestDir().mkdirs() )
+            {
+                throw new BuildException( "Cannot create the dest directory.", getLocation() );
+            }
+        }
+
+        // Calling ExecTask
+        ExecTask exec = new ExecTask();
+        exec.setProject( getProject() );
+        exec.setTaskName( "exec" );
+        exec.init();
+        if ( getDotExe() == null )
+        {
+            exec.setExecutable( "dot" );
+        }
+        else
+        {
+            if ( !getDotExe().exists() || !getDotExe().isFile() )
+            {
+                throw new BuildException( "DOT executable '" + getDotExe() + "' not found or not a file.",
+                                          getLocation() );
+            }
+
+            exec.setExecutable( getDotExe().getAbsolutePath() );
+        }
+        File output;
+        if ( getDestDir() == null )
+        {
+            output = getOut();
+        }
+        else
+        {
+            output = new File( getDestDir(), getIn().getName() + "." + format );
+        }
+        exec.setDir( output.getParentFile() );
+        exec.createArg().setLine(
+                                  "-T" + getFormat() + " " + "-o" + output.getAbsolutePath() + " "
+                                      + getIn().getAbsolutePath() );
+
+        exec.setOutputproperty( "exec.output" );
+        try
+        {
+            exec.execute();
+        }
+        catch ( BuildException e )
+        {
+            String msg = e.getMessage();
+
+            // No DOT executable in path
+            if ( msg.indexOf( "Execute failed" ) != -1 )
+            {
+                // Unix/Mac OS
+                if ( System.getProperty( "os.name" ).toLowerCase().indexOf( "windows" ) == -1 )
+                {
+                    throw new DotNotPresentInPathBuildException( "Graphviz DOT executable "
+                        + "(http://www.graphviz.org/) is not present in your path. "
+                        + "Please install it in your path or specify a 'dotExe' parameter.", e );
+                }
+
+                // Windows OS
+                log( "Graphviz DOT executable (http://www.graphviz.org/) is not present in your path. "
+                    + "Try to download it...", Project.MSG_WARN );
+
+                String tmpdir = System.getProperty( "java.io.tmpdir" );
+                File tmp = new File( tmpdir, "graphviz" );
+                if ( !tmp.exists() && !tmp.mkdirs() )
+                {
+                    throw new BuildException( "Cannot create the temp dir: " + tmp.getAbsolutePath() );
+                }
+                downloadGraphviz( getProject(), tmp );
+                installGraphviz( getProject(), tmp );
+                File dotExeFile = new File( tmp, GRAPHVIZ_DIR + "/bin/dot.exe" );
+
+                // Reexecute the task
+                exec.setExecutable( dotExeFile.getAbsolutePath() );
+                exec.execute();
+            }
+            else
+            {
+                throw e;
+            }
+        }
+
+        // Verify if no error in the output
+        if ( getProject().getProperty( "exec.output" ) != null )
+        {
+            if ( getProject().getProperty( "exec.output" ).indexOf( "Execute failed" ) != -1 )
+            {
+                throw new BuildException( getProject().getProperty( "exec.output" ), getLocation() );
+            }
+
+            if ( getProject().getProperty( "exec.output" ).indexOf( "Error:" ) != -1 )
+            {
+                log( getProject().getProperty( "exec.output" ), Project.MSG_ERR );
+                throw new BuildException( "Error when calling dot.", getLocation() );
+            }
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    // Private
+    // ----------------------------------------------------------------------
+
+    /**
+     * Getter for the dotExe
+     *
+     * @return the dotExe
+     */
+    private File getDotExe()
+    {
+        return this.dotExe;
+    }
+
+    /**
+     * Getter for the in
+     *
+     * @return the in
+     */
+    private File getIn()
+    {
+        return this.in;
+    }
+
+    /**
+     * Getter for the out
+     *
+     * @return the out
+     */
+    private File getOut()
+    {
+        return this.out;
+    }
+
+    /**
+     * Getter for the dest
+     *
+     * @return the dest
+     */
+    private File getDestDir()
+    {
+        return this.destDir;
+    }
+
+    /**
+     * Getter for the format
+     *
+     * @return the format
+     */
+    private String getFormat()
+    {
+        return this.format;
+    }
+
+    /**
+     * Download in the specified <code>outputDir</code> the Graphviz package.
+     *
+     * @param antProject not null
+     * @param outputDir not null
+     * @throws BuildException if any
+     * @see #GRAPHVIZ_WINDOWS_URL
+     * @TODO add proxy support
+     */
+    private static void downloadGraphviz( Project antProject, File outputDir )
+        throws BuildException
+    {
+        if ( new File( outputDir, TARGZ ).exists() )
+        {
+            antProject.log( "The file " + new File( outputDir, TARGZ ) + " was already downloaded. Ignored get.",
+                            Project.MSG_DEBUG );
+            return;
+        }
+
+        Get get = new Get();
+        get.setProject( antProject );
+        get.setTaskName( "get" );
+        get.init();
+        try
+        {
+            get.setSrc( new URL( GRAPHVIZ_WINDOWS_URL ) );
+        }
+        catch ( MalformedURLException e )
+        {
+            // nop
+        }
+        get.setDest( new File( outputDir, TARGZ ) );
+        get.execute();
+    }
+
+    /**
+     * Install the Graphviz package in the specified <code>outputDir</code>
+     *
+     * @param antProject not null
+     * @param outputDir not null
+     * @throws BuildException if any
+     */
+    private static void installGraphviz( Project antProject, File outputDir )
+        throws BuildException
+    {
+        // Already exist - skip
+        if ( new File( outputDir, GRAPHVIZ_DIR ).exists() )
+        {
+            antProject.log( "The dir " + new File( outputDir, GRAPHVIZ_DIR ) + " already exists. Ignored untar.",
+                            Project.MSG_DEBUG );
+            return;
+        }
+
+        File targz = new File( outputDir, TARGZ );
+
+        GUnzip gunzip = new GUnzip();
+        gunzip.setProject( antProject );
+        gunzip.setTaskName( "gunzip" );
+        gunzip.init();
+        gunzip.setSrc( targz );
+        gunzip.execute();
+
+        Untar untar = new Untar();
+        untar.setProject( antProject );
+        untar.setTaskName( "untar" );
+        untar.init();
+        untar.setSrc( new File( outputDir, TAR ) );
+        untar.setDest( outputDir );
+        untar.execute();
+    }
+
+    /**
+     * Signals that the dot executable is not present in the path
+     */
+    protected class DotNotPresentInPathBuildException
+        extends BuildException
+    {
+        /**
+         * Constructs am exception with no descriptive information.
+         */
+        public DotNotPresentInPathBuildException()
+        {
+            super();
+        }
+
+        /**
+         * Constructs an exception with the given descriptive message.
+         *
+         * @param message
+         */
+        public DotNotPresentInPathBuildException( String message )
+        {
+            super( message );
+        }
+
+        /**
+         * Constructs an exception with the given message and exception as
+         * a root cause.
+         *
+         * @param message
+         * @param cause
+         */
+        public DotNotPresentInPathBuildException( String message, Throwable cause )
+        {
+            super( message, cause );
+        }
+
+        /**
+         * Constructs an exception with the given message and exception as
+         * a root cause and a location in a file.
+         *
+         * @param message
+         * @param cause
+         * @param location
+         */
+        public DotNotPresentInPathBuildException( String message, Throwable cause, Location location )
+        {
+            super( message, cause, location );
+        }
+    }
+}

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/DotTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/DotTask.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/GenerateHTMLDoc.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/GenerateHTMLDoc.java?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/GenerateHTMLDoc.java (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/GenerateHTMLDoc.java Mon Oct 15 14:48:25 2007
@@ -0,0 +1,430 @@
+package org.apache.maven.jxr.ant.doc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.XSLTProcess;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Generate HTML documentation for <a href="http://ant.apache.org/">Ant</a> file.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class GenerateHTMLDoc
+{
+    /** An ant file */
+    private File antFile;
+
+    /** Destination directory */
+    private File destDir;
+
+    /** Temp xsl file */
+    private File xml2dot;
+
+    /** Temp xsl file */
+    private File xml2html;
+
+    /** Temp xsl file */
+    private File xml2tg;
+
+    /** Temp Vizant build graph */
+    private File buildGraph;
+
+    /** Temp generated dot file */
+    private File dot;
+
+    /** Temp generated touch graph */
+    private File buildtg;
+
+    /**
+     * @param antFile
+     * @param destDir
+     * @throws IllegalArgumentException
+     */
+    public GenerateHTMLDoc( File antFile, File destDir )
+        throws IllegalArgumentException
+    {
+        if ( antFile == null )
+        {
+            throw new IllegalArgumentException( "Missing mandatory attribute 'antFile'." );
+        }
+        if ( !antFile.exists() || !antFile.isFile() )
+        {
+            throw new IllegalArgumentException( "Input '" + getAntFile() + "' not found or not a file." );
+        }
+
+        if ( destDir == null )
+        {
+            throw new IllegalArgumentException( "Missing mandatory attribute 'dest'." );
+        }
+        if ( destDir.exists() && !destDir.isDirectory() )
+        {
+            throw new IllegalArgumentException( "Dest directory is a file." );
+        }
+        if ( !destDir.exists() && !destDir.mkdirs() )
+        {
+            throw new IllegalArgumentException( "Cannot create the dest directory." );
+        }
+
+        this.antFile = antFile;
+        this.destDir = destDir;
+    }
+
+    /**
+     * Generate the documentation
+     *
+     * @throws IOException if any
+     */
+    public void generateDoc()
+        throws IOException
+    {
+        // 1. Generate Vizant graph
+        generateVizantBuildGraph();
+
+        // 2. Generate dot graph
+        generateDotBuildGraph();
+
+        // 3. Generate images from the dot file
+        generateImages();
+
+        // 4. Generate site
+        generateSite();
+    }
+
+    // ----------------------------------------------------------------------
+    // Private
+    // ----------------------------------------------------------------------
+
+    /**
+     * @return the Ant file which be parsed.
+     */
+    private File getAntFile()
+    {
+        return this.antFile;
+    }
+
+    /**
+     * @return the dest dir
+     */
+    private File getDestDir()
+    {
+        return this.destDir;
+    }
+
+    /**
+     * @return xsl temp file.
+     * @throws IOException if any
+     */
+    private File getXml2dot()
+        throws IOException
+    {
+        if ( this.xml2dot == null )
+        {
+            this.xml2dot = FileUtils.createTempFile( "xml2dot", ".xsl", null );
+            this.xml2dot.deleteOnExit();
+
+            InputStream is = getClass().getClassLoader().getResourceAsStream( "vizant/xml2dot.xsl" );
+            if ( is == null )
+            {
+                throw new IOException( "This resource doesn't exist." );
+            }
+
+            FileOutputStream w = new FileOutputStream( this.xml2dot );
+
+            IOUtil.copy( is, w );
+
+            IOUtil.close( is );
+
+            IOUtil.close( w );
+        }
+
+        return this.xml2dot;
+    }
+
+    /**
+     * @return xsl temp file.
+     * @throws IOException if any
+     */
+    private File getXml2html()
+        throws IOException
+    {
+        if ( this.xml2html == null )
+        {
+            this.xml2html = FileUtils.createTempFile( "xml2html", ".xsl", null );
+            this.xml2html.deleteOnExit();
+
+            InputStream is = getClass().getClassLoader().getResourceAsStream( "vizant/xml2html.xsl" );
+            if ( is == null )
+            {
+                throw new IOException( "This resource doesn't exist." );
+            }
+
+            FileOutputStream w = new FileOutputStream( this.xml2html );
+
+            IOUtil.copy( is, w );
+
+            IOUtil.close( is );
+
+            IOUtil.close( w );
+        }
+
+        return this.xml2html;
+    }
+
+    /**
+     * @return xsl temp file.
+     * @throws IOException if any
+     */
+    private File getXml2tg()
+        throws IOException
+    {
+        if ( this.xml2tg == null )
+        {
+            this.xml2tg = FileUtils.createTempFile( "xml2tg", ".xsl", null );
+            this.xml2tg.deleteOnExit();
+
+            InputStream is = getClass().getClassLoader().getResourceAsStream( "vizant/xml2tg.xsl" );
+            if ( is == null )
+            {
+                throw new IOException( "This resource doesn't exist." );
+            }
+
+            FileOutputStream w = new FileOutputStream( this.xml2tg );
+
+            IOUtil.copy( is, w );
+
+            IOUtil.close( is );
+
+            IOUtil.close( w );
+        }
+
+        return this.xml2html;
+    }
+
+    /**
+     * @return a temp file for the Vizant build graph file.
+     */
+    private File getBuildGraph()
+    {
+        if ( this.buildGraph == null )
+        {
+            this.buildGraph = FileUtils.createTempFile( "buildgraph", ".xml", null );
+            this.buildGraph.deleteOnExit();
+        }
+
+        return this.buildGraph;
+    }
+
+    /**
+     * @return a temp file for dot file.
+     */
+    private File getDot()
+    {
+        if ( this.dot == null )
+        {
+            this.dot = FileUtils.createTempFile( "buildgraph", ".dot", null );
+            this.dot.deleteOnExit();
+        }
+
+        return this.dot;
+    }
+
+    /**
+     * @return a temp file for build touch graph file.
+     */
+    private File getBuildtg()
+    {
+        if ( this.buildtg == null )
+        {
+            this.buildtg = FileUtils.createTempFile( "buildtg", ".xml", null );
+            this.buildtg.deleteOnExit();
+        }
+
+        return this.buildtg;
+    }
+
+    /**
+     * @return a minimal Ant project.
+     */
+    private Project getAntProject()
+    {
+        Project antProject = new Project();
+        antProject.setBasedir( new File( "" ).getAbsolutePath() );
+
+        return antProject;
+    }
+
+    /**
+     * Call Vizant task
+     *
+     * @throws BuildException if any
+     */
+    private void generateVizantBuildGraph()
+        throws BuildException
+    {
+        Vizant vizantTask = new Vizant();
+        vizantTask.setProject( getAntProject() );
+        vizantTask.setTaskName( "vizant" );
+        vizantTask.init();
+        vizantTask.setAntfile( getAntFile() );
+        vizantTask.setOutfile( getBuildGraph() );
+        vizantTask.setUniqueref( true );
+        vizantTask.execute();
+    }
+
+    /**
+     * Apply XSLT to generate dot file from the Vizant build graph
+     *
+     * @throws BuildException if any
+     * @throws IOException if any
+     */
+    private void generateDotBuildGraph()
+        throws BuildException, IOException
+    {
+        XSLTProcess xsltTask = new XSLTProcess();
+        xsltTask.setProject( getAntProject() );
+        xsltTask.setTaskName( "xslt" );
+        xsltTask.init();
+        xsltTask.setIn( getBuildGraph() );
+        xsltTask.setOut( getDot() );
+        xsltTask.setStyle( getXml2dot().getAbsolutePath() );
+        xsltTask.execute();
+    }
+
+    /**
+     * Call graphviz dot to generate images.
+     *
+     * @throws BuildException if any
+     */
+    private void generateImages()
+        throws BuildException
+    {
+        String[] dotFormat = { "svg", "png" };
+        for ( int i = 0; i < dotFormat.length; i++ )
+        {
+            String format = dotFormat[i];
+
+            DotTask dotTask = new DotTask();
+            dotTask.setProject( getAntProject() );
+            dotTask.setTaskName( "dot" );
+            dotTask.init();
+            dotTask.setIn( getDot() );
+            dotTask.setOut( new File( getDestDir(), "vizant." + format ) );
+            dotTask.setFormat( format );
+            dotTask.execute();
+        }
+    }
+
+    /**
+     * Generate the documentation site.
+     *
+     * @throws BuildException if any
+     * @throws IOException if any
+     */
+    private void generateSite()
+        throws BuildException, IOException
+    {
+        File targetHtml = new File( getDestDir(), "target.html" );
+        XSLTProcess xsltTask = new XSLTProcess();
+        xsltTask.setProject( getAntProject() );
+        xsltTask.setTaskName( "xslt" );
+        xsltTask.init();
+        xsltTask.setIn( getBuildGraph() );
+        xsltTask.setOut( targetHtml );
+        xsltTask.setStyle( getXml2html().getAbsolutePath() );
+        xsltTask.execute();
+
+        xsltTask = new XSLTProcess();
+        xsltTask.setProject( getAntProject() );
+        xsltTask.setTaskName( "xslt" );
+        xsltTask.init();
+        xsltTask.setIn( getBuildGraph() );
+        xsltTask.setOut( getBuildtg() );
+        xsltTask.setStyle( getXml2tg().getAbsolutePath() );
+        xsltTask.setReloadStylesheet( true );
+        xsltTask.execute();
+
+        // copy
+        FileUtils.copyFile( getBuildtg(), new File( getDestDir(), "InitialXML._xml" ) );
+
+        copyResources( this.getClass().getClassLoader(), "vizant/resources.txt", getDestDir() );
+        copyResources( this.getClass().getClassLoader(), "touchgraph/resources.txt", getDestDir() );
+    }
+
+    /**
+     * @param classloader the given class loader, not null
+     * @param resourcesPath the path of a resources file in the given class loader, not null
+     * @param outputDirectory the output directory, not null
+     * @throws IOException if any
+     */
+    private static void copyResources( ClassLoader classloader, String resourcesPath, File outputDirectory )
+        throws IOException
+    {
+        InputStream resourceList = classloader.getResourceAsStream( resourcesPath );
+
+        if ( resourceList == null )
+        {
+            throw new IOException( "The resourcesPath '" + resourcesPath + "' doesn't exists in the class loader '"
+                + classloader + "'." );
+        }
+
+        LineNumberReader reader = new LineNumberReader( new InputStreamReader( resourceList ) );
+
+        String line = reader.readLine();
+
+        while ( line != null )
+        {
+            InputStream is = classloader.getResourceAsStream( line );
+
+            if ( is == null )
+            {
+                throw new IOException( "The resource " + line + " doesn't exist." );
+            }
+
+            File outputFile = new File( outputDirectory, line.substring( line.indexOf( '/' ) ) );
+
+            if ( !outputFile.getParentFile().exists() )
+            {
+                outputFile.getParentFile().mkdirs();
+            }
+
+            FileOutputStream w = new FileOutputStream( outputFile );
+
+            IOUtil.copy( is, w );
+
+            IOUtil.close( is );
+
+            IOUtil.close( w );
+
+            line = reader.readLine();
+        }
+    }
+}

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/GenerateHTMLDoc.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/java/org/apache/maven/jxr/ant/doc/GenerateHTMLDoc.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/touchgraph/resources.txt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/touchgraph/resources.txt?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/touchgraph/resources.txt (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/touchgraph/resources.txt Mon Oct 15 14:48:25 2007
@@ -0,0 +1,4 @@
+touchgraph/BrowserLauncher.jar
+touchgraph/TGLinkBrowser.jar
+touchgraph/tg.html
+touchgraph/nanoxml-2.1.1.jar

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/touchgraph/resources.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/touchgraph/resources.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/vizant/resources.txt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/vizant/resources.txt?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/vizant/resources.txt (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/vizant/resources.txt Mon Oct 15 14:48:25 2007
@@ -0,0 +1,4 @@
+vizant/cover.html
+vizant/links.html
+vizant/index.html
+vizant/main.css

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/vizant/resources.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/main/resources/vizant/resources.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/ant.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/ant.apt?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/ant.apt (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/ant.apt Mon Oct 15 14:48:25 2007
@@ -0,0 +1,54 @@
+ ------
+ Ant Example
+ ------
+ Vincent Siveton
+ ------
+ October 2007
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+Ant Example
+
+ Here is a simple Ant example:
+
++-----+
+<project name="your-project" basedir=".">
+
+  <path id="task.classpath">
+    <fileset dir="${basedir}/lib">
+      <include name="plexus-utils-1.4.6.jar" />
+    </fileset>
+    <fileset dir="${basedir}/lib">
+      <include name="maven-jxr-ant-3.0-SNAPSHOT.jar" />
+    </fileset>
+  </path>
+
+  <target name="antdoc">
+    <taskdef name="antdoc"
+             classname="org.apache.maven.jxr.ant.doc.AntDocTask"
+             classpathref="task.classpath"/>
+
+    <antdoc antFile="${basedir}/build.xml"
+            destDir="${basedir}/target/ant" />
+  </target>
+</project>
++-----+

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/ant.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/examples/ant.apt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/index.apt?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/index.apt (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/index.apt Mon Oct 15 14:48:25 2007
@@ -0,0 +1,48 @@
+ ------
+ Introduction
+ ------
+ Vincent Siveton
+ ------
+ October 2007
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+Maven JXR Ant
+
+ This project is an Ant code documentation system.
+
+* Brief History
+
+ This original code comes from the defunct {{{http://jakarta.apache.org/alexandria/}Apache Jakarta Alexandria}} project,
+ and was initially based on the {{{http://vizant.sourceforge.net/}Vizant}} project, version 0.1.1.
+ See the alexandria-dev mail list for cvs commits around 2003-04-11.
+ See {{{http://sourceforge.net/mailarchive/forum.php?forum_name=vizant-devel&max_rows=25&style=nested&viewmonth=200304}notes}}
+ at the Vizant project wherein koseki and nicolaken talked about a code grant to ASF.
+
+ The code was maintained within {{{http://forrest.apache.org/}Apache Forrest}} project, as a subproject called Forrestdoc.
+ During the summer 2007, the Apache Forrest Team gave to the Apache Maven Team the Forrestdoc project.
+ See the {{{http://www.nabble.com/-Proposal--decide-the-future-of-forrestdoc-tf4060050.html}Forrest thread}} and the
+ {{{http://www.nabble.com/Forrestdoc-and-Maven-JXR-tf3864888s177.html}Maven thread}}.
+
+* Examples
+
+   * {{{examples/ant.html}Ant}}: Some Ant example.

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/index.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/apt/index.apt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/site.xml?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/site.xml (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/site.xml Mon Oct 15 14:48:25 2007
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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>
+  <bannerLeft>
+    <name>${project.name}</name>
+    <src>http://maven.apache.org/images/apache-maven-project-2.png</src>
+    <href>http://maven.apache.org/jxr/</href>
+  </bannerLeft>
+
+  <bannerRight>
+    <src>http://maven.apache.org/images/maven-logo-2.gif</src>
+  </bannerRight>
+
+  <publishDate format="dd MMM yyyy" />
+
+  <skin>
+    <groupId>org.apache.maven.skins</groupId>
+    <artifactId>maven-stylus-skin</artifactId>
+  </skin>
+
+  <body>
+    <links>
+      <item name="Apache" href="http://www.apache.org/"/>
+      <item name="Maven 1.x" href="http://maven.apache.org/maven-1.x"/>
+      <item name="Maven 2.x" href="http://maven.apache.org/"/>
+      <item name="Archiva" href="http://maven.apache.org/archiva"/>
+      <item name="Continuum" href="http://maven.apache.org/continuum"/>
+      <item name="SCM" href="http://maven.apache.org/scm"/>
+      <item name="Wagon" href="http://maven.apache.org/wagon"/>
+      <item name="JXR" href="http://maven.apache.org/jxr"/>
+      <item name="Doxia" href="http://maven.apache.org/doxia"/>
+    </links>
+
+    <head>
+      <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+      </script>
+      <script type="text/javascript">
+        _uacct = "UA-140879-1";
+        urchinTracker();
+        function expand( item ) {
+        var expandIt = document.getElementById( item );
+        if( expandIt.style.display == "block" ) {
+        expandIt.style.display = "none";
+        expandIt.parentNode.className = "collapsed";
+        } else {
+        expandIt.style.display = "block";
+        expandIt.parentNode.className = "expanded";
+        }
+        }
+      </script>
+    </head>
+
+    <menu name="Overview">
+      <item name="Introduction" href="index.html"/>
+    </menu>
+
+    <menu name="Examples">
+      <item name="Using Maven JXR Ant with Ant" href="/examples/ant.html"/>
+    </menu>
+
+    <menu ref="reports"/>
+  </body>
+</project>

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/AntDocTaskTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/AntDocTaskTest.java?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/AntDocTaskTest.java (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/AntDocTaskTest.java Mon Oct 15 14:48:25 2007
@@ -0,0 +1,144 @@
+package org.apache.maven.jxr.ant.doc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 junit.framework.TestCase;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class AntDocTaskTest
+    extends TestCase
+{
+    /**
+     * Call Antdoc task
+     *
+     * @throws Exception if any.
+     */
+    public void testDefaultExecute()
+        throws Exception
+    {
+        final String basedir = new File( "" ).getAbsolutePath();
+
+        File antDocDir = new File( basedir, "target/unit/antdoc-default" );
+        File build = new File( basedir, "src/test/resources/build.xml" );
+
+        Project antProject = new Project();
+        antProject.setBasedir( basedir );
+
+        AntDocTask task = new AntDocTask();
+        task.setProject( antProject );
+        task.init();
+        task.setAntFile( build );
+        task.setDestDir( antDocDir );
+        task.execute();
+
+        // Generated files
+        File generated = new File( antDocDir, "vizant.png" );
+        assertTrue( generated.exists() );
+        assertTrue( generated.length() > 0 );
+        generated = new File( antDocDir, "vizant.svg" );
+        assertTrue( generated.exists() );
+        assertTrue( generated.length() > 0 );
+        generated = new File( antDocDir, "target.html" );
+        assertTrue( generated.exists() );
+        assertTrue( generated.length() > 0 );
+        generated = new File( antDocDir, "InitialXML._xml" );
+        assertTrue( generated.exists() );
+        assertTrue( generated.length() > 0 );
+
+        // Copied files
+        File copied = new File( antDocDir, "BrowserLauncher.jar" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+        copied = new File( antDocDir, "nanoxml-2.1.1.jar" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+        copied = new File( antDocDir, "TGLinkBrowser.jar" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+        copied = new File( antDocDir, "index.html" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+        copied = new File( antDocDir, "cover.html" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+        copied = new File( antDocDir, "links.html" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+        copied = new File( antDocDir, "tg.html" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+        copied = new File( antDocDir, "main.css" );
+        assertTrue( copied.exists() );
+        assertTrue( generated.length() > 0 );
+    }
+
+    /**
+     * Call Antdoc task
+     *
+     * @throws Exception if any.
+     */
+    public void testNullExecute()
+        throws Exception
+    {
+        final String basedir = new File( "" ).getAbsolutePath();
+
+        File antDocDir = new File( basedir, "target/unit/antdoc-null" );
+        File build = new File( basedir, "src/test/resources/build.xml" );
+
+        Project antProject = new Project();
+        antProject.setBasedir( basedir );
+
+        AntDocTask task = new AntDocTask();
+        task.setProject( antProject );
+        task.init();
+
+        task.setAntFile( null );
+        task.setDestDir( antDocDir );
+        try
+        {
+            task.execute();
+            assertTrue( "Doesnt handle null ant file", false );
+        }
+        catch ( BuildException e )
+        {
+            assertTrue( true );
+        }
+
+        task.setAntFile( build );
+        task.setDestDir( null );
+        try
+        {
+            task.execute();
+            assertTrue( "Doesnt handle null dest", false );
+        }
+        catch ( BuildException e )
+        {
+            assertTrue( true );
+        }
+    }
+}

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/AntDocTaskTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/AntDocTaskTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/DotTaskTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/DotTaskTest.java?rev=584931&view=auto
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/DotTaskTest.java (added)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/DotTaskTest.java Mon Oct 15 14:48:25 2007
@@ -0,0 +1,129 @@
+package org.apache.maven.jxr.ant.doc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 junit.framework.TestCase;
+
+import org.apache.maven.jxr.ant.doc.DotTask.DotNotPresentInPathBuildException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class DotTaskTest
+    extends TestCase
+{
+    /**
+     * Call Dot task
+     *
+     * @throws Exception if any.
+     */
+    public void testDefaultExecute()
+        throws Exception
+    {
+        final String basedir = new File( "" ).getAbsolutePath();
+
+        File in = new File( basedir, "src/test/resources/dot/target.dot" );
+        File out = new File( basedir, "target/unit/dot-default/" );
+
+        Project antProject = new Project();
+        antProject.setBasedir( basedir );
+
+        DotTask task = new DotTask();
+        task.setProject( antProject );
+        task.setIn( in );
+        task.setDestDir( out );
+        try
+        {
+            task.execute();
+            assertTrue( "DOT exists in the path", true );
+        }
+        catch ( DotNotPresentInPathBuildException e )
+        {
+            assertTrue( "DOT doesnt exist in the path. Ignored test", true );
+            return;
+        }
+        catch ( BuildException e )
+        {
+            if ( e.getMessage().indexOf( "Execute failed" ) != -1 )
+            {
+                assertTrue( "Uncatch error:" + e.getMessage(), false );
+            }
+
+            assertEquals( "Error when calling dot.", e.getMessage() );
+        }
+
+        // Generated files
+        File generated = new File( out, "target.dot.svg" );
+        assertTrue( generated.exists() );
+        assertTrue( generated.length() > 0 );
+    }
+
+    /**
+     * Call Dot task
+     *
+     * @throws Exception if any.
+     */
+    public void testErrorExecute()
+        throws Exception
+    {
+        final String basedir = new File( "" ).getAbsolutePath();
+
+        File in = new File( basedir, "src/test/resources/dot/graph.dot" );
+        File out = new File( basedir, "target/unit/dot-default/" );
+
+        Project antProject = new Project();
+        antProject.setBasedir( basedir );
+
+        DotTask task = new DotTask();
+        task.setProject( antProject );
+        task.setIn( in );
+        task.setDestDir( out );
+        try
+        {
+            task.execute();
+            assertTrue( "DOT exists in the path", true );
+            assertTrue( "Doesnt handle dot error", false );
+        }
+        catch ( DotNotPresentInPathBuildException e )
+        {
+            assertTrue( "DOT doesnt exist in the path. Ignored test", true );
+            return;
+        }
+        catch ( BuildException e )
+        {
+            if ( e.getMessage().indexOf( "Execute failed" ) != -1 )
+            {
+                assertTrue( "Uncatch error:" + e.getMessage(), false );
+            }
+
+            assertEquals( "Error when calling dot.", e.getMessage() );
+        }
+
+        // Generated files
+        File generated = new File( out, "graph.dot.svg" );
+        assertFalse( generated.exists() );
+        assertFalse( generated.length() > 0 );
+    }
+}

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/DotTaskTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-ant/src/test/java/org/apache/maven/jxr/ant/doc/DotTaskTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"