Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2013 Keegan Witt
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * You may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.codehaus.gmavenplus.mojo;
 
 
 import java.io.File;
 import java.util.*;


This mojo provides access to the Groovy sources.

Author(s):
Keegan Witt
 
 public abstract class AbstractGroovySourcesMojo extends AbstractGroovyMojo {
    
Main source directory name.
 
     public static final String MAIN = "main";
    
Test source directory name.
 
     public static final String TEST = "test";

    
The Groovy source files (relative paths). Default: "${project.basedir}/src/main/groovy/**/*.groovy"

Parameter:
 
     protected FileSet[] sources;

    
The Groovy test source files (relative paths). Default: "${project.basedir}/src/test/groovy/**/*.groovy"

Parameter:
 
     protected FileSet[] testSources;

    
Gets the filesets of the the main sources.

Parameters:
includeJavaSources Whether to include Java sources
Returns:
The filesets of the the main sources.
 
     protected FileSet[] getSourceRoots(final boolean includeJavaSources) {
         return getFilesets(includeJavaSources);
     }

    
Gets the filesets of the the main sources (not including Java sources).

Returns:
The filesets of the the main sources.
 
     protected FileSet[] getSourceRoots() {
         return getFilesets(false);
     }

    
Gets the set of files of the the main sources.

Parameters:
includeJavaSources Whether to include Java sources
Returns:
The set of files of the the main sources.
 
     protected Set<FilegetSources(final boolean includeJavaSources) {
         return getFiles(includeJavaSources);
     }

    
Gets the set of files of the the main sources (not including Java sources).

Returns:
The set of files of the the main sources.
 
     protected Set<FilegetSources() {
         return getFiles(false);
     }

    
Gets the filesets of the test sources.

Parameters:
includeJavaSources Whether to include Java sources
Returns:
The filesets of the test sources.
 
     protected FileSet[] getTestSourceRoots(final boolean includeJavaSources) {
         return getFilesets(includeJavaSources);
     }

    
Gets the filesets of the test sources (not including Java sources).

Returns:
The filesets of the test sources.
    protected FileSet[] getTestSourceRoots() {
        return getFilesets(false);
    }

    
Gets the set of files of the test sources.

Parameters:
includeJavaSources Whether to include Java sources
Returns:
The set of files of the test sources.
    protected Set<FilegetTestSources(final boolean includeJavaSources) {
        return getFiles(includeJavaSources);
    }

    
Gets the set of files of the test sources (not including Java sources).

Returns:
The set of files of the test sources.
    protected Set<FilegetTestSources() {
        return getFiles(false);
    }

    
Gets the set of included files from the specified source files or source directory (if sources are null).

Parameters:
fromSources The sources to get the included files from
defaultSourceDirectory The source directory to fall back on if sources are null
includeJavaSources Whether to include Java sources
Returns:
The included files from the specified sources
    protected Set<FilegetFiles(final FileSet[] fromSourcesfinal String defaultSourceDirectoryfinal boolean includeJavaSources) {
        Set<Filefiles = new HashSet<File>();
        FileSetManager fileSetManager = new FileSetManager(getLog());
        for (FileSet fileSet : getFilesets(fromSourcesdefaultSourceDirectoryincludeJavaSources)) {
            for (String include : Arrays.asList(fileSetManager.getIncludedFiles(fileSet))) {
                files.add(new File(fileSet.getDirectory(), include));
            }
        }
        return files;
    }

    
Gets the set of included filesets from the specified source files or source directory (if sources are null).

Parameters:
fromSources The sources to get the included files from
defaultSubDirectory The source subdirectory to fall back on if sources are null
includeJavaSources Whether to include Java sources
Returns:
The included filesets from the specified sources
    protected FileSet[] getFilesets(final FileSet[] fromSourcesfinal String defaultSubDirectoryboolean includeJavaSources) {
        FileSet[] result;
        FileSet[] groovyFileSets;
        if (fromSources != null) {
            groovyFileSets = fromSources;
        } else {
            FileSet groovyFileSet = new FileSet();
            String groovyDirectory = "src" + . + defaultSubDirectory + . + "groovy";
            groovyFileSet.setDirectory(.getBasedir() + . + groovyDirectory);
            groovyFileSet.setIncludes(Arrays.asList());
            groovyFileSets = new FileSet[] {groovyFileSet};
        }
        if (includeJavaSources) {
            List<FileSetjavaFileSets = new ArrayList<FileSet>();
            if (.equals(defaultSubDirectory)) {
                for (Object sourceRoot : .getTestCompileSourceRoots()) {
                    FileSet javaFileSet = new FileSet();
                    javaFileSet.setDirectory((StringsourceRoot);
                    javaFileSet.setIncludes(Arrays.asList());
                    javaFileSets.add(javaFileSet);
                }
            } else {
                for (Object sourceRoot : .getCompileSourceRoots()) {
                    FileSet javaFileSet = new FileSet();
                    javaFileSet.setDirectory((StringsourceRoot);
                    javaFileSet.setIncludes(Arrays.asList());
                    javaFileSets.add(javaFileSet);
                }
            }
            FileSet[] javaFileSetsArr = javaFileSets.toArray(new FileSet[javaFileSets.size()]);
            result = Arrays.copyOf(groovyFileSetsgroovyFileSets.length + javaFileSetsArr.length);
            System.arraycopy(javaFileSetsArr, 0, resultgroovyFileSets.lengthjavaFileSetsArr.length);
        } else {
            result = groovyFileSets;
        }
        return result;
    }

    
Sets the sources to specified.

Parameters:
newSources the sources to set
    public void setSources(final FileSet[] newSources) {
        this. = newSources;
    }

    
Sets the test sources to specified.

Parameters:
newTestSources the test sources to set
    public void setTestSources(final FileSet[] newTestSources) {
        this. = newTestSources;
    }
New to GrepCode? Check out our FAQ X