com.google.code.maven_replacer_plugin.include.FileSelector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of replacer Show documentation
Show all versions of replacer Show documentation
Maven plugin to replace tokens in a given file with a value
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[] {});
}
}