/** * 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)); }
/** * 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)); }
/** * 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))); }
/** * 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)); }
/** * 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); }
/** * 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); } }
/** * 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))); }
/** * 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); }
/** * 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); } }
public void testMainMethod() throws Exception { GroovyShell shell = new GroovyShell(); shell.run(new File("src/test/groovy/SampleMain.groovy"), new String[]{"A", "B", "C"}); } }
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(); } } }
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); } }
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; }
script.setProperty("pom", mavenPom); script.run();
/** * 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); } }
/** * 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)); }
/** * 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); }
/** * 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)); }
/** * 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); }
/** * 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); } }