本文整理了Java中groovy.lang.GroovyShell.run()
方法的一些代码示例,展示了GroovyShell.run()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GroovyShell.run()
方法的具体详情如下:
包路径:groovy.lang.GroovyShell
类名称:GroovyShell
方法名:run
[英]Runs the given script source with command line arguments
[中]使用命令行参数运行给定的脚本源
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* A helper method which runs the given script file with the given command line arguments
*
* @param scriptFile the file of the script to run
* @param list the command line arguments to pass in
*/
public Object run(File scriptFile, List list) throws CompilationFailedException, IOException {
return run(scriptFile, (String[]) list.toArray(EMPTY_STRING_ARRAY));
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* A helper method which runs the given cl script with the given command line arguments
*
* @param scriptText is the text content of the script
* @param fileName is the logical file name of the script (which is used to create the class name of the script)
* @param list the command line arguments to pass in
*/
public Object run(String scriptText, String fileName, List list) throws CompilationFailedException {
return run(scriptText, fileName, (String[]) list.toArray(EMPTY_STRING_ARRAY));
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Runs the given script source with command line arguments
*
* @param source is the source content of the script
* @param args the command line arguments to pass in
*/
public Object run(GroovyCodeSource source, List args) throws CompilationFailedException {
return run(source, ((String[]) args.toArray(EMPTY_STRING_ARRAY)));
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Runs the given script with command line arguments
*
* @param in the stream reading the script
* @param fileName is the logical file name of the script (which is used to create the class name of the script)
* @param list the command line arguments to pass in
*/
public Object run(final Reader in, final String fileName, List list) throws CompilationFailedException {
return run(in, fileName, (String[]) list.toArray(EMPTY_STRING_ARRAY));
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Runs the given script text with command line arguments
*
* @param scriptText is the text content of the script
* @param fileName is the logical file name of the script (which is used to create the class name of the script)
* @param args the command line arguments to pass in
*/
public Object run(final String scriptText, final String fileName, String[] args) throws CompilationFailedException {
GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
public GroovyCodeSource run() {
return new GroovyCodeSource(scriptText, fileName, DEFAULT_CODE_BASE);
}
});
return run(gcs, args);
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* A helper method to allow scripts to be run taking command line arguments
*/
public void run(File file, String[] arguments) throws CompilationFailedException, IOException {
GroovyShell shell = new GroovyShell(getClass().getClassLoader(), binding);
shell.run(file, arguments);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Runs the given script source with command line arguments
*
* @param source is the source content of the script
* @param args the command line arguments to pass in
*/
public Object run(URI source, List args) throws CompilationFailedException, IOException {
return run(new GroovyCodeSource(source), ((String[]) args.toArray(EMPTY_STRING_ARRAY)));
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Runs the given script source with command line arguments
*
* @param source is the source content of the script
* @param args the command line arguments to pass in
*/
public Object run(URI source, String[] args) throws CompilationFailedException, IOException {
return run(new GroovyCodeSource(source), args);
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* 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);
}
}
代码示例来源:origin: groovy/groovy-core
public void testMainMethod() throws Exception {
GroovyShell shell = new GroovyShell();
shell.run(new File("src/test/groovy/SampleMain.groovy"), new String[]{"A", "B", "C"});
}
}
代码示例来源:origin: groovy/groovy-core
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/org/codehaus/groovy/tools/DocGenerator.groovy"), args);
}
catch (Exception e) {
System.out.println("Failed: " + e);
e.printStackTrace();
}
}
}
代码示例来源:origin: groovy/groovy-core
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);
}
}
代码示例来源:origin: jenkinsci/jenkins
protected int run() throws Exception {
// this allows the caller to manipulate the JVM state, so require the execute script privilege.
Jenkins.getActiveInstance().checkPermission(Jenkins.RUN_SCRIPTS);
Binding binding = new Binding();
binding.setProperty("out",new PrintWriter(stdout,true));
binding.setProperty("stdin",stdin);
binding.setProperty("stdout",stdout);
binding.setProperty("stderr",stderr);
binding.setProperty("channel",channel);
if (channel != null) {
String j = getClientEnvironmentVariable("JOB_NAME");
if (j != null) {
Item job = Jenkins.getActiveInstance().getItemByFullName(j);
binding.setProperty("currentJob", job);
String b = getClientEnvironmentVariable("BUILD_NUMBER");
if (b != null && job instanceof AbstractProject) {
Run r = ((AbstractProject) job).getBuildByNumber(Integer.parseInt(b));
binding.setProperty("currentBuild", r);
}
}
}
GroovyShell groovy = new GroovyShell(Jenkins.getActiveInstance().getPluginManager().uberClassLoader, binding);
groovy.run(loadScript(),"RemoteClass",remaining.toArray(new String[remaining.size()]));
return 0;
}
代码示例来源:origin: apache/groovy
script.setProperty("pom", mavenPom);
script.run();
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
/**
* A helper method to allow scripts to be run taking command line arguments
*/
public void run(File file, String[] arguments) throws CompilationFailedException, IOException {
GroovyShell shell = new GroovyShell(binding);
shell.run(file, arguments);
}
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
/**
* A helper method which runs the given script file with the given command line arguments
*
* @param scriptFile the file of the script to run
* @param list the command line arguments to pass in
*/
public Object run(File scriptFile, List list) throws CompilationFailedException, IOException {
String[] args = new String[list.size()];
return run(scriptFile, (String[]) list.toArray(args));
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
/**
* A helper method which runs the given cl script with the given command line arguments
*
* @param scriptText is the text content of the script
* @param fileName is the logical file name of the script (which is used to create the class name of the script)
* @param list the command line arguments to pass in
*/
public Object run(String scriptText, String fileName, List list) throws CompilationFailedException {
String[] args = new String[list.size()];
list.toArray(args);
return run(scriptText, fileName, args);
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
/**
* A helper method which runs the given script file with the given command line arguments
*
* @param scriptFile the file of the script to run
* @param list the command line arguments to pass in
*/
public Object run(File scriptFile, List list) throws CompilationFailedException, IOException {
String[] args = new String[list.size()];
return run(scriptFile, (String[]) list.toArray(args));
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
/**
* A helper method which runs the given cl script with the given command line arguments
*
* @param scriptText is the text content of the script
* @param fileName is the logical file name of the script (which is used to create the class name of the script)
* @param list the command line arguments to pass in
*/
public Object run(String scriptText, String fileName, List list) throws CompilationFailedException {
String[] args = new String[list.size()];
list.toArray(args);
return run(scriptText, fileName, args);
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
/**
* A helper method to allow scripts to be run taking command line arguments
*/
public void run(File file, String[] arguments) throws CompilationFailedException, IOException {
GroovyShell shell = new GroovyShell(getClass().getClassLoader(), binding);
shell.run(file, arguments);
}
}
内容来源于网络,如有侵权,请联系作者删除!