All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jayway.maven.plugins.android.common.FileRetriever Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
package com.jayway.maven.plugins.android.common;

import org.codehaus.plexus.util.DirectoryScanner;

import java.io.File;

/**
 * Retrieves the names of layout resource files.
 */
public final class FileRetriever
{
    private final String[] includes;

    /**
     * @param includes      Ant-style include statements, for example "** /*.aidl" (but without the space
     *                      in the middle).
     */
    public FileRetriever( String... includes )
    {
        this.includes = includes;
    }

    /**
     * Finds the files in the supplied folder that match the configured includes.
     *
     * @param baseDirectory Directory to find files in.
     * @return String[] of the files' paths and names, relative to baseDirectory. Empty
     *         String[] if baseDirectory does not exist.
     */
    public String[] getFileNames( File baseDirectory )
    {
        if ( !baseDirectory.exists() )
        {
            return new String[ 0 ];
        }

        final DirectoryScanner directoryScanner = new DirectoryScanner();
        directoryScanner.setBasedir( baseDirectory );
        directoryScanner.setIncludes( includes );
        directoryScanner.addDefaultExcludes();
        directoryScanner.scan();

        return directoryScanner.getIncludedFiles();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy