Package groovy.lang

Examples of groovy.lang.GroovyShell.evaluate()


        binding.setVariable("index",toModuloIndex(axes));
        binding.setVariable("uniqueId",toIndex(axes));

        GroovyShell shell = new GroovyShell(binding);

        Object result = shell.evaluate("use("+BooleanCategory.class.getName().replace('$','.')+") {"+expression+"}");
        return TRUE.equals(result);
    }

    public int compareTo(Combination that) {
        int d = this.size()-that.size();
View Full Code Here


            StringWriter out = new StringWriter();
            PrintWriter pw = new PrintWriter(out);
            shell.setVariable("out", pw);
            try {
                Object output = shell.evaluate(script);
                if(output!=null)
                pw.println("Result: "+output);
            } catch (Throwable t) {
                t.printStackTrace(pw);
            }
View Full Code Here

        execute(new GroovyCodeSource(initScript));
    }

    private static void execute(GroovyCodeSource initScript) throws IOException {
        GroovyShell shell = new GroovyShell(Jenkins.getInstance().getPluginManager().uberClassLoader);
        shell.evaluate(initScript);
    }

    private static final Logger LOGGER = Logger.getLogger(GroovyInitScript.class.getName());
}
View Full Code Here

                if (object == null) {
                    ResourceResolver resolver = context.getResourceResolver(value);
                    InputStream is = resolver.getInputStream(value);
                    Binding binding = new Binding();
                    GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
                    object = shell.evaluate(is);
                    is.close();
                }
            }
        }
        return object;
View Full Code Here

        try {
            ResourceResolver resolver = context.getResourceResolver(value);
            InputStream is = resolver.getInputStream(value);
            Binding binding = new Binding();
            GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
            object = shell.evaluate(is);
            is.close();
            return object;
        } catch (Exception e) {
            log.error("A  problem in the groovy script : " + value, e);
            throw e;
View Full Code Here

                if (object == null) {
                    ResourceResolver resolver = context.getResourceResolver(value);
                    InputStream is = resolver.getInputStream(value);
                    Binding binding = new Binding();
                    GroovyShell shell = new GroovyShell(prepareClassLoader(), binding);
                    object = shell.evaluate(is);
                    is.close();
                }
            }
        }
        return object;
View Full Code Here

        try {
            ResourceResolver resolver = context.getResourceResolver(value);
            InputStream is = resolver.getInputStream(value);
            Binding binding = new Binding();
            GroovyShell shell = new GroovyShell(prepareClassLoader(), binding);
            object = shell.evaluate(is);
            is.close();
            return object;
        } catch (Exception e) {
            log.error("A  problem in the groovy script : " + value, e);
            throw e;
View Full Code Here

      binding.setVariable("message", message);

      // Create a shell and evaluate
      GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(),
          binding);
      Object result = shell.evaluate(script);
      if (!(result instanceof String)) {
        throw new RuntimeException(
            "Groovy script should return a String indicating processed filename");
      }
      return (String) result;
View Full Code Here

        if (Debug.verboseOn())
            Debug.logVerbose("Using Context -- " + context, module);

        try {
            GroovyShell shell = new GroovyShell(getBinding(context));
            o = shell.evaluate(expression);

            if (Debug.verboseOn())
                Debug.logVerbose("Evaluated to -- " + o, module);

            // read back the context info
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

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.