Search in sources :

Example 6 with JavaExecutable

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

the class WarCommandIT method warCreation.

@Test
public void warCreation() throws Exception {
    int port = SocketUtils.findAvailableTcpPort();
    File war = new File("target/test-app.war");
    Invocation invocation = this.cli.invoke("war", war.getAbsolutePath(), "war.groovy");
    invocation.await();
    assertThat(war.exists()).isTrue();
    Process process = new JavaExecutable().processBuilder("-jar", war.getAbsolutePath(), "--server.port=" + port).start();
    invocation = new Invocation(process);
    invocation.await();
    assertThat(invocation.getOutput()).contains("onStart error");
    assertThat(invocation.getOutput()).contains("Tomcat started");
    assertThat(invocation.getOutput()).contains("/WEB-INF/lib-provided/tomcat-embed-core");
    assertThat(invocation.getOutput()).contains("WEB-INF/classes!/root.properties");
    process.destroy();
}
Also used : Invocation(org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation) File(java.io.File) JavaExecutable(org.springframework.boot.loader.tools.JavaExecutable) Test(org.junit.Test)

Example 7 with JavaExecutable

use of org.springframework.boot.loader.tools.JavaExecutable 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

JavaExecutable (org.springframework.boot.loader.tools.JavaExecutable)7 File (java.io.File)5 Test (org.junit.Test)5 Invocation (org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 RunProcess (org.springframework.boot.loader.tools.RunProcess)2 FileFilter (java.io.FileFilter)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ConnectException (java.net.ConnectException)1 ReflectionException (javax.management.ReflectionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1