// Path: gmaven-plugin/src/main/java/org/codehaus/gmaven/plugin/CompilerMojoSupport.java
// public abstract class CompilerMojoSupport
//     extends ComponentMojoSupport
// {
//     /**
//      * Additional artifacts to add to the classpath (in addition to the classpath
//      * which is picked up from the executing poms configuration).
//      *
//      * @parameter
//      */
//     protected ArtifactItem[] classpath;
// 
//     /**
//      * Source files to be included.  If not specified, then the default will be used.
//      *
//      * @parameter
//      */
//     protected FileSet[] sources;
// 
//     /**
//      * Source files to be included.  If not specified, then the default will be used.
//      *
//      * @parameter
//      */
//     protected FileSet[] testSources;
// 
//     /**
//      * @component
//      *
//      * @noinspection UnusedDeclaration
//      */
//     protected CompileState compileState;
// 
//     protected CompilerMojoSupport(final String key) {
//         super(key);
//     }
// 
//     //
//     // Support
//     //
// 
//     protected abstract File getOutputDirectory() throws Exception;
// 
//     protected abstract List getSourceRoots();
// 
//     protected void addSourceRoot(final File dir) throws IOException {
//         assert dir != null;
// 
//         List roots = getSourceRoots();
//         assert roots != null;
// 
//         String path = dir.getCanonicalPath();
// 
//         if (!roots.contains(path)) {
//             log.debug("Adding source root: {}", path);
// 
//             roots.add(path);
//         }
//     }
// 
//     protected abstract FileSet[] getDefaultSources();
// 
//     protected ArtifactItem[] getUserClassspathElements() {
//         return classpath;
//     }
// 
//     //
//     // File Scanning
//     //
// 
//     protected Set getIncludesFrom(final FileSet fileSet) {
//         assert fileSet != null;
// 
//         List list = fileSet.getIncludes();
// 
//         if (list != null) {
//             return new HashSet(list);
//         }
// 
//         return Collections.singleton("**/*");
//     }
// 
//     protected Set getExcludesFrom(final FileSet fileSet) {
//         assert fileSet != null;
// 
//         List list = fileSet.getExcludes();
// 
//         if (list != null) {
//             return new HashSet(list);
//         }
// 
//         return Collections.EMPTY_SET;
//     }
// 
//     protected File[] scanForSources(final FileSet fileSet, final SourceMapping[] mappings) throws Exception {
//         assert fileSet != null;
// 
//         File sourceDir = new File(fileSet.getDirectory());
//         log.debug("Scanning for sources in: {}", sourceDir);
// 
//         if (!sourceDir.exists()) {
//             log.debug("Skipping; missing source directory: {}", sourceDir);
// 
//             return new File[0];
//         }
// 
//         File targetDir = getOutputDirectory();
//         Set includes = getIncludesFrom(fileSet);
//         Set excludes = getExcludesFrom(fileSet);
// 
//         StaleResourceScanner scanner = new StaleResourceScanner(0, includes, excludes);
// 
//         if (mappings != null && mappings.length > 0) {
//             for (int i=0; i<mappings.length; i++) {
//                 scanner.addSourceMapping(mappings[i]);
//             }
//         }
// 
//         Set files = scanner.getIncludedSources(sourceDir, targetDir);
// 
//         return (File[]) files.toArray(new File[files.size()]);
//     }
// 
//     protected File[] scanForSources(final FileSet fileSet, final SourceMapping mapping) throws Exception {
//         assert mapping != null;
// 
//         return scanForSources(fileSet, new SourceMapping[] { mapping }); 
//     }
// 
//     protected abstract FileSet[] getSources();
// 
// }
// 
// Path: gmaven-runtime/gmaven-runtime-api/src/main/java/org/codehaus/gmaven/runtime/StubCompiler.java
// public interface StubCompiler
//     extends org.codehaus.gmaven.runtime.util.Compiler, Component
// {
//     String KEY = StubCompiler.class.getName();
// 
//     interface Keys
//     {
//         String SOURCE_ENCODING = "sourceEncoding";
//     }
// 
//     // Add one off bits here to render/generate
// }


import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.shared.io.scan.mapping.SourceMapping;
import org.apache.maven.shared.io.scan.mapping.SuffixMapping;
import org.apache.maven.shared.model.fileset.FileSet;
import org.codehaus.gmaven.feature.Component;
import org.codehaus.gmaven.plugin.CompilerMojoSupport;
import org.codehaus.gmaven.runtime.StubCompiler;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
     * added to the code that creates the stubs, but as that code is sprinkled 
     * across several different runtimes, I am putting this into the common area.
     */
    private void resetStubModifiedDates() throws Exception {
        List stubs = recurseFiles(getOutputDirectory());

        for (Iterator i = stubs.iterator(); i.hasNext();) {
            File file = (File) i.next();
            file.setLastModified(0L);
        }
    }

    /**
     * Get all files, recursively, in a folder.
     * TODO: Should be moved into a utility class.
     *
     * @param folder The folder to look in.
     * @return A list of <code>File</code> instances.
     */
    private List recurseFiles(final File folder) {
        assert folder != null;

        List result = new ArrayList();
        File[] files = folder.listFiles();

        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    result.addAll(recurseFiles(files[i]));
                }
// Path: gmaven-plugin/src/main/java/org/codehaus/gmaven/plugin/CompilerMojoSupport.java
// public abstract class CompilerMojoSupport
//     extends ComponentMojoSupport
// {
//     /**
//      * Additional artifacts to add to the classpath (in addition to the classpath
//      * which is picked up from the executing poms configuration).
//      *
//      * @parameter
//      */
//     protected ArtifactItem[] classpath;
// 
//     /**
//      * Source files to be included.  If not specified, then the default will be used.
//      *
//      * @parameter
//      */
//     protected FileSet[] sources;
// 
//     /**
//      * Source files to be included.  If not specified, then the default will be used.
//      *
//      * @parameter
//      */
//     protected FileSet[] testSources;
// 
//     /**
//      * @component
//      *
//      * @noinspection UnusedDeclaration
//      */
//     protected CompileState compileState;
// 
//     protected CompilerMojoSupport(final String key) {
//         super(key);
//     }
// 
//     //
//     // Support
//     //
// 
//     protected abstract File getOutputDirectory() throws Exception;
// 
//     protected abstract List getSourceRoots();
// 
//     protected void addSourceRoot(final File dir) throws IOException {
//         assert dir != null;
// 
//         List roots = getSourceRoots();
//         assert roots != null;
// 
//         String path = dir.getCanonicalPath();
// 
//         if (!roots.contains(path)) {
//             log.debug("Adding source root: {}", path);
// 
//             roots.add(path);
//         }
//     }
// 
//     protected abstract FileSet[] getDefaultSources();
// 
//     protected ArtifactItem[] getUserClassspathElements() {
//         return classpath;
//     }
// 
//     //
//     // File Scanning
//     //
// 
//     protected Set getIncludesFrom(final FileSet fileSet) {
//         assert fileSet != null;
// 
//         List list = fileSet.getIncludes();
// 
//         if (list != null) {
//             return new HashSet(list);
//         }
// 
//         return Collections.singleton("**/*");
//     }
// 
//     protected Set getExcludesFrom(final FileSet fileSet) {
//         assert fileSet != null;
// 
//         List list = fileSet.getExcludes();
// 
//         if (list != null) {
//             return new HashSet(list);
//         }
// 
//         return Collections.EMPTY_SET;
//     }
// 
//     protected File[] scanForSources(final FileSet fileSet, final SourceMapping[] mappings) throws Exception {
//         assert fileSet != null;
// 
//         File sourceDir = new File(fileSet.getDirectory());
//         log.debug("Scanning for sources in: {}", sourceDir);
// 
//         if (!sourceDir.exists()) {
//             log.debug("Skipping; missing source directory: {}", sourceDir);
// 
//             return new File[0];
//         }
// 
//         File targetDir = getOutputDirectory();
//         Set includes = getIncludesFrom(fileSet);
//         Set excludes = getExcludesFrom(fileSet);
// 
//         StaleResourceScanner scanner = new StaleResourceScanner(0, includes, excludes);
// 
//         if (mappings != null && mappings.length > 0) {
//             for (int i=0; i<mappings.length; i++) {
//                 scanner.addSourceMapping(mappings[i]);
//             }
//         }
// 
//         Set files = scanner.getIncludedSources(sourceDir, targetDir);
// 
//         return (File[]) files.toArray(new File[files.size()]);
//     }
// 
//     protected File[] scanForSources(final FileSet fileSet, final SourceMapping mapping) throws Exception {
//         assert mapping != null;
// 
//         return scanForSources(fileSet, new SourceMapping[] { mapping }); 
//     }
// 
//     protected abstract FileSet[] getSources();
// 
// }
// 
// Path: gmaven-runtime/gmaven-runtime-api/src/main/java/org/codehaus/gmaven/runtime/StubCompiler.java
// public interface StubCompiler
//     extends org.codehaus.gmaven.runtime.util.Compiler, Component
// {
//     String KEY = StubCompiler.class.getName();
// 
//     interface Keys
//     {
//         String SOURCE_ENCODING = "sourceEncoding";
//     }
// 
//     // Add one off bits here to render/generate
// }


// Path: gmaven-plugin/src/main/java/org/codehaus/gmaven/plugin/stubgen/AbstractGenerateStubsMojo.java
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.shared.io.scan.mapping.SourceMapping;
import org.apache.maven.shared.io.scan.mapping.SuffixMapping;
import org.apache.maven.shared.model.fileset.FileSet;
import org.codehaus.gmaven.feature.Component;
import org.codehaus.gmaven.plugin.CompilerMojoSupport;
import org.codehaus.gmaven.runtime.StubCompiler;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

     * added to the code that creates the stubs, but as that code is sprinkled 
     * across several different runtimes, I am putting this into the common area.
     */
    private void resetStubModifiedDates() throws Exception {
        List stubs = recurseFiles(getOutputDirectory());

        for (Iterator i = stubs.iterator(); i.hasNext();) {
            File file = (File) i.next();
            file.setLastModified(0L);
        }
    }

    /**
     * Get all files, recursively, in a folder.
     * TODO: Should be moved into a utility class.
     *
     * @param folder The folder to look in.
     * @return A list of <code>File</code> instances.
     */
    private List recurseFiles(final File folder) {
        assert folder != null;

        List result = new ArrayList();
        File[] files = folder.listFiles();

        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    result.addAll(recurseFiles(files[i]));
                }
                else {