in src/main/java/org/apache/netbeans/nbpackage/AbstractPackagerTask.java [102:164]
public final Path createImage(Path input) throws Exception {
String imageName = calculateImageName(input);
Path image = context.destination().resolve(imageName);
Files.createDirectory(image);
Path appDir = calculateAppPath(image);
Files.createDirectories(appDir);
if (Files.isDirectory(input)) {
copyAppFromDirectory(input, appDir);
} else if (Files.isRegularFile(input)) {
extractAppFromArchive(input, appDir);
} else {
throw new IllegalArgumentException(input.toString());
}
Path runtime = context.getValue(NBPackage.PACKAGE_RUNTIME)
.map(Path::toAbsolutePath)
.orElse(null);
if (runtime != null) {
Path runtimeDir = calculateRuntimePath(image, appDir);
Files.createDirectories(runtimeDir);
if (Files.isDirectory(runtime)) {
copyRuntimeFromDirectory(runtime, runtimeDir);
} else if (Files.isRegularFile(runtime)) {
extractRuntimeFromArchive(runtime, runtimeDir);
} else {
throw new IllegalArgumentException(runtime.toString());
}
if (runtimeDir.startsWith(appDir)) {
String jdkhome = appDir.relativize(runtimeDir).toString();
try (var confs = Files.newDirectoryStream(appDir.resolve("etc"), "*.conf")) {
for (Path conf : confs) {
addRuntimeToConf(conf, jdkhome);
}
}
}
}
customizeImage(image);
String filterPattern = context.getValue(NBPackage.PACKAGE_REMOVE).orElse(null);
if (filterPattern != null) {
removeFromImage(image, filterPattern);
}
Path mergeSource = context.getValue(NBPackage.PACKAGE_MERGE)
.map(Path::toAbsolutePath)
.orElse(null);
if (mergeSource != null) {
Path rootDir = calculateRootPath(image);
if (Files.isDirectory(mergeSource)) {
processMergeFromDirectory(mergeSource, image, rootDir);
} else if (Files.isRegularFile(mergeSource)) {
processMergeFromArchive(mergeSource, image, rootDir);
} else {
throw new IllegalArgumentException(mergeSource.toString());
}
}
finalizeImage(image);
return image;
}