forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow quarkus:run to launch DevServices
Closes: quarkusio#40270
- Loading branch information
Showing
5 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ public void defaultJavaCommand(PackageConfig packageConfig, | |
List<String> args = new ArrayList<>(); | ||
args.add(determineJavaPath()); | ||
|
||
for (Map.Entry<?, ?> e : System.getProperties().entrySet()) { | ||
for (Map.Entry<?, ?> e : System.getProperties().entrySet()) { //TODO: this is almost certainly wrong as it pulls in all the system properties Maven has set | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
maxandersen
|
||
args.add("-D" + e.getKey().toString() + "=" + e.getValue().toString()); | ||
} | ||
args.add("-jar"); | ||
|
63 changes: 63 additions & 0 deletions
63
...loyment/src/main/java/io/quarkus/deployment/cmd/StartDevServicesAndRunCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package io.quarkus.deployment.cmd; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
import io.quarkus.builder.BuildResult; | ||
import io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem; | ||
|
||
public class StartDevServicesAndRunCommandHandler implements BiConsumer<Object, BuildResult> { | ||
|
||
@Override | ||
public void accept(Object o, BuildResult buildResult) { | ||
var runCommandActionResult = buildResult.consume(RunCommandActionResultBuildItem.class); | ||
var devServicesLauncherConfigResult = buildResult.consume(DevServicesLauncherConfigResultBuildItem.class); | ||
|
||
// FYI: AugmentAction.performCustomBuild runs in its own classloader | ||
// so we can only pass back instances of those classes in the system classloader | ||
|
||
Consumer<Map<String, List>> consumer = (Consumer<Map<String, List>>) o; | ||
|
||
// build up the commands | ||
Map<String, List> cmds = new HashMap<>(); | ||
for (RunCommandActionBuildItem item : runCommandActionResult.getCommands()) { | ||
List<String> itemList = new ArrayList<>(); | ||
addLaunchCommand(itemList, item, devServicesLauncherConfigResult.getConfig()); | ||
cmds.put(item.getCommandName(), itemList); | ||
} | ||
|
||
consumer.accept(cmds); | ||
} | ||
|
||
private void addLaunchCommand(List list, RunCommandActionBuildItem item, Map<String, String> devServicesProperties) { | ||
List<String> effectiveArgs; | ||
List<String> originalArgs = item.getArgs(); | ||
if (devServicesProperties.isEmpty()) { | ||
effectiveArgs = originalArgs; | ||
} else { | ||
effectiveArgs = new ArrayList<>(originalArgs.size() + devServicesProperties.size()); | ||
int jarArgIndex = 0; | ||
for (int i = 0; i < originalArgs.size(); i++) { | ||
if (originalArgs.get(i).trim().equals("-jar")) { | ||
jarArgIndex = i; | ||
break; | ||
} | ||
} | ||
effectiveArgs.addAll(originalArgs.subList(0, jarArgIndex)); | ||
for (var devServiceConfigEntry : devServicesProperties.entrySet()) { | ||
effectiveArgs.add("-D" + devServiceConfigEntry.getKey() + "=" + devServiceConfigEntry.getValue()); | ||
} | ||
effectiveArgs.addAll(originalArgs.subList(jarArgIndex, originalArgs.size())); | ||
} | ||
|
||
list.add(effectiveArgs); | ||
list.add(item.getWorkingDirectory()); | ||
list.add(item.getStartedExpression()); | ||
list.add(item.isNeedsLogfile()); | ||
list.add(item.getLogFile()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
does this not also overrides java.*/user.home keys which would not be the right ones to have set if the JVM to run mvn vs exec is different?