-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish quarkus:run and integration tests
- Loading branch information
1 parent
c15c8a8
commit acb6963
Showing
8 changed files
with
168 additions
and
86 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
7 changes: 4 additions & 3 deletions
7
core/deployment/src/main/java/io/quarkus/deployment/run/RunCommandLauncherBuildItem.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
67 changes: 67 additions & 0 deletions
67
core/deployment/src/main/java/io/quarkus/deployment/run/RunCommandProcessor.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 |
---|---|---|
@@ -1,13 +1,80 @@ | ||
package io.quarkus.deployment.run; | ||
|
||
import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.DEFAULT_FAST_JAR_DIRECTORY_NAME; | ||
import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.QUARKUS_RUN_JAR; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.pkg.PackageConfig; | ||
import io.quarkus.deployment.pkg.builditem.LegacyJarRequiredBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.UberJarRequiredBuildItem; | ||
|
||
public class RunCommandProcessor { | ||
private static final String JAVA_HOME_SYS = "java.home"; | ||
private static final String JAVA_HOME_ENV = "JAVA_HOME"; | ||
|
||
@BuildStep | ||
public RunCommandLaunchResultBuildItem commands(List<RunCommandLauncherBuildItem> cmds) { | ||
return new RunCommandLaunchResultBuildItem(cmds); | ||
} | ||
|
||
@BuildStep | ||
public void defaultJavaCommand(PackageConfig packageConfig, | ||
OutputTargetBuildItem jar, | ||
List<UberJarRequiredBuildItem> uberJarRequired, | ||
List<LegacyJarRequiredBuildItem> legacyJarRequired, | ||
BuildProducer<RunCommandLauncherBuildItem> cmds) { | ||
|
||
Path jarPath = null; | ||
if (legacyJarRequired.isEmpty() && (!uberJarRequired.isEmpty() | ||
|| packageConfig.type.equalsIgnoreCase(PackageConfig.UBER_JAR))) { | ||
jarPath = jar.getOutputDirectory() | ||
.resolve(jar.getBaseName() + packageConfig.getRunnerSuffix() + ".jar"); | ||
} else if (!legacyJarRequired.isEmpty() || packageConfig.isLegacyJar() | ||
|| packageConfig.type.equalsIgnoreCase(PackageConfig.LEGACY)) { | ||
jarPath = jar.getOutputDirectory() | ||
.resolve(jar.getBaseName() + packageConfig.getRunnerSuffix() + ".jar"); | ||
} else { | ||
jarPath = jar.getOutputDirectory().resolve(DEFAULT_FAST_JAR_DIRECTORY_NAME).resolve(QUARKUS_RUN_JAR); | ||
|
||
} | ||
|
||
List<String> args = new ArrayList<>(); | ||
args.add(determineJavaPath()); | ||
|
||
for (Map.Entry e : System.getProperties().entrySet()) { | ||
args.add("-D" + e.getKey().toString() + "=" + e.getValue().toString()); | ||
} | ||
args.add("-jar"); | ||
args.add(jarPath.toAbsolutePath().toString()); | ||
cmds.produce(new RunCommandLauncherBuildItem("java", args, null, null, null, false)); | ||
} | ||
|
||
private String determineJavaPath() { | ||
// try system property first - it will be the JAVA_HOME used by the current JVM | ||
String home = System.getProperty(JAVA_HOME_SYS); | ||
if (home == null) { | ||
// No luck, somewhat a odd JVM not enforcing this property | ||
// try with the JAVA_HOME environment variable | ||
home = System.getenv(JAVA_HOME_ENV); | ||
} | ||
if (home != null) { | ||
File javaHome = new File(home); | ||
File file = new File(javaHome, "bin/java"); | ||
if (file.exists()) { | ||
return file.getAbsolutePath(); | ||
} | ||
} | ||
|
||
// just assume 'java' is on the system path | ||
return "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
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
Oops, something went wrong.