Skip to content

Commit

Permalink
Remove the boot lib entirely
Browse files Browse the repository at this point in the history
All the resources from those jars
have now been moved to quarkus-run.jar
  • Loading branch information
geoand committed Sep 25, 2023
1 parent e9af6db commit afa3f94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -736,14 +736,25 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,

Path appInfo = buildDir.resolve(QuarkusEntryPoint.QUARKUS_APPLICATION_DAT);

// merge all the jars in boot into a single one
// the idea is to cut down on the memory needed to load them

List<Path> copiedBootJars = Files.list(bootLib)
.filter(p -> p.getFileName().toString().endsWith(".jar"))
.collect(Collectors.toList());
Path initJar = buildDir.resolve(QUARKUS_RUN_JAR);
if (!rebuild) {
try (FileSystem runnerZipFs = ZipUtils.newZip(initJar)) {
ResolvedDependency appArtifact = curateOutcomeBuildItem.getApplicationModel().getAppArtifact();
generateManifest(runnerZipFs,
"",
packageConfig, appArtifact,
QuarkusEntryPoint.class.getName(),
applicationInfo);
}
}

// merge all the jars in boot into a single one
// the idea is to cut down on the memory needed to load them

mergeBootJars(packageConfig, bootLib, copiedBootJars,
mergeBootJars(packageConfig, initJar, copiedBootJars,
parentFirstTargetPathToArtifact);

try (OutputStream out = Files.newOutputStream(appInfo)) {
Expand Down Expand Up @@ -773,14 +784,10 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
throw new UncheckedIOException(e);
}
});

StringBuilder classPath = new StringBuilder(LIB + "/" + BOOT_LIB + "/" + MERGED_BOOT_LIB + ".jar");
Files.list(bootLib).filter(p -> !p.getFileName().toString().contains(MERGED_BOOT_LIB)).forEach(p -> {
classPath.append(" " + LIB + "/" + BOOT_LIB + "/" + p.getFileName().toString());
});
Files.delete(bootLib);

runnerJar.toFile().setReadable(true, false);
Path initJar = buildDir.resolve(QUARKUS_RUN_JAR);

boolean mutableJar = packageConfig.type.equalsIgnoreCase(PackageConfig.BuiltInType.MUTABLE_JAR.getValue());
if (mutableJar) {
//we output the properties in a reproducible manner, so we remove the date comment
Expand All @@ -797,14 +804,6 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
}
}
if (!rebuild) {
try (FileSystem runnerZipFs = ZipUtils.newZip(initJar)) {
ResolvedDependency appArtifact = curateOutcomeBuildItem.getApplicationModel().getAppArtifact();
generateManifest(runnerZipFs,
classPath.toString(),
packageConfig, appArtifact,
QuarkusEntryPoint.class.getName(),
applicationInfo);
}

//now copy the deployment artifacts, if required
if (mutableJar) {
Expand Down Expand Up @@ -879,7 +878,7 @@ public void accept(Path path) {
}

private void mergeBootJars(PackageConfig packageConfig,
Path bootLib, List<Path> copiedBootJars,
Path initJar, List<Path> copiedBootJars,
Map<Path, Dependency> parentFirstTargetPathToArtifact) throws IOException {
final Map<String, String> seen = new HashMap<>();
final Map<String, Set<Dependency>> duplicateCatcher = new HashMap<>();
Expand All @@ -894,8 +893,7 @@ public boolean test(String path) {
}
};

Path mergedBootLibJar = bootLib.resolve(MERGED_BOOT_LIB + ".jar");
try (FileSystem runnerZipFs = ZipUtils.newZip(mergedBootLibJar)) {
try (FileSystem runnerZipFs = ZipUtils.newFileSystem(initJar)) {
Path manifestPath = runnerZipFs.getPath("META-INF", "MANIFEST.MF");
Manifest manifest = new Manifest();
Files.createDirectories(manifestPath.getParent());
Expand Down Expand Up @@ -1372,7 +1370,9 @@ private void generateManifest(FileSystem runnerZipFs, final String classPath, Pa
log.warn(
"A CLASS_PATH entry was already defined in your MANIFEST.MF or using the property quarkus.package.manifest.attributes.\"Class-Path\". Quarkus has overwritten this existing entry.");
}
attributes.put(Attributes.Name.CLASS_PATH, classPath);
if (!((classPath == null) || classPath.isEmpty())) {
attributes.put(Attributes.Name.CLASS_PATH, classPath);
}
if (attributes.containsKey(Attributes.Name.MAIN_CLASS)) {
String existingMainClass = attributes.getValue(Attributes.Name.MAIN_CLASS);
if (!mainClassName.equals(existingMainClass)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private static void doRun(Object args) throws IOException, ClassNotFoundExceptio
InvocationTargetException, NoSuchMethodException {
String path = QuarkusEntryPoint.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8");
Path appRoot = new File(decodedPath).toPath().getParent().getParent().getParent();
Path appRoot = new File(decodedPath).toPath().getParent();

if (Boolean.parseBoolean(System.getenv("QUARKUS_LAUNCH_DEVMODE"))) {
DevModeMediator.doDevMode(appRoot);
Expand Down

0 comments on commit afa3f94

Please sign in to comment.