Search in sources :

Example 6 with FileSetManager

use of org.apache.maven.shared.model.fileset.util.FileSetManager in project maven-dependency-plugin by apache.

the class DependencyTestUtils method removeDirectory.

/**
 * Deletes a directory and its contents.
 *
 * @param dir {@link File} The base directory of the included and excluded files.
 * @throws IOException in case of an error. When a directory failed to get deleted.
 */
public static void removeDirectory(File dir) throws IOException {
    if (dir != null) {
        Log log = new SilentLog();
        FileSetManager fileSetManager = new FileSetManager(log, false);
        FileSet fs = new FileSet();
        fs.setDirectory(dir.getPath());
        fs.addInclude("**/**");
        fileSetManager.delete(fs);
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) Log(org.apache.maven.plugin.logging.Log) SilentLog(org.apache.maven.plugin.testing.SilentLog) SilentLog(org.apache.maven.plugin.testing.SilentLog) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 7 with FileSetManager

use of org.apache.maven.shared.model.fileset.util.FileSetManager in project maven-scm by apache.

the class AbstractScmMojo method handleExcludesIncludesAfterCheckoutAndExport.

protected void handleExcludesIncludesAfterCheckoutAndExport(File checkoutDirectory) throws MojoExecutionException {
    List<String> includes = new ArrayList<String>();
    if (!StringUtils.isBlank(this.getIncludes())) {
        String[] tokens = StringUtils.split(this.getIncludes(), ",");
        for (int i = 0; i < tokens.length; ++i) {
            includes.add(tokens[i]);
        }
    }
    List<String> excludes = new ArrayList<String>();
    if (!StringUtils.isBlank(this.getExcludes())) {
        String[] tokens = StringUtils.split(this.getExcludes(), ",");
        for (int i = 0; i < tokens.length; ++i) {
            excludes.add(tokens[i]);
        }
    }
    if (includes.isEmpty() && excludes.isEmpty()) {
        return;
    }
    FileSetManager fileSetManager = new FileSetManager();
    FileSet fileset = new FileSet();
    fileset.setDirectory(checkoutDirectory.getAbsolutePath());
    // revert the order to do the delete
    fileset.setIncludes(excludes);
    fileset.setExcludes(includes);
    fileset.setUseDefaultExcludes(false);
    try {
        fileSetManager.delete(fileset);
    } catch (IOException e) {
        throw new MojoExecutionException("Error found while cleaning up output directory base on " + "excludes/includes configurations.", e);
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) ScmFileSet(org.apache.maven.scm.ScmFileSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 8 with FileSetManager

use of org.apache.maven.shared.model.fileset.util.FileSetManager in project maven-plugins by apache.

the class DependencyTestUtils method removeDirectory.

/**
 * Deletes a directory and its contents.
 *
 * @param dir {@link File} The base directory of the included and excluded files.
 * @throws IOException in case of an error. When a directory failed to get deleted.
 */
public static void removeDirectory(File dir) throws IOException {
    if (dir != null) {
        Log log = new SilentLog();
        FileSetManager fileSetManager = new FileSetManager(log, false);
        FileSet fs = new FileSet();
        fs.setDirectory(dir.getPath());
        fs.addInclude("**/**");
        fileSetManager.delete(fs);
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) Log(org.apache.maven.plugin.logging.Log) SilentLog(org.apache.maven.plugin.testing.SilentLog) SilentLog(org.apache.maven.plugin.testing.SilentLog) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 9 with FileSetManager

use of org.apache.maven.shared.model.fileset.util.FileSetManager in project spf4j by zolyfarkas.

the class SchemaCompileMojo method getSourceFiles.

public String[] getSourceFiles(final String pattern) {
    FileSetManager fsm = new FileSetManager();
    FileSet fs = new FileSet();
    fs.setDirectory(sourceDirectory.getAbsolutePath());
    fs.addInclude(pattern);
    fs.setFollowSymlinks(false);
    return fsm.getIncludedFiles(fs);
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 10 with FileSetManager

use of org.apache.maven.shared.model.fileset.util.FileSetManager in project spf4j by zolyfarkas.

the class SchemaCompileMojo method getFiles.

public static String[] getFiles(final File directory, final String pattern) {
    FileSetManager fsm = new FileSetManager();
    FileSet fs = new FileSet();
    fs.setDirectory(directory.getAbsolutePath());
    fs.addInclude(pattern);
    fs.setFollowSymlinks(false);
    return fsm.getIncludedFiles(fs);
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Aggregations

FileSetManager (org.apache.maven.shared.model.fileset.util.FileSetManager)10 FileSet (org.apache.maven.shared.model.fileset.FileSet)9 IOException (java.io.IOException)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 File (java.io.File)3 Log (org.apache.maven.plugin.logging.Log)2 SilentLog (org.apache.maven.plugin.testing.SilentLog)2 ArrayList (java.util.ArrayList)1 PropertyClassGenerator (net.jangaroo.properties.PropertyClassGenerator)1 PropcException (net.jangaroo.properties.api.PropcException)1 FileLocations (net.jangaroo.utils.FileLocations)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1