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

com.google.code.maven_replacer_plugin.include.FileSelector Maven / Gradle / Ivy

The newest version!
package com.google.code.maven_replacer_plugin.include;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.apache.tools.ant.DirectoryScanner;

public class FileSelector {

	public List listIncludes(String basedir, List includes, List excludes) {
		if (includes == null || includes.isEmpty()) {
			return Collections.emptyList();
		}

		DirectoryScanner directoryScanner = new DirectoryScanner();
		directoryScanner.addDefaultExcludes();
		directoryScanner.setBasedir(new File(basedir));
		directoryScanner.setIncludes(stringListToArray(includes));
		directoryScanner.setExcludes(stringListToArray(excludes));

		directoryScanner.scan();
		return Arrays.asList(directoryScanner.getIncludedFiles());
	}

	private String[] stringListToArray(List stringList) {
		if (stringList == null) {
			return null;
		}
		return stringList.toArray(new String[] {});
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy