當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。