Package org.apache.maven.plugin.coreit

Source Code of org.apache.maven.plugin.coreit.RunnableMojo

package org.apache.maven.plugin.coreit;

import bsh.EvalError;
import bsh.Interpreter;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

/**
* @goal runnable
* @requiresDependencyResolution test
*/
public class RunnableMojo
    extends AbstractMojo
{
    /**
     * @parameter
     * @required
     */
    private String script;

    public void execute() throws MojoExecutionException
    {
        Interpreter terp = new Interpreter();

        try
        {
            getLog().info( "Executing in java version: " + System.getProperty( "java.version" ) );
           
            Object result = terp.eval( script );

            getLog().info( "Result of script evaluation was: " + result + "\nLoaded from: " + result.getClass().getClassLoader() );
        }
        catch ( EvalError e )
        {
            throw new MojoExecutionException( "Failed to evaluate script.", e );
        }
    }
}
TOP

Related Classes of org.apache.maven.plugin.coreit.RunnableMojo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.