Skip to content

Commit

Permalink
#311 - provide fluent setter for usingDefaultExcludes flag in Abstrac…
Browse files Browse the repository at this point in the history
…tFileSet.
  • Loading branch information
redzi authored and slachiewicz committed Nov 26, 2023
1 parent 9c0e021 commit fca25e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public T includeEmptyDirs(boolean includeEmptyDirectories) {
return (T) this;
}

@SuppressWarnings("unchecked")
public T usingDefaultExcludes(boolean usingDefaultExcludes) {
setUsingDefaultExcludes(usingDefaultExcludes);
return (T) this;
}

public void setStreamTransformer(@Nonnull InputStreamTransformer streamTransformer) {
this.streamTransformer = streamTransformer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ void testSymlinkArchivedFileSet() throws Exception {
final File tarFile2 = getTestFile("target/output/pasymlinks-archivedFileset.tar");
final TarArchiver tarArchiver = getPosixTarArchiver();
tarArchiver.setDestFile(tarFile2);
DefaultArchivedFileSet archivedFileSet = DefaultArchivedFileSet.archivedFileSet(tarFile);
archivedFileSet.setUsingDefaultExcludes(false);
DefaultArchivedFileSet archivedFileSet =
DefaultArchivedFileSet.archivedFileSet(tarFile).usingDefaultExcludes(false);
tarArchiver.addArchivedFileSet(archivedFileSet);
tarArchiver.createArchive();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ class DefaultFileSetTest {
void testCreate() {
final String[] includes = {"zz", "yy"};
final String[] exc = {"xx1", "xx2"};
final DefaultFileSet dfs =
fileSet(new File("foo")).prefixed("pfx").include(includes).exclude(exc);
final boolean usingDefaultExcludes = true;
final DefaultFileSet dfs = fileSet(new File("foo"))
.prefixed("pfx")
.include(includes)
.exclude(exc)
.usingDefaultExcludes(usingDefaultExcludes);
assertEquals("foo", dfs.getDirectory().getName());
assertEquals("pfx", dfs.getPrefix());
assertEquals("zz", dfs.getIncludes()[0]);
assertEquals("xx1", dfs.getExcludes()[0]);
assertEquals(usingDefaultExcludes, dfs.isUsingDefaultExcludes());
}
}

0 comments on commit fca25e5

Please sign in to comment.