当前位置: 首页>>代码示例>>Java>>正文


Java GroovyShell.run方法代码示例

本文整理汇总了Java中groovy.lang.GroovyShell.run方法的典型用法代码示例。如果您正苦于以下问题:Java GroovyShell.run方法的具体用法?Java GroovyShell.run怎么用?Java GroovyShell.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在groovy.lang.GroovyShell的用法示例。


在下文中一共展示了GroovyShell.run方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
/**
 * Standalone execution for Designer and Gradle.
 */
public void run() {
    startExecution();

    CompilerConfiguration compilerConfig = new CompilerConfiguration(System.getProperties());
    compilerConfig.setScriptBaseClass(TestCaseScript.class.getName());
    Binding binding = new Binding();
    binding.setVariable("testCaseRun", this);

    ClassLoader classLoader = this.getClass().getClassLoader();
    GroovyShell shell = new GroovyShell(classLoader, binding, compilerConfig);
    shell.setProperty("out", getLog());
    setupContextClassLoader(shell);
    try {
        shell.run(new GroovyCodeSource(getTestCase().file()), new String[0]);
        finishExecution(null);
    }
    catch (IOException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:24,代码来源:StandaloneTestCaseRun.java

示例2: testGroovyScriptEngineVsGroovyShell

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
public void testGroovyScriptEngineVsGroovyShell() throws IOException, ResourceException, ScriptException {
    // @todo refactor this path
    File currentDir = new File("./src/test/groovy/bugs");
    String file = "bug1567_script.groovy";

    Binding binding = new Binding();
    GroovyShell shell = new GroovyShell(binding);
    String[] test = null;
    Object result = shell.run(new File(currentDir, file), test);

    String[] roots = new String[]{currentDir.getAbsolutePath()};
    GroovyScriptEngine gse = new GroovyScriptEngine(roots);
    binding = new Binding();
    // a MME was ensued here stating no 't.start()' was available
    // in the script
    gse.run(file, binding);
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:Groovy1567_Bug.java

示例3: main

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        GroovyShell shell = new GroovyShell();
        //shell.run("src/main/org/codehaus/groovy/tools/DocGenerator.groovy", "org.codehaus.groovy.tools.DocGenerator.groovy", args);
        shell.run(new File("src/main/groovy/org/codehaus/groovy/tools/DocGenerator.groovy"), args);
    }
    catch (Exception e) {
        System.out.println("Failed: " + e);
        e.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:DocGeneratorMain.java

示例4: run

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
public ArquillianEnvironment run(String script) throws Exception {
        CompilerConfiguration config = new CompilerConfiguration();
        config.setScriptBaseClass(ArquillianEnvironment.class.getName());
        GroovyShell shell = new GroovyShell(config);
        
//        GroovyScriptEngine gse = new GroovyScriptEngine(connector);
//        System.out.println(ArquillianEnvironment.class.getName());
//        gse.getConfig().setScriptBaseClass(ArquillianEnvironment.class.getName());

        return (ArquillianEnvironment)shell.run(script, "arquillian", new ArrayList<String>());
        
//        Binding b = new Binding();
//        return (ArquillianEnvironment)gse.run(script, b);
    }
 
开发者ID:arquillian,项目名称:arquillian-script,代码行数:15,代码来源:ScriptRunner.java

示例5: setupDecorateMethods

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
/**
 * Decorate Dumpling API with groovy extensions.
 */
public void setupDecorateMethods(ClassLoader cl) {
    synchronized (STAR_IMPORTS) {
        if (DECORATED) return;

        GroovyShell shell = new GroovyShell(cl, new Binding(), getCompilerConfiguration());
        try {
            shell.run(
                    "import org.codehaus.groovy.runtime.DefaultGroovyMethods;" +
                    "def mc = ThreadSet.metaClass;" +
                    "mc.asImmutable << { -> delegate };" +
                    "mc.toSet << { -> delegate };" +
                    "mc.grep << { Object filter -> delegate.derive(DefaultGroovyMethods.grep(delegate.threadsAsSet, filter)) };" +
                    "mc.grep << { -> delegate.derive(delegate.threadsAsSet.grep()) };" +
                    "mc.findAll << { Closure closure -> delegate.derive(DefaultGroovyMethods.findAll((Object) delegate.threadsAsSet, closure)) };" +
                    "mc.findAll << { -> delegate.derive(delegate.threadsAsSet.findAll()) };" +
                    "mc.intersect << { rhs -> if (!delegate.getProcessRuntime().equals(rhs.getProcessRuntime())) throw new IllegalArgumentException('Unable to intersect ThreadSets bound to different ProcessRuntimes'); return delegate.derive(DefaultGroovyMethods.intersect(delegate.threadsAsSet, rhs.threadsAsSet)) };" +
                    "mc.plus << { rhs -> if (!delegate.getProcessRuntime().equals(rhs.getProcessRuntime())) throw new IllegalArgumentException('Unable to merge ThreadSets bound to different ProcessRuntimes'); return delegate.derive(DefaultGroovyMethods.plus(delegate.threadsAsSet, rhs.threadsAsSet)) };",
                    "dumpling-metaclass-setup",
                    Arrays.asList()
            );
        } catch (Exception ex) {
            AssertionError err = new AssertionError("Unable to decorate object model");
            err.initCause(ex);
            throw err; // Java 6
        }
        DECORATED = true;
    }
}
 
开发者ID:olivergondza,项目名称:dumpling,代码行数:32,代码来源:GroovyInterpretterConfig.java

示例6: run

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
@Override
public int run(ProcessStream process) throws CmdLineException {
    Binding binding = CONFIG.getDefaultBinding(process, args, runtime);
    if (runtime != null) {
        binding.setProperty("runtime", runtime); // Compatibility
    }

    GroovyShell shell = new GroovyShell(binding, CONFIG.getCompilerConfiguration());
    CONFIG.setupDecorateMethods();
    Object exitVal = shell.run(getScript(process), "dumpling-script", args.toArray(new String[args.size()]));
    if (exitVal != null) {
        if (exitVal instanceof ModelObject) {
            final ModelObject model = (ModelObject) exitVal;
            model.toString(process.out(), porcelain ? Mode.MACHINE : Mode.HUMAN);
        } else {
            process.out().println(exitVal);
        }
    }

    if (exitVal instanceof Boolean) {
        return Boolean.TRUE.equals(exitVal) ? 0 : -1;
    } else if (exitVal instanceof Integer) {
        return ((Integer) exitVal);
    }

    return 0;
}
 
开发者ID:olivergondza,项目名称:dumpling,代码行数:28,代码来源:GroovyCommand.java

示例7: run

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
@Override
public int run(ProcessStream process) throws CmdLineException {
    Binding binding = CONFIG.getDefaultBinding(process, Arrays.<String>asList(), runtime);
    GroovyShell shell = new GroovyShell(binding, CONFIG.getCompilerConfiguration());

    CONFIG.setupDecorateMethods();
    String script = String.format(SCRIPT_STUB, predicate);
    ThreadSet<?, ?, ?> set = (ThreadSet<?, ?, ?>) shell.run(script, "dumpling-script", Arrays.asList());

    set.toString(process.out(), porcelain ? Mode.MACHINE : Mode.HUMAN);
    process.err().printf("Threads: %d%n", set.size());

    return set.isEmpty() ? 1 : 0;
}
 
开发者ID:olivergondza,项目名称:dumpling,代码行数:15,代码来源:GrepCommand.java

示例8: processOnce

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
/**
 * Process the standard, single script with args.
 */
private void processOnce() throws CompilationFailedException, IOException, URISyntaxException {
    GroovyShell groovy = new GroovyShell(conf);
    setupContextClassLoader(groovy);
    groovy.run(getScriptSource(isScriptFile, script), args);
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:GroovyMain.java

示例9: evaluate

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
/** evaluate the source text against the classic AST with the JSR parser implementation*/
public Object evaluate(String theSrcText, String testName) throws Exception {
    parse(theSrcText, testName); // fail early with a direct message if possible')
    GroovyShell groovy = new GroovyShell(new CompilerConfiguration());
    return groovy.run(theSrcText, "main", new ArrayList());
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:ClassicGroovyTestGeneratorHelper.java

示例10: testMainMethod

import groovy.lang.GroovyShell; //导入方法依赖的package包/类
public void testMainMethod() throws Exception {
    GroovyShell shell = new GroovyShell();
    shell.run(new File("src/test/groovy/SampleMain.groovy"), new String[]{"A", "B", "C"});
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:MainTest.java


注:本文中的groovy.lang.GroovyShell.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。