in plugins/maven/src/main/java/org/wildfly/swarm/plugin/maven/StartMojo.java [86:180]
public void executeSpecific() throws MojoExecutionException, MojoFailureException {
initProperties(true);
initEnvironment();
final SwarmExecutor executor;
if (useUberJar) {
executor = uberJarExecutor();
} else if (this.project.getPackaging().equals(WAR)) {
executor = warExecutor();
} else if (this.project.getPackaging().equals(JAR)) {
executor = jarExecutor();
} else {
throw new MojoExecutionException("Unsupported packaging: " + this.project.getPackaging());
}
executor.withJVMArguments(this.jvmArguments);
if (this.argumentsProp != null) {
StringTokenizer args = new StringTokenizer(this.argumentsProp);
while (args.hasMoreTokens()) {
this.arguments.add(args.nextToken());
}
}
executor.withArguments(this.arguments);
final SwarmProcess process;
try {
File tmp;
try {
tmp = Files.createTempFile("thorntail-process-file", null).toFile();
} catch (IOException e) {
throw new MojoFailureException("Error while creating process file");
}
process = executor.withDebug(debugPort)
.withProcessFile(tmp)
.withProperties(this.properties)
.withStdoutFile(this.stdoutFile != null ? this.stdoutFile.toPath() : null)
.withStderrFile(this.stderrFile != null ? this.stderrFile.toPath() : null)
.withEnvironment(this.environment)
.withWorkingDirectory(this.project.getBasedir().toPath())
.withProperty("remote.maven.repo",
String.join(",",
this.project.getRemoteProjectRepositories().stream()
.map(RemoteRepository::getUrl)
.collect(Collectors.toList())))
.execute();
int startTimeoutSeconds;
try {
startTimeoutSeconds = Integer.valueOf(this.properties.getProperty("start.timeout.seconds", "120"));
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Wrong format of the start timeout!. Integer expected.", nfe);
}
process.awaitReadiness(startTimeoutSeconds, TimeUnit.SECONDS);
if (!process.isAlive()) {
throw new MojoFailureException("Process failed to start");
}
if (process.getError() != null) {
throw new MojoFailureException("Error starting process", process.getError());
}
} catch (IOException e) {
throw new MojoFailureException("unable to execute", e);
} catch (InterruptedException e) {
throw new MojoFailureException("Error waiting for deployment", e);
}
List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("thorntail-process");
if (procs == null) {
procs = new ArrayList<>();
getPluginContext().put("thorntail-process", procs);
}
procs.add(process);
if (waitForProcess) {
try {
process.waitFor();
} catch (InterruptedException e) {
try {
process.stop(10, TimeUnit.SECONDS);
} catch (InterruptedException ie) {
// Do nothing
}
} finally {
process.destroyForcibly();
}
}
}