Search in sources :

Example 1 with DirectoryScanner

use of org.apache.maven.shared.utils.io.DirectoryScanner in project docker-maven-plugin by fabric8io.

the class MappingTrackArchiver method getAssemblyFiles.

/**
 * Get all files depicted by this assembly.
 *
 * @return assembled files
 */
public AssemblyFiles getAssemblyFiles(MavenSession session) {
    AssemblyFiles ret = new AssemblyFiles(new File(getDestFile().getParentFile(), assemblyName));
    // Where the 'real' files are copied to
    for (Addition addition : added) {
        Object resource = addition.resource;
        File target = new File(ret.getAssemblyDirectory(), addition.destination);
        if (resource instanceof File && addition.destination != null) {
            addFileEntry(ret, session, (File) resource, target);
        } else if (resource instanceof PlexusIoFileResource) {
            addFileEntry(ret, session, ((PlexusIoFileResource) resource).getFile(), target);
        } else if (resource instanceof FileSet) {
            FileSet fs = (FileSet) resource;
            DirectoryScanner ds = new DirectoryScanner();
            File base = addition.directory;
            ds.setBasedir(base);
            ds.setIncludes(fs.getIncludes());
            ds.setExcludes(fs.getExcludes());
            ds.setCaseSensitive(fs.isCaseSensitive());
            ds.scan();
            for (String f : ds.getIncludedFiles()) {
                File source = new File(base, f);
                File subTarget = new File(target, f);
                addFileEntry(ret, session, source, subTarget);
            }
        } else {
            throw new IllegalStateException("Unknown resource type " + resource.getClass() + ": " + resource);
        }
    }
    return ret;
}
Also used : PlexusIoFileResource(org.codehaus.plexus.components.io.resources.PlexusIoFileResource) FileSet(org.codehaus.plexus.archiver.FileSet) DirectoryScanner(org.apache.maven.shared.utils.io.DirectoryScanner)

Example 2 with DirectoryScanner

use of org.apache.maven.shared.utils.io.DirectoryScanner in project fabric8-maven-plugin by fabric8io.

the class AbstractAppServerHandler method scanFiles.

/**
 * Scan the project's output directory for certain files.
 *
 * @param patterns one or more patterns which fit to Maven's include syntax
 * @return list of files found
 */
protected String[] scanFiles(String... patterns) {
    String buildOutputDir = project.getBuild().getDirectory();
    if (buildOutputDir != null && new File(buildOutputDir).exists()) {
        DirectoryScanner directoryScanner = new DirectoryScanner();
        directoryScanner.setBasedir(buildOutputDir);
        directoryScanner.setIncludes(patterns);
        directoryScanner.scan();
        return directoryScanner.getIncludedFiles();
    } else {
        return new String[0];
    }
}
Also used : DirectoryScanner(org.apache.maven.shared.utils.io.DirectoryScanner) File(java.io.File)

Aggregations

DirectoryScanner (org.apache.maven.shared.utils.io.DirectoryScanner)2 File (java.io.File)1 FileSet (org.codehaus.plexus.archiver.FileSet)1 PlexusIoFileResource (org.codehaus.plexus.components.io.resources.PlexusIoFileResource)1