Added more logging
This commit is contained in:
parent
af828201ce
commit
9260fa5068
3 changed files with 29 additions and 14 deletions
|
@ -42,6 +42,7 @@ import java.util.spi.ToolProvider;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
||||||
extends AbstractOperation<AbstractBootOperation<T>> {
|
extends AbstractOperation<AbstractBootOperation<T>> {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(AbstractBootOperation.class.getName());
|
||||||
private final List<File> infLibs_ = new ArrayList<>();
|
private final List<File> infLibs_ = new ArrayList<>();
|
||||||
private final List<File> launcherLibs_ = new ArrayList<>();
|
private final List<File> launcherLibs_ = new ArrayList<>();
|
||||||
private final List<BootManifestAttribute> manifestAttributes_ = new ArrayList<>();
|
private final List<BootManifestAttribute> manifestAttributes_ = new ArrayList<>();
|
||||||
|
@ -119,9 +120,13 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
||||||
} else {
|
} else {
|
||||||
var meta_inf_dir = new File(stagingDirectory, "META-INF");
|
var meta_inf_dir = new File(stagingDirectory, "META-INF");
|
||||||
for (var jar : launcherLibs()) {
|
for (var jar : launcherLibs()) {
|
||||||
FileUtils.unzipFile(jar, stagingDirectory);
|
if (jar.exists()) {
|
||||||
if (meta_inf_dir.exists()) {
|
FileUtils.unzipFile(jar, stagingDirectory);
|
||||||
FileUtils.deleteDirectory(meta_inf_dir);
|
if (meta_inf_dir.exists()) {
|
||||||
|
FileUtils.deleteDirectory(meta_inf_dir);
|
||||||
|
}
|
||||||
|
} else if (LOGGER.isLoggable(Level.WARNING)) {
|
||||||
|
LOGGER.warning("ERROR: file not found: " + jar.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,6 +144,8 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
||||||
for (var dir : sourceDirectories()) {
|
for (var dir : sourceDirectories()) {
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
FileUtils.copyDirectory(dir, inf_classes_dir);
|
FileUtils.copyDirectory(dir, inf_classes_dir);
|
||||||
|
} else if (LOGGER.isLoggable(Level.WARNING)) {
|
||||||
|
LOGGER.warning("ERROR: directory not found: " + dir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +162,11 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
||||||
mkDirs(inf_lib_dir);
|
mkDirs(inf_lib_dir);
|
||||||
|
|
||||||
for (var jar : infLibs_) {
|
for (var jar : infLibs_) {
|
||||||
Files.copy(jar.toPath(), inf_lib_dir.toPath().resolve(jar.getName()));
|
if (jar.exists()) {
|
||||||
|
Files.copy(jar.toPath(), inf_lib_dir.toPath().resolve(jar.getName()));
|
||||||
|
} else if (LOGGER.isLoggable(Level.WARNING)) {
|
||||||
|
LOGGER.warning("ERROR: file not found: " + jar.getAbsolutePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,17 +174,16 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
||||||
* Part of the {@link #execute} operation, create the archive from the staging directory.
|
* Part of the {@link #execute} operation, create the archive from the staging directory.
|
||||||
*
|
*
|
||||||
* @param stagingDirectory the staging directory
|
* @param stagingDirectory the staging directory
|
||||||
* @param logger the logger instance
|
|
||||||
*/
|
*/
|
||||||
protected void executeCreateArchive(File stagingDirectory, Logger logger)
|
protected void executeCreateArchive(File stagingDirectory)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
executeCreateManifest(stagingDirectory);
|
executeCreateManifest(stagingDirectory);
|
||||||
if (logger.isLoggable(Level.FINE) && (!silent())) {
|
if (LOGGER.isLoggable(Level.FINE) && (!silent())) {
|
||||||
logger.fine(MessageFormat.format("Staging Directory: {0} (exists:{1})", stagingDirectory,
|
LOGGER.fine(MessageFormat.format("Staging Directory: {0} (exists:{1})", stagingDirectory,
|
||||||
stagingDirectory.exists()));
|
stagingDirectory.exists()));
|
||||||
logger.fine(MessageFormat.format("Destination Directory: {0} (exists:{1})", destinationDirectory(),
|
LOGGER.fine(MessageFormat.format("Destination Directory: {0} (exists:{1})", destinationDirectory(),
|
||||||
destinationDirectory().exists()));
|
destinationDirectory().exists()));
|
||||||
logger.fine(MessageFormat.format("Destination Archive: {0}", destinationFileName()));
|
LOGGER.fine(MessageFormat.format("Destination Archive: {0}", destinationFileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
var out = new StringWriter();
|
var out = new StringWriter();
|
||||||
|
@ -183,7 +193,7 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
||||||
var jarTool = ToolProvider.findFirst("jar").orElseThrow();
|
var jarTool = ToolProvider.findFirst("jar").orElseThrow();
|
||||||
|
|
||||||
String args;
|
String args;
|
||||||
if (logger.isLoggable(Level.FINER)) {
|
if (LOGGER.isLoggable(Level.FINER)) {
|
||||||
args = "-0cMvf";
|
args = "-0cMvf";
|
||||||
} else {
|
} else {
|
||||||
args = "-0cMf";
|
args = "-0cMf";
|
||||||
|
@ -198,8 +208,8 @@ public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>>
|
||||||
throw new IOException(errBuff.toString());
|
throw new IOException(errBuff.toString());
|
||||||
} else {
|
} else {
|
||||||
var outBuff = out.getBuffer();
|
var outBuff = out.getBuffer();
|
||||||
if (!outBuff.isEmpty() && logger.isLoggable(Level.INFO) && !silent()) {
|
if (!outBuff.isEmpty() && LOGGER.isLoggable(Level.INFO) && !silent()) {
|
||||||
logger.info(outBuff.toString());
|
LOGGER.info(outBuff.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class BootJarOperation extends AbstractBootOperation<BootJarOperation> {
|
||||||
executeCopyInfLibs(boot_inf_dir);
|
executeCopyInfLibs(boot_inf_dir);
|
||||||
executeCopyBootLoader(staging_dir);
|
executeCopyBootLoader(staging_dir);
|
||||||
|
|
||||||
executeCreateArchive(staging_dir, LOGGER);
|
executeCreateArchive(staging_dir);
|
||||||
|
|
||||||
if (!silent() && LOGGER.isLoggable(Level.INFO)) {
|
if (!silent() && LOGGER.isLoggable(Level.INFO)) {
|
||||||
LOGGER.info(String.format("The executable JAR (%s) was created in: %s%n", destinationFileName(),
|
LOGGER.info(String.format("The executable JAR (%s) was created in: %s%n", destinationFileName(),
|
||||||
|
|
|
@ -76,6 +76,11 @@ public class BootWarOperation extends AbstractBootOperation<BootWarOperation> {
|
||||||
|
|
||||||
for (var jar : providedLibs_) {
|
for (var jar : providedLibs_) {
|
||||||
Files.copy(jar.toPath(), boot_inf_lib_dir.toPath().resolve(jar.getName()));
|
Files.copy(jar.toPath(), boot_inf_lib_dir.toPath().resolve(jar.getName()));
|
||||||
|
if (jar.exists()) {
|
||||||
|
Files.copy(jar.toPath(), lib_provided_dir.toPath().resolve(jar.getName()));
|
||||||
|
} else if (LOGGER.isLoggable(Level.WARNING)) {
|
||||||
|
LOGGER.warning("ERROR: file not found: " + jar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue