Package groovy.lang

Examples of groovy.lang.GroovyShell.evaluate()


             ImportCustomizer customizer = new ImportCustomizer();
             customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
             configuratorConfig.addCompilationCustomizers(customizer);

             GroovyShell shell = new GroovyShell(binding, configuratorConfig);
             shell.evaluate(groovyConfigurator);
         }

         main.args = args;

        return main.run();
View Full Code Here



    @SuppressWarnings("unchecked")
    public Map<String, Object> execute(String script, Binding binding) {
        GroovyShell shell = new GroovyShell(getClass().getClassLoader(), binding);
        shell.evaluate(script);
        return binding.getVariables();
    }


    private <V> List<Object> invokeWithClosure(Class<?> clz, List<String> attributes, Closure<V> callable) {
View Full Code Here

        if (listener != null) {
            shell.setVariable("listener", listener);
            shell.setVariable("out", listener.getLogger());
        }

        output = shell.evaluate(new InputStreamReader(getScriptSource().getScriptStream(build.getWorkspace(), build,
                listener)));

        if (output instanceof Boolean) {
            return (Boolean) output;
        } else {
View Full Code Here

                } else {
                    return super.invokeMethod(name, args);
                }
            }
        });
        Step actual = (Step) shell.evaluate("steps." + expected);
        r.assertEqualDataBoundBeans(step, actual);
    }

    private static void assertRender(String expected, Object o) {
        StringBuilder b = new StringBuilder();
View Full Code Here

     *
     * @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());
    }

    protected String getTestClassName() {
        return TEST_SCRIPT_NAME_PREFIX + getMethodName() + (counter++) + ".groovy";
    }
View Full Code Here

  public static void main(String[] args) {
    Binding binding = new Binding();
    binding.setVariable("x", 2.4);
    binding.setVariable("y", 8);
    GroovyShell shell = new GroovyShell(binding);
    Object value = shell.evaluate("x + y");
    assert value.equals(new BigDecimal(10.4));
  }

}
View Full Code Here

    {
      System.setOut(newOut);
      System.setErr(newOut);

      final GroovyShell shell = new GroovyShell(new Binding(bindings));
      returnValue = shell.evaluate(script);

    }
    catch (final Exception e)
    {
      exception = e;
View Full Code Here


    @SuppressWarnings("unchecked")
    public Map<String, Object> execute(String script, Binding binding) {
        GroovyShell shell = new GroovyShell(getClass().getClassLoader(), binding);
        shell.evaluate(script);
        return binding.getVariables();
    }


    private <V> List<Object> invokeWithClosure(Class<?> clz, List<String> attributes, Closure<V> callable) {
View Full Code Here

            .injectMain(bearMain);

        GroovyShell shell = new GroovyShell();

        shell.setVariable("project", project);
        shell.evaluate("project." + method);
    }

    public GlobalTaskRunner run(BearProject project, boolean shutdown) {
        return run(project, null, shutdown, false);
    }
View Full Code Here

         ResourceResolver resolver = context.getResourceResolver(value);
         InputStream is = resolver.getInputStream(value);
         //TODO if is == null throw an exception saying the it's impossible to find the file
         Binding binding = new Binding();
         GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
         object = shell.evaluate(is);
         is.close();
         return object;
      }
      catch (Exception e)
      {
View Full Code Here

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.