Search in sources :

Example 1 with RunProcess

use of org.springframework.boot.loader.tools.RunProcess in project spring-boot by spring-projects.

the class StartMojo method runProcess.

private RunProcess runProcess(File workingDirectory, List<String> args) throws MojoExecutionException {
    try {
        RunProcess runProcess = new RunProcess(workingDirectory, new JavaExecutable().toString());
        runProcess.run(false, args.toArray(new String[args.size()]));
        return runProcess;
    } catch (Exception ex) {
        throw new MojoExecutionException("Could not exec java", ex);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) RunProcess(org.springframework.boot.loader.tools.RunProcess) JavaExecutable(org.springframework.boot.loader.tools.JavaExecutable) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ConnectException(java.net.ConnectException) ReflectionException(javax.management.ReflectionException)

Example 2 with RunProcess

use of org.springframework.boot.loader.tools.RunProcess in project spring-boot by spring-projects.

the class RunProcessCommand method run.

protected ExitStatus run(Collection<String> args) throws IOException {
    this.process = new RunProcess(this.command);
    int code = this.process.run(true, args.toArray(new String[args.size()]));
    if (code == 0) {
        return ExitStatus.OK;
    } else {
        return new ExitStatus(code, "EXTERNAL_ERROR");
    }
}
Also used : ExitStatus(org.springframework.boot.cli.command.status.ExitStatus) RunProcess(org.springframework.boot.loader.tools.RunProcess)

Example 3 with RunProcess

use of org.springframework.boot.loader.tools.RunProcess in project spring-boot by spring-projects.

the class RunMojo method runWithForkedJvm.

@Override
protected void runWithForkedJvm(File workingDirectory, List<String> args) throws MojoExecutionException {
    try {
        RunProcess runProcess = new RunProcess(workingDirectory, new JavaExecutable().toString());
        Runtime.getRuntime().addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
        int exitCode = runProcess.run(true, args.toArray(new String[args.size()]));
        if (exitCode == 0 || exitCode == EXIT_CODE_SIGINT) {
            return;
        }
        throw new MojoExecutionException("Application finished with exit code: " + exitCode);
    } catch (Exception ex) {
        throw new MojoExecutionException("Could not exec java", ex);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) RunProcess(org.springframework.boot.loader.tools.RunProcess) JavaExecutable(org.springframework.boot.loader.tools.JavaExecutable) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Aggregations

RunProcess (org.springframework.boot.loader.tools.RunProcess)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 JavaExecutable (org.springframework.boot.loader.tools.JavaExecutable)2 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 ReflectionException (javax.management.ReflectionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 ExitStatus (org.springframework.boot.cli.command.status.ExitStatus)1