diff --git a/src/bld/java/rife/bld/extension/ArchiveBuild.java b/src/bld/java/rife/bld/extension/ArchiveBuild.java index b3decaf..5b88a50 100644 --- a/src/bld/java/rife/bld/extension/ArchiveBuild.java +++ b/src/bld/java/rife/bld/extension/ArchiveBuild.java @@ -29,10 +29,10 @@ public ArchiveBuild() { repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES); scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(2,0,1))) - .include(dependency("org.apache.commons", "commons-compress", version(1,26,2))); + .include(dependency("org.apache.commons", "commons-compress", version(1,27,1))); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,10,3))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,10,3))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,0))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,0))); javadocOperation() .javadocOptions() diff --git a/src/main/java/rife/bld/extension/ZipOperation.java b/src/main/java/rife/bld/extension/ZipOperation.java index b06d79a..5578d10 100644 --- a/src/main/java/rife/bld/extension/ZipOperation.java +++ b/src/main/java/rife/bld/extension/ZipOperation.java @@ -7,15 +7,20 @@ import org.apache.commons.compress.archivers.zip.UnixStat; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; -import org.apache.commons.compress.utils.IOUtils; +import org.apache.commons.io.IOUtils; import rife.bld.NamedFile; import rife.bld.operations.AbstractOperation; import rife.tools.FileUtils; import rife.tools.StringUtils; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; -import java.util.*; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.regex.Pattern; /** @@ -135,11 +140,35 @@ protected void executeAddFileToZip(ZipArchiveOutputStream zip, NamedFile file) * * @param directories source directories * @return this operation instance + * @see #sourceDirectories(List) * @since 1.0 */ public ZipOperation sourceDirectories(File... directories) { - sourceDirectories_.addAll(List.of(directories)); - return this; + return sourceDirectories(List.of(directories)); + } + + /** + * Provides source directories that will be used for the zip archive creation. + * + * @param directories source directories + * @return this operation instance + * @see #sourceDirectoriesPaths(List) + * @since 1.0 + */ + public ZipOperation sourceDirectories(Path... directories) { + return sourceDirectoriesPaths(List.of(directories)); + } + + /** + * Provides source directories that will be used for the zip archive creation. + * + * @param directories source directories + * @return this operation instance + * @see #sourceDirectoriesStrings(List) + * @since 1.0 + */ + public ZipOperation sourceDirectories(String... directories) { + return sourceDirectoriesStrings(List.of(directories)); } /** @@ -149,6 +178,7 @@ public ZipOperation sourceDirectories(File... directories) { * * @param directories a list of source directories * @return this operation instance + * @see #sourceDirectories(File...) * @since 1.0 */ public ZipOperation sourceDirectories(List directories) { @@ -156,6 +186,34 @@ public ZipOperation sourceDirectories(List directories) { return this; } + /** + * Provides a list of source directories that will be used for the zip archive creation. + *

+ * A copy will be created to allow this list to be independently modifiable. + * + * @param directories a list of source directories + * @return this operation instance + * @see #sourceDirectories(Path...) + * @since 1.0 + */ + public ZipOperation sourceDirectoriesPaths(List directories) { + return sourceDirectories(directories.stream().map(Path::toFile).toList()); + } + + /** + * Provides a list of source directories that will be used for the zip archive creation. + *

+ * A copy will be created to allow this list to be independently modifiable. + * + * @param directories a list of source directories + * @return this operation instance + * @see #sourceDirectories(String...) + * @since 1.0 + */ + public ZipOperation sourceDirectoriesStrings(List directories) { + return sourceDirectories(directories.stream().map(File::new).toList()); + } + /** * Provides source files that will be used for the zip archive creation. * @@ -194,6 +252,28 @@ public ZipOperation destinationDirectory(File directory) { return this; } + /** + * Provides the destination directory in which the zip archive will be created. + * + * @param directory the zip destination directory + * @return this operation instance + * @since 1.0 + */ + public ZipOperation destinationDirectory(Path directory) { + return destinationDirectory(directory.toFile()); + } + + /** + * Provides the destination directory in which the zip archive will be created. + * + * @param directory the zip destination directory + * @return this operation instance + * @since 1.0 + */ + public ZipOperation destinationDirectory(String directory) { + return destinationDirectory(new File(directory)); + } + /** * Provides the destination file name that will be used for the zip archive creation. *