Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/java/org/apache/maven/plugins/clean/Cleaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Deque;
import java.util.EnumSet;
Expand Down Expand Up @@ -105,8 +106,12 @@ final class Cleaner implements FileVisitor<Path> {
@Nonnull
private final String fastMode;

/**
* Combination of includes and excludes path matchers.
* A {@code null} value means to include everything.
*/
@Nullable
private Selector selector;
private PathSelector selector;

/**
* Whether the base directory is excluded from the set of directories to delete.
Expand Down Expand Up @@ -205,7 +210,11 @@ final class Cleaner implements FileVisitor<Path> {
* @throws IOException if a file/directory could not be deleted and {@code failOnError} is {@code true}
*/
public void delete(@Nonnull Fileset fileset) throws IOException {
selector = new Selector(fileset);
selector = new PathSelector(
fileset.getDirectory(),
Arrays.asList(fileset.getIncludes()),
Arrays.asList(fileset.getExcludes()),
fileset.isUseDefaultExcludes());
if (selector.isEmpty()) {
selector = null;
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/apache/maven/plugins/clean/Fileset.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public class Fileset {

private boolean useDefaultExcludes;

/**
* Creates an initially empty file set.
*/
public Fileset() {}

/**
* {@return the base directory}.
*/
Expand Down Expand Up @@ -96,7 +101,7 @@ public boolean isUseDefaultExcludes() {
* Appends the elements of the given array in the given buffer.
* This is a helper method for {@link #toString()} implementations.
*
* @param buffer the buffer where to add the elements
* @param buffer the buffer to add the elements to
* @param label label identifying the array of elements to add
* @param patterns the elements to append, or {@code null} if none
*/
Expand Down
Loading
Loading