diff --git a/README.md b/README.md index 22ce8ce..5eaebdb 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions). -To create a [Spring Boot executable Java Archive](https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html) -(JAR) from the current project: +To create a Spring Boot executable Java Archive (JAR) from the current project: ```java @@BuildCommand(summary = "Creates an executable JAR for the project") @@ -26,8 +25,7 @@ public void bootjar() throws Exception { ./bld compile bootjar ``` -To create a [Spring Boot executable Web Archive](https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#appendix.executable-jar.nested-jars.war-structure) -(WAR) from the current project: +To create a Spring Boot executable Web Archive (WAR) from the current project: ```java @BuildCommand(summary = "Create an executable WAR for the project") diff --git a/examples/src/bld/java/com/example/demo/DemoApplicationBuild.java b/examples/src/bld/java/com/example/demo/DemoApplicationBuild.java index b591297..fb06087 100644 --- a/examples/src/bld/java/com/example/demo/DemoApplicationBuild.java +++ b/examples/src/bld/java/com/example/demo/DemoApplicationBuild.java @@ -39,12 +39,11 @@ public class DemoApplicationBuild extends WebProject { } public static void main(String[] args) { - var level = Level.ALL; var logger = Logger.getLogger("rife.bld.extension"); ConsoleHandler consoleHandler = new ConsoleHandler(); - consoleHandler.setLevel(level); + consoleHandler.setLevel(Level.ALL); logger.addHandler(consoleHandler); - logger.setLevel(level); + logger.setLevel(Level.ALL); logger.setUseParentHandlers(false); new DemoApplicationBuild().start(args); diff --git a/src/main/java/rife/bld/extension/AbstractBootOperation.java b/src/main/java/rife/bld/extension/AbstractBootOperation.java index df4bb43..d486f4c 100644 --- a/src/main/java/rife/bld/extension/AbstractBootOperation.java +++ b/src/main/java/rife/bld/extension/AbstractBootOperation.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.nio.file.Files; -import java.text.DecimalFormat; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; @@ -58,7 +57,7 @@ public abstract class AbstractBootOperation> * * @param directory the directory to delete */ - public static void deleteDirectories(File... directory) throws FileUtilsErrorException { + public void deleteDirectories(File... directory) throws FileUtilsErrorException { for (var d : directory) { if (d.exists()) { FileUtils.deleteDirectory(d); @@ -66,34 +65,6 @@ public abstract class AbstractBootOperation> } } - /** - * Return the given file size in bytes, kilobytes, megabytes, gigabytes or terabytes. - * - * @param file the file - * @return the file size in B, KB, MB, GB, or TB. - */ - public static String fileSize(File file) { - var size = file.length(); - if (size <= 0) { - return "0 B"; - } - var units = new String[]{"B", "KB", "MB", "GB", "TB"}; - var digitGroups = (int) (Math.log10(size) / Math.log10(1024)); - return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) - + ' ' + units[digitGroups]; - } - - /** - * Makes a directory for the given path, including any necessary but nonexistent parent directories. - * - * @param path the directory path - */ - public static void mkDirs(File path) throws IOException { - if (!path.exists() && !path.mkdirs()) { - throw new IOException("ERROR: unable to create: " + path.getAbsolutePath()); - } - } - /** * Retrieves the destination directory in which the JAR will be created. * @@ -405,6 +376,17 @@ public abstract class AbstractBootOperation> return (T) this; } + /** + * Makes a directory for the given path, including any necessary but nonexistent parent directories. + * + * @param path the directory path + */ + protected void mkDirs(File path) throws IOException { + if (!path.exists() && !path.mkdirs()) { + throw new IOException("ERROR: unable to create: " + path.getAbsolutePath()); + } + } + /** * Provides source directories that will be used for the jar archive creation. * @@ -432,7 +414,6 @@ public abstract class AbstractBootOperation> * * @return {@code true} or an {@link IllegalArgumentException} */ - @SuppressWarnings("SameReturnValue") protected boolean verifyExecute() throws IllegalArgumentException { if (mainClass() == null) { throw new IllegalArgumentException("ERROR: project mainClass required."); diff --git a/src/main/java/rife/bld/extension/BootJarOperation.java b/src/main/java/rife/bld/extension/BootJarOperation.java index 72d6361..ae5aed7 100644 --- a/src/main/java/rife/bld/extension/BootJarOperation.java +++ b/src/main/java/rife/bld/extension/BootJarOperation.java @@ -53,8 +53,7 @@ public class BootJarOperation extends AbstractBootOperation { var archive = executeCreateArchive(staging_dir); if (!silent() && LOGGER.isLoggable(Level.INFO)) { - LOGGER.info(String.format("The executable JAR was created: %s (%s)", archive.getAbsolutePath(), - fileSize(archive))); + LOGGER.info("The executable JAR was created: " + archive.getAbsolutePath()); } } finally { FileUtils.deleteDirectory(staging_dir); diff --git a/src/main/java/rife/bld/extension/BootWarOperation.java b/src/main/java/rife/bld/extension/BootWarOperation.java index 2b05d0f..1a73de0 100644 --- a/src/main/java/rife/bld/extension/BootWarOperation.java +++ b/src/main/java/rife/bld/extension/BootWarOperation.java @@ -57,8 +57,7 @@ public class BootWarOperation extends AbstractBootOperation { var archive = executeCreateArchive(staging_dir); if (!silent() && LOGGER.isLoggable(Level.INFO)) { - LOGGER.info(String.format("The executable WAR was created: %s (%s)", archive.getAbsolutePath(), - fileSize(archive))); + LOGGER.info("The executable WAR was created: " + archive.getAbsolutePath()); } } finally { FileUtils.deleteDirectory(staging_dir);