Package groovy.lang

Examples of groovy.lang.GroovyShell


        String message = writer.toString();
        throw new BuildException("Script Failed: " + message, e, getLocation());
    }

    public static void main(String[] args) {
        final GroovyShell shell = new GroovyShell(new Binding());
        final Groovy groovy = new Groovy();
        for (int i = 1; i < args.length; i++) {
            final Commandline.Argument argument = groovy.createArg();
            argument.setValue(args[i]);
        }
View Full Code Here


  public abstract Object executeCommand(List args);

  @SuppressWarnings({ "rawtypes", "unchecked" })
  protected void resolveVariables(List arg) {
    List temp = new ArrayList();
    GroovyShell gs = new GroovyShell(getBinding());
    for(Object obj:arg) {
      Script scr = gs.parse("\""+(String)obj+"\"");
      try {
        temp.add(scr.run().toString());
      }
      catch(MissingPropertyException e) {
        throw new SqoopException(ShellError.SHELL_0004, e.getMessage(), e);
View Full Code Here

        assertEquals("extends MockObjectTestCase", classProps[Inspector.CLASS_SUPERCLASS_IDX]);
        assertEquals("is Primitive: false, is Array: false, is Groovy: false", classProps[Inspector.CLASS_OTHER_IDX]);
    }

    public void testClassPropsGroovy() {
        Object testObject = new GroovyShell().evaluate("class Test {def meth1(a,b){}}\nreturn new Test()");
        Inspector insp = new Inspector(testObject);
        String[] classProps = insp.getClassProps();
        assertEquals("package n/a", classProps[Inspector.CLASS_PACKAGE_IDX]);
        assertEquals("public class Test", classProps[Inspector.CLASS_CLASS_IDX]);
        assertEquals("implements GroovyObject ", classProps[Inspector.CLASS_INTERFACE_IDX]);
View Full Code Here

     * Asserts that the script runs without any exceptions
     *
     * @param script the script that should pass without any exception thrown
     */
    protected void assertScript(final String script) throws Exception {
        GroovyShell shell = new GroovyShell();
        shell.evaluate(script, getTestClassName());
    }
View Full Code Here

*/
public class SeansBug extends TestSupport {

    public void testBug() throws Exception {
        String code = "for (i in 1..10) \n{\n  println(i)\n}";
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }
View Full Code Here

                        "    elem1('hello1') ",
                        "    elem2('hello2') ",
                        "    elem3(x:7) ",
                        "}"};
        String code = asCode(lines);
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }
View Full Code Here

* @version $Revision: 21496 $
*/
public class MainTest extends TestSupport {

    public void testMainMethod() throws Exception {
        GroovyShell shell = new GroovyShell();
        shell.run(new File("src/test/groovy/SampleMain.groovy"), new String[]{"A", "B", "C"});
    }
View Full Code Here

            p.put("openejb.localcopy", copy);
        }
        try {
            InitialContext ctx = new InitialContext(p);

            GroovyShell shell = new GroovyShell();
            shell.setVariable("context", ctx);
            //shell.evaluate("src/test/groovy/j2ee/CreateData.groovy");

            //shell.evaluate("src/main/groovy/ui/Console.groovy");
            GroovyObject console = (GroovyObject) InvokerHelper.invokeConstructorOf("groovy.ui.Console", null);
            console.setProperty("shell", shell);
View Full Code Here

        // Add some completors to fancy things up
        reader.addCompletor(new CommandNameCompletor());

        if (parent != null) {
            shell = new GroovyShell(parent, binding);
        }
        else {
            shell = new GroovyShell(binding);
        }       

        // Add some default variables to the shell
        Map map = shell.getContext().getVariables();
View Full Code Here

        final String scriptName = computeScriptName();
        final GroovyClassLoader classLoader = new GroovyClassLoader(baseClassLoader);
        addClassPathes(classLoader);

        final GroovyShell groovy = new GroovyShell(classLoader, new Binding(), configuration);
        try {
            parseAndRunScript(groovy, txt, mavenPom, scriptName, null, new AntBuilder(this));
        } finally {
            groovy.resetLoadedClasses();
            groovy.getClassLoader().clearCache();
            if (contextClassLoader || maven) thread.setContextClassLoader(savedLoader);
        }
    }
View Full Code Here

TOP

Related Classes of groovy.lang.GroovyShell

Copyright © 2018 www.massapicom. 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.