use of org.apache.commons.io.filefilter.NotFileFilter in project maven-plugins by apache.
the class ScmPublishPublishScmMojo method update.
/**
* Update scm checkout directory with content.
*
* @param checkout the scm checkout directory
* @param dir the content to put in scm (can be <code>null</code>)
* @param doNotDeleteDirs directory names that should not be deleted from scm even if not in new content:
* used for modules, which content is available only when staging
* @throws IOException
*/
private void update(File checkout, File dir, List<String> doNotDeleteDirs) throws IOException {
String scmSpecificFilename = scmProvider.getScmSpecificFilename();
String[] files = scmSpecificFilename != null ? checkout.list(new NotFileFilter(new NameFileFilter(scmSpecificFilename))) : checkout.list();
Set<String> checkoutContent = new HashSet<String>(Arrays.asList(files));
List<String> dirContent = (dir != null) ? Arrays.asList(dir.list()) : Collections.<String>emptyList();
Set<String> deleted = new HashSet<String>(checkoutContent);
deleted.removeAll(dirContent);
MatchPatterns ignoreDeleteMatchPatterns = null;
List<String> pathsAsList = new ArrayList<String>(0);
if (ignorePathsToDelete != null && ignorePathsToDelete.length > 0) {
ignoreDeleteMatchPatterns = MatchPatterns.from(ignorePathsToDelete);
pathsAsList = Arrays.asList(ignorePathsToDelete);
}
for (String name : deleted) {
if (ignoreDeleteMatchPatterns != null && ignoreDeleteMatchPatterns.matches(name, true)) {
getLog().debug(name + " match one of the patterns '" + pathsAsList + "': do not add to deleted files");
continue;
}
getLog().debug("file marked for deletion: " + name);
File file = new File(checkout, name);
if ((doNotDeleteDirs != null) && file.isDirectory() && (doNotDeleteDirs.contains(name))) {
// ignore directory not available
continue;
}
if (file.isDirectory()) {
update(file, null, null);
}
this.deleted.add(file);
}
for (String name : dirContent) {
File file = new File(checkout, name);
File source = new File(dir, name);
if (source.isDirectory()) {
directories++;
if (!checkoutContent.contains(name)) {
this.added.add(file);
file.mkdir();
}
update(file, source, null);
} else {
if (checkoutContent.contains(name)) {
this.updated.add(file);
} else {
this.added.add(file);
}
copyFile(source, file);
}
}
}
use of org.apache.commons.io.filefilter.NotFileFilter in project symmetric-ds by JumpMind.
the class FileTrigger method createIOFileFilter.
public IOFileFilter createIOFileFilter() {
String[] includes = StringUtils.isNotBlank(includesFiles) ? includesFiles.split(",") : new String[] { "*" };
String[] excludes = StringUtils.isNotBlank(excludesFiles) ? excludesFiles.split(",") : null;
IOFileFilter filter = new WildcardFileFilter(includes);
if (excludes != null && excludes.length > 0) {
List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
fileFilters.add(filter);
fileFilters.add(new NotFileFilter(new WildcardFileFilter(excludes)));
filter = new AndFileFilter(fileFilters);
}
if (!recurse) {
List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
fileFilters.add(filter);
fileFilters.add(new NotFileFilter(FileFilterUtils.directoryFileFilter()));
filter = new AndFileFilter(fileFilters);
} else {
List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
fileFilters.add(filter);
fileFilters.add(FileFilterUtils.directoryFileFilter());
filter = new OrFileFilter(fileFilters);
}
return filter;
}
Aggregations