public void execute(AbstractWisdomMojo mojo, boolean interactive, int debug, String jvmArgs,
                        ProcessDestroyer destroyer) throws MojoExecutionException {
        // Get java
        File java = ExecUtils.find("java", new File(mojo.javaHome, "bin"));
        if (java == null) {
            throw new MojoExecutionException("Cannot find the java executable");
        }

        CommandLine cmdLine = new CommandLine(java);

        if (debug != 0) {
            cmdLine.addArgument(
                    "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + debug,
                    false);
        }

        if (!Strings.isNullOrEmpty(jvmArgs)) {
            cmdLine.addArguments(jvmArgs, false);
        }

        cmdLine.addArgument("-jar");
        cmdLine.addArgument("bin/chameleon-core-" + CHAMELEON_VERSION + ".jar");
        if (interactive) {
            cmdLine.addArgument("--interactive");
        }

        appendSystemPropertiesToCommandLine(mojo, cmdLine);

        DefaultExecutor executor = new DefaultExecutor();
        if (destroyer != null) {
            executor.setProcessDestroyer(destroyer);
        } else {
            executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
        }

        executor.setWorkingDirectory(mojo.getWisdomRootDirectory());
        if (interactive) {
            executor.setStreamHandler(new PumpStreamHandler(System.out, System.err, System.in)); //NOSONAR
            // Using the interactive mode the framework should be stopped using the 'exit' command,
            // and produce a '0' status.
            executor.setExitValue(0);
        } else {
            executor.setStreamHandler(new PumpStreamHandler(System.out, System.err)); // NOSONAR
            // As the execution is intended to be interrupted using CTRL+C, the status code returned is expected to be 1
            // 137 or 143 is used when stopped by the destroyer.
            executor.setExitValues(new int[]{1, 137, 143});
        }
        try {
            mojo.getLog().info("Launching Wisdom Server");
            mojo.getLog().debug("Command Line: " + cmdLine.toString());
            // The message is different whether or not we are in the interactive mode.
            if (interactive) {
                mojo.getLog().info("You are in interactive mode");
                mojo.getLog().info("Hit 'exit' to shutdown");
            } else {
                mojo.getLog().info("Hit CTRL+C to exit");
            }
            if (debug != 0) {
                mojo.getLog().info("Wisdom launched with remote debugger interface enabled on port " + debug);
            }
            // Block execution until ctrl+c
            executor.execute(cmdLine);
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot execute Wisdom", e);
        }
    }
public void execute ( AbstractWisdomMojo mojo , boolean interactive , int debug , String jvmArgs , ProcessDestroyer destroyer ) throws MojoExecutionException { File java = ExecUtils . find ( "java" , new File ( mojo . javaHome , "bin" ) ) ; if ( java == null ) { throw new MojoExecutionException ( "Cannot find the java executable" ) ; } CommandLine cmdLine = new CommandLine ( java ) ; if ( debug != 0 ) { cmdLine . addArgument ( "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + debug , false ) ; } if ( ! Strings . isNullOrEmpty ( jvmArgs ) ) { cmdLine . addArguments ( jvmArgs , false ) ; } cmdLine . addArgument ( "-jar" ) ; cmdLine . addArgument ( "bin/chameleon-core-" + CHAMELEON_VERSION + ".jar" ) ; if ( interactive ) { cmdLine . addArgument ( "--interactive" ) ; } appendSystemPropertiesToCommandLine ( mojo , cmdLine ) ; DefaultExecutor executor = new DefaultExecutor ( ) ; if ( destroyer != null ) { executor . setProcessDestroyer ( destroyer ) ; } else { executor . setProcessDestroyer ( new ShutdownHookProcessDestroyer ( ) ) ; } executor . setWorkingDirectory ( mojo . getWisdomRootDirectory ( ) ) ; if ( interactive ) { executor . setStreamHandler ( new PumpStreamHandler ( System . out , System . err , System . in ) ) ; executor . setExitValue ( 0 ) ; } else { executor . setStreamHandler ( new PumpStreamHandler ( System . out , System . err ) ) ; executor . setExitValues ( new int [ ] { 1 , 137 , 143 } ) ; } try { mojo . getLog ( ) . info ( "Launching Wisdom Server" ) ; mojo . getLog ( ) . debug ( "Command Line: " + cmdLine . toString ( ) ) ; if ( interactive ) { mojo . getLog ( ) . info ( "You are in interactive mode" ) ; mojo . getLog ( ) . info ( "Hit 'exit' to shutdown" ) ; } else { mojo . getLog ( ) . info ( "Hit CTRL+C to exit" ) ; } if ( debug != 0 ) { mojo . getLog ( ) . info ( "Wisdom launched with remote debugger interface enabled on port " + debug ) ; } executor . execute ( cmdLine ) ; } catch ( IOException e ) { throw new MojoExecutionException ( "Cannot execute Wisdom" , e ) ; } }
Launches the Wisdom server. This method blocks until the wisdom server shuts down.
It uses the {@literal Java} executable directly.

@param mojo        the mojo
@param interactive enables the shell prompt
@param debug       the debug port (0 to disable it)
@param jvmArgs     JVM arguments to add to the `java` command (before the -jar argument).
@param destroyer   a process destroyer that can be used to destroy the process, if {@code null}
a {@link org.apache.commons.exec.ShutdownHookProcessDestroyer} is used.
@throws MojoExecutionException if the Wisdom instance cannot be started or has thrown an unexpected status
while being stopped.