Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Loubyansky committed Nov 13, 2024
1 parent 9d8d021 commit d4ea420
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ public DevModeCommandLineBuilder extensionDevModeJvmOptionFilter(
public DevModeCommandLine build() throws Exception {
JBossVersion.disableVersionLogging();

setJvmOptions();

//build a class-path string for the base platform
//this stuff does not change
// Do not include URIs in the manifest, because some JVMs do not like that
Expand Down Expand Up @@ -360,26 +358,46 @@ public DevModeCommandLine build() throws Exception {
devModeContext.setApplicationRoot(main);
devModeContext.getAdditionalModules().addAll(dependencies);

devModeContext.setBaseName(baseName);
devModeContext.setCacheDir(new File(buildDir, "transformer-cache").getAbsoluteFile());

if (entryPointCustomizer != null) {
entryPointCustomizer.accept(devModeContext);
}

// if the --enable-preview flag was set, then we need to enable it when launching dev mode as well
if (devModeContext.isEnablePreview()) {
System.out.println("ADDING enable-preview");
jvmOptionsBuilder.add("enable-preview");
}

setJvmOptions();
args.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager");

File tempFile = new File(buildDir, applicationName + "-dev.jar");
outputDir.mkdirs();

args.add("-jar");
args.add(createDevJar(devModeContext).getAbsolutePath());
if (applicationArgs != null) {
args.addAll(Arrays.asList(CommandLineUtil.translateCommandline(applicationArgs)));
}

return new DevModeCommandLine(args, actualDebugPort, buildFiles);
}

private File createDevJar(DevModeContext devModeContext) throws IOException {

final File tempFile = new File(buildDir, applicationName + "-dev.jar");
tempFile.delete();
// Only delete the -dev.jar on exit if requested
if (deleteDevJar) {
tempFile.deleteOnExit();
}
log.debugf("Executable jar: %s", tempFile.getAbsolutePath());

devModeContext.setBaseName(baseName);
devModeContext.setCacheDir(new File(buildDir, "transformer-cache").getAbsoluteFile());

// this is the jar file we will use to launch the dev mode main class
devModeContext.setDevModeRunnerJarFile(tempFile);

if (entryPointCustomizer != null) {
entryPointCustomizer.accept(devModeContext);
}

try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(tempFile))) {
out.putNextEntry(new ZipEntry("META-INF/"));
Manifest manifest = new Manifest();
Expand All @@ -403,20 +421,7 @@ public DevModeCommandLine build() throws Exception {
obj.close();
out.write(bytes.toByteArray());
}

outputDir.mkdirs();
// if the --enable-preview flag was set, then we need to enable it when launching dev mode as well
if (devModeContext.isEnablePreview()) {
args.add(DevModeContext.ENABLE_PREVIEW_FLAG);
}

args.add("-jar");
args.add(tempFile.getAbsolutePath());
if (applicationArgs != null) {
args.addAll(Arrays.asList(CommandLineUtil.translateCommandline(applicationArgs)));
}

return new DevModeCommandLine(args, actualDebugPort, buildFiles);
return tempFile;
}

private void setJvmOptions() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class DevModeContext implements Serializable {

public static final CompilationUnit EMPTY_COMPILATION_UNIT = new CompilationUnit(PathList.of(), null, null, null, null);

public static final String ENABLE_PREVIEW_FLAG = "--enable-preview";
private static final String ENABLE_PREVIEW_FLAG = "--enable-preview";

private ModuleInfo applicationRoot;
private final List<ModuleInfo> additionalModules = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@ protected QuarkusDevModeLauncher() {
protected void prepare() throws Exception {
JBossVersion.disableVersionLogging();

setJvmOptions();

if (suspend != null) {
switch (suspend.toLowerCase(Locale.ENGLISH)) {
case "n":
Expand Down Expand Up @@ -545,9 +543,11 @@ protected void prepare() throws Exception {
outputDir.mkdirs();
// if the --enable-preview flag was set, then we need to enable it when launching dev mode as well
if (devModeContext.isEnablePreview()) {
args.add(DevModeContext.ENABLE_PREVIEW_FLAG);
jvmOptionsBuilder.add("enable-preview");
}

setJvmOptions();

args.add("-jar");
args.add(tempFile.getAbsolutePath());
if (applicationArgs != null) {
Expand Down

0 comments on commit d4ea420

Please sign in to comment.