From fca25e56461394a6d34af8e018ec0348885cbad8 Mon Sep 17 00:00:00 2001 From: redzi Date: Tue, 21 Nov 2023 20:24:57 +0100 Subject: [PATCH] #311 - provide fluent setter for usingDefaultExcludes flag in AbstractFileSet. --- .../codehaus/plexus/archiver/util/AbstractFileSet.java | 6 ++++++ .../codehaus/plexus/archiver/tar/TarArchiverTest.java | 4 ++-- .../plexus/archiver/util/DefaultFileSetTest.java | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codehaus/plexus/archiver/util/AbstractFileSet.java b/src/main/java/org/codehaus/plexus/archiver/util/AbstractFileSet.java index 5c2cde548..fbf093b00 100644 --- a/src/main/java/org/codehaus/plexus/archiver/util/AbstractFileSet.java +++ b/src/main/java/org/codehaus/plexus/archiver/util/AbstractFileSet.java @@ -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; } diff --git a/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java b/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java index 2bbfbd06b..615cd41be 100644 --- a/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java @@ -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(); diff --git a/src/test/java/org/codehaus/plexus/archiver/util/DefaultFileSetTest.java b/src/test/java/org/codehaus/plexus/archiver/util/DefaultFileSetTest.java index 0f8750e68..702b0e18d 100644 --- a/src/test/java/org/codehaus/plexus/archiver/util/DefaultFileSetTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/util/DefaultFileSetTest.java @@ -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()); } }