You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/09/02 03:26:47 UTC

svn commit: r1164321 - in /myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin: ./ src/main/java/org/apache/myfaces/plugins/jsdoc/ src/main/java/org/apache/myfaces/plugins/jsdoc/util/

Author: lu4242
Date: Fri Sep  2 01:26:46 2011
New Revision: 1164321

URL: http://svn.apache.org/viewvc?rev=1164321&view=rev
Log:
refactoring to add report, jar generation and other useful goodies and fixes (scan src/main/resources and src/main/webapp folders automatically)

Added:
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/AbstractJSDocMojo.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocHelper.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocJarMojo.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocReportMojo.java
Modified:
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/   (props changed)
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/pom.xml
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocMojo.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/HTMLFileContentFilter.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/JSDocPackResources.java

Propchange: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Sep  2 01:26:46 2011
@@ -1 +1,12 @@
 *.iml
+*.ipr
+*.iws
+*.jdbc
+.classpath
+.externalToolBuilders
+.project
+.settings
+derby.log
+maven-eclipse.xml
+myfacesOrchestraDB
+target

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/pom.xml?rev=1164321&r1=1164320&r2=1164321&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/pom.xml (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/pom.xml Fri Sep  2 01:26:46 2011
@@ -45,9 +45,71 @@
         </url>
     </scm>
 
+    <properties>
+      <mavenVersion>2.0.9</mavenVersion>
+      <doxiaVersion>1.0</doxiaVersion>
+      <doxia-sitetoolsVersion>1.0</doxia-sitetoolsVersion>
+      <!-- 
+      <wagonVersion>1.0-beta-6</wagonVersion>
+      <sitePluginVersion>2.2</sitePluginVersion>
+      <projectInfoReportsPluginVersion>2.3.1</projectInfoReportsPluginVersion>
+       -->
+    </properties>
+  
+    <build>
+        <plugins>
+            <plugin>
+              <artifactId>maven-compiler-plugin</artifactId>
+              <version>2.0.2</version>
+              <inherited>true</inherited>
+              <configuration>
+                <source>1.5</source>
+                <target>1.5</target>
+              </configuration>
+            </plugin>
+        </plugins>
+    </build>
     <dependencies>
 
         <dependency>
+          <groupId>org.apache.maven</groupId>
+          <artifactId>maven-model</artifactId>
+          <version>${mavenVersion}</version>
+        </dependency>
+    
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-archiver</artifactId>
+            <version>2.3</version>
+        </dependency>
+        
+        <dependency>
+          <groupId>org.apache.maven.reporting</groupId>
+          <artifactId>maven-reporting-api</artifactId>
+          <version>3.0</version>
+        </dependency>
+        
+        <dependency>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-utils</artifactId>
+          <version>1.5.8</version>
+        </dependency>
+    
+        <!-- Doxia -->
+        <dependency>
+          <groupId>org.apache.maven.doxia</groupId>
+          <artifactId>doxia-sink-api</artifactId>
+          <version>${doxiaVersion}</version>
+        </dependency>
+    
+        <!-- Doxia-sitetools -->
+        <dependency>
+          <groupId>org.apache.maven.doxia</groupId>
+          <artifactId>doxia-site-renderer</artifactId>
+          <version>${doxia-sitetoolsVersion}</version>
+        </dependency>
+    
+        <dependency>
             <groupId>rhino</groupId>
             <artifactId>js</artifactId>
             <version>1.7R1</version>
@@ -66,6 +128,12 @@
             <artifactId>commons-io</artifactId>
             <version>1.4</version>
         </dependency>
+        
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.4</version>
+        </dependency>
 
         <!-- we have to add the stax api just in case
         we are on an older build system -->

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/AbstractJSDocMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/AbstractJSDocMojo.java?rev=1164321&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/AbstractJSDocMojo.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/AbstractJSDocMojo.java Fri Sep  2 01:26:46 2011
@@ -0,0 +1,538 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.plugins.jsdoc;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.MavenReportException;
+import org.apache.myfaces.plugins.jsdoc.util.HTMLFileContentFilter;
+import org.apache.myfaces.plugins.jsdoc.util.JSDocPackMaven;
+import org.apache.myfaces.plugins.jsdoc.util.JSFileNameFilter;
+import org.apache.myfaces.plugins.jsdoc.util.XMLConfig;
+
+public abstract class AbstractJSDocMojo extends AbstractMojo
+{
+    
+    // ----------------------------------------------------------------------
+    // Mojo components
+    // ----------------------------------------------------------------------
+
+    // ----------------------------------------------------------------------
+    // Mojo parameters
+    // ----------------------------------------------------------------------
+    
+    /**
+     * The Maven Project Object
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    protected MavenProject project;
+    
+    /**
+     * the root project build dir (target directory)
+     *
+     * @parameter expression="${project.build.directory}"
+     */
+    protected String projectBuildDir;
+    
+    // ----------------------------------------------------------------------
+    // Standard Options
+    // ----------------------------------------------------------------------
+    
+    /**
+     * The project source javascript directory, which are the source 
+     * files unprocessed by myfaces javascript plugin
+     *
+     * @parameter expression="${basedir}/src/main/javascript/"
+     */
+    protected String sourceDirectory;
+    
+    /**
+     * The relative dir name sourceDirectory is
+     *
+     * @parameter expression="src/main/javascript/"
+     */
+    protected String relativeSourceDirectory;
+    
+    /**
+     * The project resource directory, to take all files ending 
+     * with .js 
+     *
+     * @parameter expression="${basedir}/src/main/resources/"
+     */
+    protected File resourceDirectory;
+    
+    /**
+     * The relative dir name resourceDirectory is
+     *
+     * @parameter expression="src/main/resources/"
+     */
+    protected String relativeResourceDirectory;
+    
+    
+    /**
+     * The project webapp directory, to take all files ending
+     * with .js
+     *
+     * @parameter expression="${basedir}/src/main/webapp/"
+     */
+    protected String webappDirectory;
+    
+    /**
+     * The relative dir name webappDirectory is
+     *
+     * @parameter expression="src/main/webapp/"
+     */
+    protected String relativeWebappDirectory;
+    
+    /**
+     * Specifies the destination directory where jsdoc saves the generated HTML files.
+     *
+     * @parameter expression="${destDir}" alias="destDir" default-value="${project.build.directory}/jsdoc"
+     * @required
+     */
+    protected File outputDirectory;
+    
+    /**
+     * Path to the assembly file containing the file paths to our source javascript files
+     *
+     * @parameter expression="${basedir}/src/assembler/jsdoc-compiler.xml"
+     */
+    protected String assemblyFile;
+    
+    /**
+     * Specifies whether the Javadoc generation should be skipped.
+     *
+     * @since 2.5
+     * @parameter expression="${myfaces.jsdoc.skip}" default-value="false"
+     */
+    protected boolean skip;
+    
+    // ----------------------------------------------------------------------
+    // Standard JSDoc Options
+    // ----------------------------------------------------------------------
+    
+    //various jsdoc params, copied over as well as the corresponding snippets from
+    /**
+     * Whether to include symbols tagged as private. Default is <code>false</code>.
+     *
+     * @parameter expression="false"
+     */
+    protected boolean includePrivate;
+
+    /**
+     * Include all functions, even undocumented ones. Default is <code>false</code>.
+     *
+     * @parameter expression="false"
+     */
+    protected boolean includeUndocumented;
+
+    /**
+     * Include all functions, even undocumented, underscored ones. Default is <code>false</code>.
+     *
+     * @parameter expression="false"
+     */
+    protected boolean includeUndocumentedUnderscored;
+
+    /**
+     * template directory used by jsdoc the default is <code>templates/jsdoc</code> under the jsdoc root
+     *
+     * @parameter expression="templates/jsdoc"
+     */
+    protected String templates;
+
+    // ----------------------------------------------------------------------
+    // protected methods
+    // ----------------------------------------------------------------------
+
+    protected void executeReport( Locale unusedLocale )
+        throws MavenReportException
+    {
+        JSDocHelper helper = _setup();
+        try
+        {
+            _execute(helper);
+        }
+        catch (IOException e)
+        {
+            throw new MavenReportException(e.toString());
+        }
+        finally
+        {
+            _tearDown(helper);
+        }  
+    }
+
+    /**
+     * @return the output directory
+     */
+    protected String getOutputDirectory()
+    {
+        return outputDirectory.getAbsoluteFile().toString();
+    }
+    
+    protected MavenProject getProject()
+    {
+        return project;
+    }
+    
+    // ----------------------------------------------------------------------
+    // private methods
+    // ----------------------------------------------------------------------
+    
+    protected JSDocHelper _setup() throws MavenReportException
+    {
+        JSDocHelper helper = new JSDocHelper();
+        try
+        {
+            if (new File(assemblyFile).exists())
+            {
+                helper.setFileMap(new XMLConfig(assemblyFile));
+            }
+        }
+        catch (XMLStreamException e)
+        {
+            getLog().error(e);
+            throw new MavenReportException(e.toString());
+        }
+        catch (FileNotFoundException e)
+        {
+            getLog().error(e);
+            throw new MavenReportException(e.toString());
+        }
+        helper.setUnpacker(new JSDocPackMaven());
+        //unpacker = new JSDocPackResources();
+
+        helper.setJsdocRunPath(projectBuildDir + File.separator + JSDocMojoConst.JSDOC);
+        helper.setJsdocEngineUnpacked(projectBuildDir + File.separator + JSDocMojoConst.TEMP
+                + File.separator + JSDocMojoConst.JSDOC);
+
+        helper.setJavascriptTargetPath(helper.getJsdocRunPath() + File.separator + JSDocMojoConst.JAVASCRIPT);
+
+        File pathCreator = new File(helper.getJsdocEngineUnpacked());
+        File jsdocPathCreator = new File(helper.getJavascriptTargetPath());
+        pathCreator.mkdirs();
+        jsdocPathCreator.mkdirs();
+        return helper;
+    }
+
+    public void _tearDown(JSDocHelper helper) throws MavenReportException
+    {
+        try
+        {
+            FileUtils.deleteDirectory(new File(helper.getJsdocEngineUnpacked()));
+        }
+        catch (IOException e)
+        {
+            throw new MavenReportException(e.toString());
+        }
+    }
+
+    protected void _execute(JSDocHelper helper) throws MavenReportException, IOException
+    {
+
+        copyJavascripts(helper);
+
+        //fetchJavascriptSources(helper);
+        //now we have all files we now can now work on our plugin call
+        unpackJSDoc(helper);
+
+        String systemJsdocDir = setenvJSDocDir(helper);
+        String userDir = setenvUserDir(helper);
+        try
+        {
+            executeJSDoc(helper);
+        }
+        finally
+        {
+            resetSysenvVars(systemJsdocDir, userDir);
+        }
+    }
+
+    private void resetSysenvVars(String systemJsdocDir, String userDir)
+    {
+        if (systemJsdocDir != null)
+        {
+            System.setProperty(JSDocMojoConst.JSDOC_DIR, systemJsdocDir);
+        }
+        if (userDir != null)
+        {
+            System.setProperty("user.dir", userDir);
+        }
+    }
+
+    private void executeJSDoc(JSDocHelper helper)
+    {
+        List args = _initArguments(helper);
+
+        getLog().info("[JSDOC] Executing within maven: '" + args.toString().replaceAll(",", "") + "'");
+
+        // tell Rhino to run JSDoc with the provided params
+        // without calling System.exit
+
+        org.mozilla.javascript.tools.shell.Main.main((String[]) args.toArray(new String[0]));
+
+        this.fixHTML(helper);
+    }
+
+    private String setenvUserDir(JSDocHelper helper)
+    {
+        String userDir = System.getProperty("user.dir");
+        System.setProperty("user.dir", helper.getJsdocEngineUnpacked() + File.separator);
+        return userDir;
+    }
+
+    private String setenvJSDocDir(JSDocHelper helper)
+    {
+        String systemJsdocDir = System.getProperty(JSDocMojoConst.JSDOC_DIR);
+        System.setProperty(JSDocMojoConst.JSDOC_DIR, helper.getJsdocEngineUnpacked() + File.separator);
+        return systemJsdocDir;
+    }
+
+    private void unpackJSDoc(JSDocHelper helper) throws IOException
+    {
+        getLog().info("[JSDOC] Unpacking jsdoc toolkit for further processing");
+        helper.getUnpacker().unpack(helper.getJsdocEngineUnpacked(), getLog());
+        getLog().info("[JSDOC] Unpacking jsdoc toolkit for further processing done");
+    }
+
+    /**
+     * initially copies all source files from the given source dir to the target
+     * dir so that the files can be referenced later on by the html files
+     */
+    private void copyJavascripts(JSDocHelper helper) throws IOException
+    {
+        getLog().info("[JSDOC] Copying all javascript sources to the target dir for later reference");
+        
+        if (!StringUtils.isEmpty(sourceDirectory))
+        {
+            File buildSourceDirFile = new File(sourceDirectory);
+            if (buildSourceDirFile.exists())
+            {
+                FileUtils.copyDirectory(
+                        buildSourceDirFile, 
+                        new File(helper.getJavascriptTargetPath()+'/'+relativeSourceDirectory), 
+                        new FileFilter()
+                {
+                    
+                    public boolean accept(File pathname)
+                    {
+                        if (pathname.getName().endsWith(".svn"))
+                        {
+                            return false;
+                        }
+                        return true;
+                    }
+                });
+            }
+        }
+
+        if (resourceDirectory != null)
+        {
+            if (resourceDirectory.exists())
+            {
+                FileUtils.copyDirectory(
+                        resourceDirectory, 
+                        new File(helper.getJavascriptTargetPath()+'/'+relativeResourceDirectory), 
+                        new FileFilter()
+                {
+                    
+                    public boolean accept(File pathname)
+                    {
+                        if (pathname.getName().endsWith(".svn"))
+                        {
+                            return false;
+                        }
+                        if (pathname.isDirectory())
+                        {
+                            return true;
+                        }
+                        if (pathname.getName().endsWith(".js"))
+                        {
+                            return true;
+                        }
+                        return false;
+                    }
+                });
+            }
+        }
+        
+        if (!StringUtils.isEmpty(webappDirectory))
+        {
+            File buildWebappSourceDirFile = new File(webappDirectory);
+            if (buildWebappSourceDirFile.exists())
+            {
+                FileUtils.copyDirectory(
+                        buildWebappSourceDirFile, 
+                        new File(helper.getJavascriptTargetPath()+'/'+relativeWebappDirectory), 
+                        new FileFilter()
+                {
+                    
+                    public boolean accept(File pathname)
+                    {
+                        if (pathname.getName().endsWith(".svn"))
+                        {
+                            return false;
+                        }
+                        if (pathname.isDirectory())
+                        {
+                            return true;
+                        }
+                        if (pathname.getName().endsWith(".js"))
+                        {
+                            return true;
+                        }
+                        return false;
+                    }
+                });
+            }
+        }
+        
+        getLog().info("[JSDOC] Copying done without any errors");
+    }
+
+    private final List _initArguments(JSDocHelper helper)
+    {
+        List args = new ArrayList();
+        String runJsPath = helper.getJsdocEngineUnpacked() + File.separator + JSDocMojoConst.APP
+                + File.separator + JSDocMojoConst.RUN_JS;
+        args.add(runJsPath);
+
+        if (this.includeUndocumented)
+        {
+            args.add(JSDocMojoConst.PARAM_UNDOCUMENTED);
+        }
+        if (this.includeUndocumentedUnderscored)
+        {
+            args.add(JSDocMojoConst.PARAM_UNDOCUMENTED_UNDERSCORED);
+        }
+        if (this.includePrivate)
+        {
+            args.add(JSDocMojoConst.PARAM_PRIVATE);
+        }
+        args.add(JSDocMojoConst.PARAM_OUTPUT + JSDocMojoConst.EQUALS + this.getOutputDirectory());
+        args.add(JSDocMojoConst.PARAM_TEMPLATE + JSDocMojoConst.EQUALS + getTemplateDirectory(helper));
+
+        args.addAll(fetchJavascriptSources(helper));
+        //according to the run.js source the last argument
+        //must be a -j param pointing to the jsdoc javascripts
+        args.add(JSDocMojoConst.PARAM_JS_FLAG + JSDocMojoConst.EQUALS + runJsPath);
+        return args;
+    }
+
+    /**
+     * @return the directory as absolute path holding the jsdoc toolkit templates
+     */
+    private final String getTemplateDirectory(JSDocHelper helper)
+    {
+        return (JSDocMojoConst.TEMPLATES_JSDOC.equals(this.templates)) ?
+                helper.getJsdocEngineUnpacked() + File.separator + this.templates :
+                this.templates;
+    }
+
+    /**
+     * @return the target directory for the jsdoc files
+     */
+    /*
+    private final String getOutputDirectory()
+    {
+        return (this.outputDirectory == null || this.outputDirectory.equals("")) ?
+                projectBuildDir + File.separator + JSDocMojoConst.JSDOC :
+                this.outputDirectory;
+
+    }*/
+
+    /**
+     * @return fetches the sources for the javascripts in the order given by the xml
+     */
+    private List<String> fetchJavascriptSources(JSDocHelper helper)
+    {
+        List<String> sources = null;
+        getLog().info("[JSDOC] Fetch Javascript sources for further processing");
+        if (helper.getFileMap() == null)
+        {
+            sources = new ArrayList<String>();
+            File javascriptTargetFileBase = new File(helper.getJavascriptTargetPath());
+            addSources(sources, javascriptTargetFileBase);
+            return sources;
+        }
+        else
+        {
+            JSFileNameFilter fileNameFilter = new JSFileNameFilter(helper.getFileMap());
+            //FileUtils.iterateFiles(new File(getOutputDirectory()), fileNameFilter, TrueFileFilter.INSTANCE);
+            FileUtils.iterateFiles(new File(helper.getJavascriptTargetPath()), fileNameFilter, TrueFileFilter.INSTANCE);
+    
+            Map sortedResult = fileNameFilter.getSortedResults();
+            sources = new ArrayList(sortedResult.size());
+            Iterator it = sortedResult.entrySet().iterator();
+            while (it.hasNext())
+            {
+                Map.Entry singleItem = (Map.Entry) it.next();
+                String finalFileName = (String) singleItem.getValue();
+                sources.add(finalFileName);
+            }
+        }
+        getLog().info("[JSDOC] All Javascript sources are prepared for processing");
+        return sources;
+    }
+    
+    private void addSources(List<String> sources, File file)
+    {
+        if (file.isDirectory())
+        {
+            File[] files = file.listFiles();
+            if (files != null)
+            {
+                for (int i = 0; i < files.length; i++)
+                {
+                    addSources(sources, files[i]);
+                }
+            }
+        }
+        else
+        {
+            sources.add(file.getAbsolutePath());
+        }
+    }
+
+    private void fixHTML(JSDocHelper helper)
+    {
+        FileUtils.iterateFiles(new File(getOutputDirectory()), 
+                new HTMLFileContentFilter(helper.getJavascriptTargetPath()),
+                TrueFileFilter.INSTANCE);
+    }
+
+}

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocHelper.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocHelper.java?rev=1164321&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocHelper.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocHelper.java Fri Sep  2 01:26:46 2011
@@ -0,0 +1,103 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.plugins.jsdoc;
+
+import org.apache.myfaces.plugins.jsdoc.util.JSDocPack;
+import org.apache.myfaces.plugins.jsdoc.util.XMLConfig;
+
+public class JSDocHelper
+{
+    /**
+     * the parsed xml filemap containing the single source files
+     */
+    private XMLConfig fileMap;
+
+    private JSDocPack unpacker;
+
+    /**
+     * target path for the unpacked jsdoc engine
+     */
+    private String jsdocEngineUnpacked = null;
+
+    /**
+     * target patchs for the javascript
+     */
+    private String javascriptTargetPath = null;
+
+    /**
+     * run path for the jsdoc engine
+     */
+    private String jsdocRunPath = null;
+
+    public JSDocHelper()
+    {
+    }
+
+    public XMLConfig getFileMap()
+    {
+        return fileMap;
+    }
+
+    public void setFileMap(XMLConfig fileMap)
+    {
+        this.fileMap = fileMap;
+    }
+
+    public JSDocPack getUnpacker()
+    {
+        return unpacker;
+    }
+
+    public void setUnpacker(JSDocPack unpacker)
+    {
+        this.unpacker = unpacker;
+    }
+
+    public String getJsdocEngineUnpacked()
+    {
+        return jsdocEngineUnpacked;
+    }
+
+    public void setJsdocEngineUnpacked(String jsdocEngineUnpacked)
+    {
+        this.jsdocEngineUnpacked = jsdocEngineUnpacked;
+    }
+
+    public String getJavascriptTargetPath()
+    {
+        return javascriptTargetPath;
+    }
+
+    public void setJavascriptTargetPath(String javascriptTargetPath)
+    {
+        this.javascriptTargetPath = javascriptTargetPath;
+    }
+
+    public String getJsdocRunPath()
+    {
+        return jsdocRunPath;
+    }
+
+    public void setJsdocRunPath(String jsdocRunPath)
+    {
+        this.jsdocRunPath = jsdocRunPath;
+    }
+    
+    
+}

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocJarMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocJarMojo.java?rev=1164321&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocJarMojo.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocJarMojo.java Fri Sep  2 01:26:46 2011
@@ -0,0 +1,272 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.plugins.jsdoc;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+
+/**
+ * @author  Werner Punz
+ *          Leonardo Uribe
+ * @version 1.0.0
+ *          <p/>
+ *          A simple jsdoc plugin which should cover our documentation needs
+ *          Note this plugin is a simplified tailored derivate from
+ *          <p/>
+ *          http://www.abiss.gr some code stems from there.
+ *          <p/>
+ *          since we use jsdoc for now and are not in the reporting part
+ *          a simple plugin suffices.
+ * @goal jar
+ * @phase package
+ */
+public class JSDocJarMojo extends AbstractJSDocMojo
+{
+
+    
+    
+    /** Includes all generated Javascript doc files */
+    private static final String[] DEFAULT_INCLUDES = new String[] { "**/**" };
+
+    /**
+     * Excludes none
+     */
+    private static final String[] DEFAULT_EXCLUDES = new String[] {};
+
+    
+    // ----------------------------------------------------------------------
+    // Mojo components
+    // ----------------------------------------------------------------------
+
+    /**
+     * Used for attaching the artifact in the project.
+     *
+     * @component
+     */
+    private MavenProjectHelper projectHelper;
+
+    /**
+     * The Jar archiver.
+     *
+     * @component role="org.codehaus.plexus.archiver.Archiver" roleHint="jar"
+     * @since 2.5
+     */
+    private JarArchiver jarArchiver;
+    
+    /**
+     * The archive configuration to use.
+     * See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven Archiver Reference</a>.
+     *
+     * @parameter
+     * @since 2.5
+     */
+    private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+    
+    // ----------------------------------------------------------------------
+    // Parameters
+    // ----------------------------------------------------------------------
+
+    /**
+     * Specifies the directory where the generated jar file will be put.
+     *
+     * @parameter expression="${project.build.directory}"
+     */
+    private String jarOutputDirectory;
+    
+    /**
+     * Specifies the filename that will be used for the generated jar file. Please note that <code>-jsdoc</code>
+     * or <code>-test-jsdoc</code> will be appended to the file name.
+     *
+     * @parameter expression="${project.build.finalName}"
+     */
+    private String finalName;
+    
+    /**
+     * Specifies whether to attach the generated artifact to the project helper.
+     * <br/>
+     *
+     * @parameter expression="${attach}" default-value="true"
+     */
+    private boolean attach;
+    
+    /**
+     * Path to the default MANIFEST file to use. It will be used if
+     * <code>useDefaultManifestFile</code> is set to <code>true</code>.
+     *
+     * @parameter expression="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+     * @required
+     * @readonly
+     * @since 1.0
+     */
+    private File defaultManifestFile;
+
+    /**
+     * Set this to <code>true</code> to enable the use of the <code>defaultManifestFile</code>.
+     * <br/>
+     *
+     * @parameter default-value="false"
+     * @since 1.0
+     */
+    private boolean useDefaultManifestFile;
+
+    public void execute() throws MojoExecutionException
+    {
+        if ( skip )
+        {
+            getLog().info( "Skipping jsdoc generation" );
+            return;
+        }
+    
+        File innerDestDir = new File( getOutputDirectory() );
+   
+        try
+        {
+            executeReport(Locale.US);
+            if ( innerDestDir.exists() )
+            {
+                File outputFile = generateArchive( innerDestDir, finalName + "-" + getClassifier() + ".jar" );
+    
+                if ( !attach )
+                {
+                    getLog().info( "NOT adding jsdoc to attached artifacts list." );
+                }
+                else
+                {
+                    // TODO: these introduced dependencies on the project are going to
+                    // become problematic - can we export it
+                    //  through metadata instead?
+                    projectHelper.attachArtifact( project, "jsdoc", getClassifier(), outputFile );
+                }
+            }
+        }
+        catch ( ArchiverException e )
+        {
+            getLog().error("ArchiverException: Error while creating archive", e );
+        }
+        catch ( IOException e )
+        {
+            getLog().error("IOException: Error while creating archive", e );
+        }
+        catch ( MavenReportException e )
+        {
+            getLog().error("MavenReportException: Error while creating archive", e );
+        }
+        catch ( RuntimeException e )
+        {
+            getLog().error("RuntimeException: Error while creating archive", e );
+        }
+    }
+    
+    // ----------------------------------------------------------------------
+    // Protected methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * @return the wanted classifier, i.e. <code>jsdoc</code> or <code>test-jsdoc</code>
+     */
+    protected String getClassifier()
+    {
+        return "jsdoc";
+    }
+    
+    // ----------------------------------------------------------------------
+    // private methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * Method that creates the jar file
+     *
+     * @param jsdocFiles the directory where the generated jar file will be put
+     * @param jarFileName the filename of the generated jar file
+     * @return a File object that contains the generated jar file
+     * @throws ArchiverException if any
+     * @throws IOException if any
+     */
+    private File generateArchive( File jsdocFiles, String jarFileName )
+        throws ArchiverException, IOException
+    {
+        File jsdocJar = new File( jarOutputDirectory, jarFileName );
+
+        if ( jsdocJar.exists() )
+        {
+            jsdocJar.delete();
+        }
+
+        MavenArchiver archiver = new MavenArchiver();
+        archiver.setArchiver( jarArchiver );
+        archiver.setOutputFile( jsdocJar );
+
+        File contentDirectory = jsdocFiles;
+        if ( !contentDirectory.exists() )
+        {
+            getLog().warn( "JAR will be empty - no content was marked for inclusion!" );
+        }
+        else
+        {
+            archiver.getArchiver().addDirectory( contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES );
+        }
+
+        List<Resource> resources = project.getBuild().getResources();
+
+        for ( Resource r : resources )
+        {
+            if ( r.getDirectory().endsWith( "maven-shared-archive-resources" ) )
+            {
+                archiver.getArchiver().addDirectory( new File( r.getDirectory() ) );
+            }
+        }
+
+        if ( useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null )
+        {
+            getLog().info( "Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath() );
+            archive.setManifestFile( defaultManifestFile );
+        }
+
+        try
+        {
+            // we don't want Maven stuff
+            archive.setAddMavenDescriptor( false );
+            archiver.createArchive( project, archive );
+        }
+        catch ( ManifestException e )
+        {
+            throw new ArchiverException( "ManifestException: " + e.getMessage(), e );
+        }
+        catch ( DependencyResolutionRequiredException e )
+        {
+            throw new ArchiverException( "DependencyResolutionRequiredException: " + e.getMessage(), e );
+        }
+
+        return jsdocJar;
+    }
+
+}
\ No newline at end of file

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocMojo.java?rev=1164321&r1=1164320&r2=1164321&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocMojo.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocMojo.java Fri Sep  2 01:26:46 2011
@@ -18,25 +18,10 @@
  */
 package org.apache.myfaces.plugins.jsdoc;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.filefilter.TrueFileFilter;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.myfaces.plugins.jsdoc.util.HTMLFileContentFilter;
-import org.apache.myfaces.plugins.jsdoc.util.XMLConfig;
-import org.apache.myfaces.plugins.jsdoc.util.JSDocPack;
-import org.apache.myfaces.plugins.jsdoc.util.JSDocPackMaven;
-import org.apache.myfaces.plugins.jsdoc.util.JSFileNameFilter;
+import java.util.Locale;
 
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.reporting.MavenReportException;
 
 /**
  * @author Werner Punz (latest modification by $Author$)
@@ -51,315 +36,23 @@ import java.util.Map;
  *          a simple plugin suffices.
  * @goal jsdoc
  */
-public class JSDocMojo extends AbstractMojo
+public class JSDocMojo extends AbstractJSDocMojo
 {
-
-    /**
-     * the root project build dir (target directory)
-     *
-     * @parameter expression="${project.build.directory}"
-     */
-    String projectBuildDir;
-
-    /**
-     * The project source directory
-     *
-     * @parameter expression="${project.build.directory}/../src/main/javascript/META-INF/"
-     */
-    String buildSourceDirectory;
-
-    /**
-     * Path to the assembly file containing the file paths to our source javascript files
-     *
-     * @parameter expression="${project.build.directory}/../src/assembler/jsdoc-compiler.xml"
-     */
-    String assemblyFile;
-
-    //various jsdoc params, copied over as well as the corresponding snippets from
-    /**
-     * Whether to include symbols tagged as private. Default is <code>false</code>.
-     *
-     * @parameter expression="false"
-     */
-    boolean includePrivate;
-
-    /**
-     * Include all functions, even undocumented ones. Default is <code>false</code>.
-     *
-     * @parameter expression="false"
-     */
-    boolean includeUndocumented;
-
-    /**
-     * Include all functions, even undocumented, underscored ones. Default is <code>false</code>.
-     *
-     * @parameter expression="false"
-     */
-    boolean includeUndocumentedUnderscored;
-
-    /**
-     * template directory used by jsdoc the default is <code>templates/jsdoc</code> under the jsdoc root
-     *
-     * @parameter expression="templates/jsdoc"
-     */
-    String templates;
-
-    /**
-     * output dir override
-     *
-     * @parameter expression=""
-     */
-    String outputDirectory;
-
-    /**
-     * the parsed xml filemap containing the single source files
-     */
-    XMLConfig fileMap;
-
-    JSDocPack unpacker;
-
-    /**
-     * target path for the unpacked jsdoc engine
-     */
-    String jsdocEngineUnpacked = null;
-
-    /**
-     * target patchs for the javascript
-     */
-    String javascriptTargetPath = null;
-
-    /**
-     * run path for the jsdoc engine
-     */
-    String jsdocRunPath = null;
-
-    protected void _setup() throws MojoExecutionException
-    {
-        try
-        {
-            fileMap = new XMLConfig(assemblyFile);
-        }
-        catch (XMLStreamException e)
-        {
-            getLog().error(e);
-            throw new MojoExecutionException(e.toString());
-        }
-        catch (FileNotFoundException e)
-        {
-            getLog().error(e);
-            throw new MojoExecutionException(e.toString());
-        }
-        unpacker = new JSDocPackMaven();
-        //unpacker = new JSDocPackResources();
-
-        jsdocRunPath = projectBuildDir + File.separator + JSDocMojoConst.JSDOC;
-        jsdocEngineUnpacked = projectBuildDir + File.separator + JSDocMojoConst.TEMP
-                + File.separator + JSDocMojoConst.JSDOC;
-
-        javascriptTargetPath = jsdocRunPath + File.separator + JSDocMojoConst.JAVASCRIPT;
-
-        File pathCreator = new File(jsdocEngineUnpacked);
-        File jsdocPathCreator = new File(javascriptTargetPath);
-        pathCreator.mkdirs();
-        jsdocPathCreator.mkdirs();
-    }
-
-    public void _tearDown() throws MojoExecutionException
-    {
-        try
-        {
-            FileUtils.deleteDirectory(new File(jsdocEngineUnpacked));
-        }
-        catch (IOException e)
-        {
-            throw new MojoExecutionException(e.toString());
-        }
-    }
-
-    protected void _execute() throws MojoExecutionException, IOException
-    {
-
-        copyJavascripts();
-
-        fetchJavascriptSources();
-        //now we have all files we now can now work on our plugin call
-        unpackJSDoc();
-
-        String systemJsdocDir = setenvJSDocDir();
-        String userDir = setenvUserDir();
-        try
-        {
-            executeJSDoc();
-        }
-        finally
-        {
-            resetSysenvVars(systemJsdocDir, userDir);
-        }
-    }
-
-    private void resetSysenvVars(String systemJsdocDir, String userDir)
-    {
-        if (systemJsdocDir != null)
-        {
-            System.setProperty(JSDocMojoConst.JSDOC_DIR, systemJsdocDir);
-        }
-        if (userDir != null)
-        {
-            System.setProperty("user.dir", userDir);
-        }
-    }
-
-    private void executeJSDoc()
-    {
-        List args = _initArguments();
-
-        getLog().info("[JSDOC] Executing within maven: '" + args.toString().replaceAll(",", "") + "'");
-
-        // tell Rhino to run JSDoc with the provided params
-        // without calling System.exit
-
-        org.mozilla.javascript.tools.shell.Main.main((String[]) args.toArray(new String[0]));
-
-        this.fixHTML();
-    }
-
-    private String setenvUserDir()
-    {
-        String userDir = System.getProperty("user.dir");
-        System.setProperty("user.dir", jsdocEngineUnpacked + File.separator);
-        return userDir;
-    }
-
-    private String setenvJSDocDir()
-    {
-        String systemJsdocDir = System.getProperty(JSDocMojoConst.JSDOC_DIR);
-        System.setProperty(JSDocMojoConst.JSDOC_DIR, jsdocEngineUnpacked + File.separator);
-        return systemJsdocDir;
-    }
-
-    private void unpackJSDoc() throws IOException
-    {
-        getLog().info("[JSDOC] Unpacking jsdoc toolkit for further processing");
-        unpacker.unpack(jsdocEngineUnpacked, getLog());
-        getLog().info("[JSDOC] Unpacking jsdoc toolkit for further processing done");
-    }
-
-    /**
-     * initially copies all source files from the given source dir to the target
-     * dir so that the files can be referenced later on by the html files
-     */
-    private void copyJavascripts() throws IOException
-    {
-        getLog().info("[JSDOC] Copying all javascript sources to the target dir for later reference");
-        FileUtils.copyDirectory(new File(buildSourceDirectory), new File(javascriptTargetPath), new FileFilter()
-        {
-            
-            public boolean accept(File pathname)
-            {
-                if (pathname.getName().endsWith(".svn"))
-                {
-                    return false;
-                }
-                return true;
-            }
-        });
-        getLog().info("[JSDOC] Copying done without any errors");
-    }
-
-    private final List _initArguments()
-    {
-        List args = new ArrayList();
-        String runJsPath = jsdocEngineUnpacked + File.separator + JSDocMojoConst.APP
-                + File.separator + JSDocMojoConst.RUN_JS;
-        args.add(runJsPath);
-
-        if (this.includeUndocumented)
-        {
-            args.add(JSDocMojoConst.PARAM_UNDOCUMENTED);
-        }
-        if (this.includeUndocumentedUnderscored)
-        {
-            args.add(JSDocMojoConst.PARAM_UNDOCUMENTED_UNDERSCORED);
-        }
-        if (this.includePrivate)
-        {
-            args.add(JSDocMojoConst.PARAM_PRIVATE);
-        }
-        args.add(JSDocMojoConst.PARAM_OUTPUT + JSDocMojoConst.EQUALS + this.getOutputDirectory());
-        args.add(JSDocMojoConst.PARAM_TEMPLATE + JSDocMojoConst.EQUALS + getTemplateDirectory());
-
-        args.addAll(fetchJavascriptSources());
-        //according to the run.js source the last argument
-        //must be a -j param pointing to the jsdoc javascripts
-        args.add(JSDocMojoConst.PARAM_JS_FLAG + JSDocMojoConst.EQUALS + runJsPath);
-        return args;
-    }
-
-    /**
-     * @return the directory as absolute path holding the jsdoc toolkit templates
-     */
-    private final String getTemplateDirectory()
-    {
-        return (JSDocMojoConst.TEMPLATES_JSDOC.equals(this.templates)) ?
-                this.jsdocEngineUnpacked + File.separator + this.templates :
-                this.templates;
-    }
-
-    /**
-     * @return the target directory for the jsdoc files
-     */
-    private final String getOutputDirectory()
-    {
-        return (this.outputDirectory == null || this.outputDirectory.equals("")) ?
-                projectBuildDir + File.separator + JSDocMojoConst.JSDOC :
-                this.outputDirectory;
-
-    }
-
-    /**
-     * @return fetches the sources for the javascripts in the order given by the xml
-     */
-    private List fetchJavascriptSources()
-    {
-        getLog().info("[JSDOC] Fetch Javascript sources for further processing");
-        JSFileNameFilter fileNameFilter = new JSFileNameFilter(fileMap);
-        FileUtils.iterateFiles(new File(getOutputDirectory()), fileNameFilter, TrueFileFilter.INSTANCE);
-
-        Map sortedResult = fileNameFilter.getSortedResults();
-        List sources = new ArrayList(sortedResult.size());
-        Iterator it = sortedResult.entrySet().iterator();
-        while (it.hasNext())
-        {
-            Map.Entry singleItem = (Map.Entry) it.next();
-            String finalFileName = (String) singleItem.getValue();
-            sources.add(finalFileName);
-        }
-        getLog().info("[JSDOC] All Javascript sources are prepared for processing");
-        return sources;
-    }
-
-    private void fixHTML()
-    {
-        FileUtils.iterateFiles(new File(getOutputDirectory()), new HTMLFileContentFilter(getOutputDirectory()),
-                TrueFileFilter.INSTANCE);
-    }
-
+    
     public void execute() throws MojoExecutionException
     {
-        _setup();
         try
         {
-            _execute();
+            executeReport(Locale.US);
         }
-        catch (IOException e)
+        catch ( MavenReportException e )
         {
-            throw new MojoExecutionException(e.toString());
+            getLog().error("MavenReportException: Error while creating archive", e );
         }
-        finally
+        catch ( RuntimeException e )
         {
-            _tearDown();
+            getLog().error("RuntimeException: Error while creating archive", e );
         }
-
     }
 
 }

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocReportMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocReportMojo.java?rev=1164321&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocReportMojo.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/JSDocReportMojo.java Fri Sep  2 01:26:46 2011
@@ -0,0 +1,249 @@
+/*
+ *  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.
+ */
+package org.apache.myfaces.plugins.jsdoc;
+
+import java.io.File;
+import java.util.Locale;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
+import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.reporting.MavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.doxia.sink.Sink;
+
+/**
+ * <p/>
+ * A simple jsdoc plugin which should cover our documentation needs
+ * Note this plugin is a simplified tailored derivate from
+ * <p/>
+ * http://www.abiss.gr some code stems from there.
+ * <p/>
+ * since we use jsdoc for now and are not in the reporting part
+ * a simple plugin suffices.
+ *          
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ * @goal jsdocreport
+ * @execute phase="generate-resources"
+ */
+public class JSDocReportMojo extends AbstractJSDocMojo implements MavenReport
+{
+    // ----------------------------------------------------------------------
+    // Report Mojo Parameters
+    // ----------------------------------------------------------------------
+
+    /**
+     * Specifies the destination directory where jsdoc saves the generated HTML files.
+     *
+     * @parameter expression="${reportOutputDirectory}" default-value="${project.reporting.outputDirectory}/jsdoc"
+     * @required
+     */
+    private File reportOutputDirectory;
+
+    /**
+     * The name of the destination directory.
+     * <br/>
+     *
+     * @since 2.1
+     * @parameter expression="${destDir}" default-value="jsdoc"
+     */
+    private String destDir;
+
+    /**
+     * The name of the Javadoc report to be displayed in the Maven Generated Reports page
+     * (i.e. <code>project-reports.html</code>).
+     *
+     * @since 2.1
+     * @parameter expression="${name}"
+     */
+    private String name;
+
+    /**
+     * The description of the Javadoc report to be displayed in the Maven Generated Reports page
+     * (i.e. <code>project-reports.html</code>).
+     *
+     * @since 2.1
+     * @parameter expression="${description}"
+     */
+    private String description;
+
+    // ----------------------------------------------------------------------
+    // Report public methods
+    // ----------------------------------------------------------------------
+
+    /** {@inheritDoc} */
+    public String getName( Locale locale )
+    {
+        if ( StringUtils.isEmpty( name ) )
+        {
+            //return getBundle( locale ).getString( "report.jsdoc.name" );
+            return "JSDoc Report";
+        }
+
+        return name;
+    }
+
+    /** {@inheritDoc} */
+    public String getDescription( Locale locale )
+    {
+        if ( StringUtils.isEmpty( description ) )
+        {
+            //return getBundle( locale ).getString( "report.jsdoc.description" );
+            return "Javascript report using JSDoc";
+        }
+
+        return description;
+    }
+
+    /** {@inheritDoc} */
+    public void generate( Sink sink, Locale locale )
+        throws MavenReportException
+    {
+        outputDirectory = getReportOutputDirectory();
+
+        try
+        {
+            executeReport( locale );
+        }
+        catch ( MavenReportException e )
+        {
+            getLog().error( "Error while creating jsdoc report: " + e.getMessage(), e );
+        }
+        catch ( RuntimeException e )
+        {
+            getLog().error( "Error while creating jsdoc report: " + e.getMessage(), e );
+        }
+    }
+
+    /** {@inheritDoc} */
+    public String getOutputName()
+    {
+        return destDir + "/index";
+    }
+
+    /** {@inheritDoc} */
+    public boolean isExternalReport()
+    {
+        return true;
+    }
+
+    public boolean canGenerateReport()
+    {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    public String getCategoryName()
+    {
+        return CATEGORY_PROJECT_REPORTS;
+    }
+
+    /** {@inheritDoc} */
+    public File getReportOutputDirectory()
+    {
+        if ( reportOutputDirectory == null )
+        {
+            return outputDirectory;
+        }
+
+        return reportOutputDirectory;
+    }
+
+    /**
+     * Method to set the directory where the generated reports will be put
+     *
+     * @param reportOutputDirectory the directory file to be set
+     */
+    public void setReportOutputDirectory( File reportOutputDirectory )
+    {
+        updateReportOutputDirectory( reportOutputDirectory, destDir );
+    }
+
+    public void setDestDir( String destDir )
+    {
+        this.destDir = destDir;
+        updateReportOutputDirectory( reportOutputDirectory, destDir );
+    }
+
+    private void updateReportOutputDirectory( File reportOutputDirectory, String destDir )
+    {
+        if ( reportOutputDirectory != null && destDir != null
+             && !reportOutputDirectory.getAbsolutePath().endsWith( destDir ) )
+        {
+            this.reportOutputDirectory = new File( reportOutputDirectory, destDir );
+        }
+        else
+        {
+            this.reportOutputDirectory = reportOutputDirectory;
+        }
+    }
+
+    /**
+     * Gets the resource bundle for the specified locale.
+     *
+     * @param locale The locale of the currently generated report.
+     * @return The resource bundle for the requested locale.
+     */
+    //private ResourceBundle getBundle( Locale locale )
+    //{
+    //    return ResourceBundle.getBundle( "jsdoc-report", locale, getClass().getClassLoader() );
+    //}
+    
+    public void execute() throws MojoExecutionException
+    {
+        if ( skip )
+        {
+            getLog().info( "Skipping jsdoc generation" );
+            return;
+        }
+        
+        try
+        {
+            executeReport(Locale.US);
+        }
+        catch ( MavenReportException e )
+        {
+            getLog().error("MavenReportException: Error while creating archive", e );
+        }
+        catch ( RuntimeException e )
+        {
+            getLog().error("RuntimeException: Error while creating archive", e );
+        }
+        
+        try
+        {
+            RenderingContext context = new RenderingContext( outputDirectory, getOutputName() + ".html" );
+            SiteRendererSink sink = new SiteRendererSink( context );
+            Locale locale = Locale.getDefault();
+            generate( sink, locale );
+        }
+        catch ( MavenReportException e )
+        {
+            getLog().error("An error has occurred in " + getName( Locale.ENGLISH ) + " report generation", e );
+        }
+        catch ( RuntimeException e )
+        {
+            getLog().error("An error has occurred in " + getName( Locale.ENGLISH ) + " report generation", e );
+        }
+
+    }
+
+}

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/HTMLFileContentFilter.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/HTMLFileContentFilter.java?rev=1164321&r1=1164320&r2=1164321&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/HTMLFileContentFilter.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/HTMLFileContentFilter.java Fri Sep  2 01:26:46 2011
@@ -81,7 +81,12 @@ public class HTMLFileContentFilter imple
             if (file.getName().startsWith(substitutionName))
             {
                 String newName = file.getName().substring(substitutionName.length());
-                file.renameTo(new File(file.getParentFile(), newName));
+                File renameFile = new File(file.getParentFile(), newName);
+                if (renameFile.exists())
+                {
+                    renameFile.delete();
+                }
+                file.renameTo(renameFile);
             }
             else
             {
@@ -106,7 +111,12 @@ public class HTMLFileContentFilter imple
             if (s.startsWith(substitutionName))
             {
                 String newName = s.substring(substitutionName.length());
-                file.renameTo(new File(file.getParentFile(), newName));
+                File renameFile = new File(file.getParentFile(), newName);
+                if (renameFile.exists())
+                {
+                    renameFile.delete();
+                }
+                file.renameTo(renameFile);
             }
             else
             {

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/JSDocPackResources.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/JSDocPackResources.java?rev=1164321&r1=1164320&r2=1164321&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/JSDocPackResources.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-jsdoc-plugin/src/main/java/org/apache/myfaces/plugins/jsdoc/util/JSDocPackResources.java Fri Sep  2 01:26:46 2011
@@ -53,7 +53,7 @@ public class JSDocPackResources extends 
         }
         catch (URISyntaxException e)
         {
-            throw new IOException(e);
+            throw new IOException(e.getMessage());
         }
 
     }