public void run() { try { executor = new DaemonExecutor(); resultHandler = new DefaultExecuteResultHandler(); String javaHome = System.getProperty("java.home"); String userDir = System.getProperty("user.dir"); executor.setStreamHandler(new PumpStreamHandler(System.out)); watchdog = new ExecuteWatchdog(15000); executor.setWatchdog(watchdog); executor.execute(new CommandLine(javaHome + SystemUtils.FILE_SEPARATOR + "bin"+ SystemUtils.FILE_SEPARATOR+"java.exe").addArgument("-version")); executor.execute(new CommandLine(javaHome + SystemUtils.FILE_SEPARATOR + "bin"+ SystemUtils.FILE_SEPARATOR+"java.exe") .addArgument("-jar") .addArgument(userDir + "/../moneta-springboot/target/moneta-springboot-" + ContractTestSuite.getProjectVersion() + ".jar")); } catch (Exception e) { e.printStackTrace(); } }
@Override protected final void executeGoal() throws MojoExecutionException { init(); LOG.info("command={}", command); LOG.info("arguments={}", Arrays.toString(arguments)); final CommandLine cmdLine = createCommandLine(); final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); final DaemonExecutor executor = new DaemonExecutor(); try { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final PumpStreamHandler psh = new PumpStreamHandler(bos); executor.setStreamHandler(psh); executor.setWorkingDirectory(getEventStoreDir()); executor.execute(cmdLine, resultHandler); final List<String> messages = waitForHttpServer(resultHandler, bos); logDebug(messages); final String pid = extractPid(messages); LOG.info("Event store process ID: {}", pid); writePid(pid); } catch (final IOException ex) { throw new MojoExecutionException( "Error executing the command line: " + cmdLine, ex); } }