public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        if ( isSkip() )
        {
            getLog().info( "skipping execute as per configuration" );
            return;
        }
        if ( killAfter != -1 )
        {
            getLog().warn( "Warning: killAfter is now deprecated. Do you need it ? Please comment on MEXEC-6." );
        }

        if ( null == arguments )
        {
            arguments = new String[0];
        }

        if ( getLog().isDebugEnabled() )
        {
            StringBuffer msg = new StringBuffer( "Invoking : " );
            msg.append( mainClass );
            msg.append( ".main(" );
            for ( int i = 0; i < arguments.length; i++ )
            {
                if ( i > 0 )
                {
                    msg.append( ", " );
                }
                msg.append( arguments[i] );
            }
            msg.append( ")" );
            getLog().debug( msg );
        }

        IsolatedThreadGroup threadGroup = new IsolatedThreadGroup( mainClass /* name */ );
        Thread bootstrapThread = new Thread( threadGroup, new Runnable()
        {
            public void run()
            {
                int sepIndex = mainClass.indexOf( '/' );

                final String bootClassName;
                if ( sepIndex >= 0 )
                {
                    bootClassName = mainClass.substring( sepIndex + 1 );
                }
                else 
                {
                    bootClassName = mainClass;
                }
                
                try
                {
                    Class<?> bootClass = Thread.currentThread().getContextClassLoader().loadClass( bootClassName );
                    
                    MethodHandles.Lookup lookup = MethodHandles.lookup();

                    MethodHandle mainHandle =
                        lookup.findStatic( bootClass, "main",
                                                 MethodType.methodType( void.class, String[].class ) );
                    
                    mainHandle.invoke( arguments );
                }
                catch ( IllegalAccessException e )
                { // just pass it on
                    Thread.currentThread().getThreadGroup().uncaughtException( Thread.currentThread(),
                                                                               new Exception( "The specified mainClass doesn't contain a main method with appropriate signature.",
                                                                                              e ) );
                }
                catch ( InvocationTargetException e )
                { // use the cause if available to improve the plugin execution output
                   Throwable exceptionToReport = e.getCause() != null ? e.getCause() : e;
                   Thread.currentThread().getThreadGroup().uncaughtException( Thread.currentThread(), exceptionToReport );
                }
                catch ( Throwable e )
                { // just pass it on
                    Thread.currentThread().getThreadGroup().uncaughtException( Thread.currentThread(), e );
                }
            }
        }, mainClass + ".main()" );
        bootstrapThread.setContextClassLoader( getClassLoader() );
        setSystemProperties();

        bootstrapThread.start();
        joinNonDaemonThreads( threadGroup );
        // It's plausible that spontaneously a non-daemon thread might be created as we try and shut down,
        // but it's too late since the termination condition (only daemon threads) has been triggered.
        if ( keepAlive )
        {
            getLog().warn( "Warning: keepAlive is now deprecated and obsolete. Do you need it? Please comment on MEXEC-6." );
            waitFor( 0 );
        }

        if ( cleanupDaemonThreads )
        {

            terminateThreads( threadGroup );

            try
            {
                threadGroup.destroy();
            }
            catch ( IllegalThreadStateException e )
            {
                getLog().warn( "Couldn't destroy threadgroup " + threadGroup, e );
            }
        }

        if ( originalSystemProperties != null )
        {
            System.setProperties( originalSystemProperties );
        }

        synchronized ( threadGroup )
        {
            if ( threadGroup.uncaughtException != null )
            {
                throw new MojoExecutionException( "An exception occured while executing the Java class. "
                    + threadGroup.uncaughtException.getMessage(), threadGroup.uncaughtException );
            }
        }

        registerSourceRoots();
    }
public void execute()
        throws MojoExecutionException, MojoFailureException
    {
        if ( isSkip() )
        {
            getLog().info( "skipping execute as per configuration" );
            return;
        }
        if ( killAfter != -1 )
        {
            getLog().warn( "Warning: killAfter is now deprecated. Do you need it ? Please comment on MEXEC-6." );
        }

        if ( null == arguments )
        {
            arguments = new String[0];
        }

        if ( getLog().isDebugEnabled() )
        {
            StringBuffer msg = new StringBuffer( "Invoking : " );
            msg.append( mainClass );
            msg.append( ".main(" );
            for ( int i = 0; i < arguments.length; i++ )
            {
                if ( i > 0 )
                {
                    msg.append( ", " );
                }
                msg.append( arguments[i] );
            }
            msg.append( ")" );
            getLog().debug( msg );
        }

        IsolatedThreadGroup threadGroup = new IsolatedThreadGroup( mainClass  );
        Thread bootstrapThread = new Thread( threadGroup, new Runnable()
        {
            public void run()
            {
                int sepIndex = mainClass.indexOf( '/' );

                final String bootClassName;
                if ( sepIndex >= 0 )
                {
                    bootClassName = mainClass.substring( sepIndex + 1 );
                }
                else 
                {
                    bootClassName = mainClass;
                }
                
                try
                {
                    Class<?> bootClass = Thread.currentThread().getContextClassLoader().loadClass( bootClassName );
                    
                    MethodHandles.Lookup lookup = MethodHandles.lookup();

                    MethodHandle mainHandle =
                        lookup.findStatic( bootClass, "main",
                                                 MethodType.methodType( void.class, String[].class ) );
                    
                    mainHandle.invoke( arguments );
                }
                catch ( IllegalAccessException e )
                { 
                    Thread.currentThread().getThreadGroup().uncaughtException( Thread.currentThread(),
                                                                               new Exception( "The specified mainClass doesn't contain a main method with appropriate signature.",
                                                                                              e ) );
                }
                catch ( InvocationTargetException e )
                { 
                   Throwable exceptionToReport = e.getCause() != null ? e.getCause() : e;
                   Thread.currentThread().getThreadGroup().uncaughtException( Thread.currentThread(), exceptionToReport );
                }
                catch ( Throwable e )
                { 
                    Thread.currentThread().getThreadGroup().uncaughtException( Thread.currentThread(), e );
                }
            }
        }, mainClass + ".main()" );
        bootstrapThread.setContextClassLoader( getClassLoader() );
        setSystemProperties();

        bootstrapThread.start();
        joinNonDaemonThreads( threadGroup );
        
        
        if ( keepAlive )
        {
            getLog().warn( "Warning: keepAlive is now deprecated and obsolete. Do you need it? Please comment on MEXEC-6." );
            waitFor( 0 );
        }

        if ( cleanupDaemonThreads )
        {

            terminateThreads( threadGroup );

            try
            {
                threadGroup.destroy();
            }
            catch ( IllegalThreadStateException e )
            {
                getLog().warn( "Couldn't destroy threadgroup " + threadGroup, e );
            }
        }

        if ( originalSystemProperties != null )
        {
            System.setProperties( originalSystemProperties );
        }

        synchronized ( threadGroup )
        {
            if ( threadGroup.uncaughtException != null )
            {
                throw new MojoExecutionException( "An exception occured while executing the Java class. "
                    + threadGroup.uncaughtException.getMessage(), threadGroup.uncaughtException );
            }
        }

        registerSourceRoots();
    }
public void execute ( ) throws MojoExecutionException , MojoFailureException { if ( isSkip ( ) ) { getLog ( ) . info ( "skipping execute as per configuration" ) ; return ; } if ( killAfter != - 1 ) { getLog ( ) . warn ( "Warning: killAfter is now deprecated. Do you need it ? Please comment on MEXEC-6." ) ; } if ( null == arguments ) { arguments = new String [ 0 ] ; } if ( getLog ( ) . isDebugEnabled ( ) ) { StringBuffer msg = new StringBuffer ( "Invoking : " ) ; msg . append ( mainClass ) ; msg . append ( ".main(" ) ; for ( int i = 0 ; i < arguments . length ; i ++ ) { if ( i > 0 ) { msg . append ( ", " ) ; } msg . append ( arguments [ i ] ) ; } msg . append ( ")" ) ; getLog ( ) . debug ( msg ) ; } IsolatedThreadGroup threadGroup = new IsolatedThreadGroup ( mainClass /* name */ ) ; Thread bootstrapThread = new Thread ( threadGroup , new Runnable ( ) { public void run ( ) { int sepIndex = mainClass . indexOf ( ' ' ) ; final String bootClassName ; if ( sepIndex >= 0 ) { bootClassName = mainClass . substring ( sepIndex + 1 ) ; } else { bootClassName = mainClass ; } try { Class < ? > bootClass = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( bootClassName ) ; MethodHandles . Lookup lookup = MethodHandles . lookup ( ) ; MethodHandle mainHandle = lookup . findStatic ( bootClass , "main" , MethodType . methodType ( void . class , String [ ] . class ) ) ; mainHandle . invoke ( arguments ) ; } catch ( IllegalAccessException e ) { // just pass it on Thread . currentThread ( ) . getThreadGroup ( ) . uncaughtException ( Thread . currentThread ( ) , new Exception ( "The specified mainClass doesn't contain a main method with appropriate signature." , e ) ) ; } catch ( InvocationTargetException e ) { // use the cause if available to improve the plugin execution output Throwable exceptionToReport = e . getCause ( ) != null ? e . getCause ( ) : e ; Thread . currentThread ( ) . getThreadGroup ( ) . uncaughtException ( Thread . currentThread ( ) , exceptionToReport ) ; } catch ( Throwable e ) { // just pass it on Thread . currentThread ( ) . getThreadGroup ( ) . uncaughtException ( Thread . currentThread ( ) , e ) ; } } } , mainClass + ".main()" ) ; bootstrapThread . setContextClassLoader ( getClassLoader ( ) ) ; setSystemProperties ( ) ; bootstrapThread . start ( ) ; joinNonDaemonThreads ( threadGroup ) ; // It's plausible that spontaneously a non-daemon thread might be created as we try and shut down, // but it's too late since the termination condition (only daemon threads) has been triggered. if ( keepAlive ) { getLog ( ) . warn ( "Warning: keepAlive is now deprecated and obsolete. Do you need it? Please comment on MEXEC-6." ) ; waitFor ( 0 ) ; } if ( cleanupDaemonThreads ) { terminateThreads ( threadGroup ) ; try { threadGroup . destroy ( ) ; } catch ( IllegalThreadStateException e ) { getLog ( ) . warn ( "Couldn't destroy threadgroup " + threadGroup , e ) ; } } if ( originalSystemProperties != null ) { System . setProperties ( originalSystemProperties ) ; } synchronized ( threadGroup ) { if ( threadGroup . uncaughtException != null ) { throw new MojoExecutionException ( "An exception occured while executing the Java class. " + threadGroup . uncaughtException . getMessage ( ) , threadGroup . uncaughtException ) ; } } registerSourceRoots ( ) ; }
Execute goal.

@throws MojoExecutionException execution of the main class or one of the threads it generated failed.
@throws MojoFailureException something bad happened...
Execute goal .