/** * Primary entry point for compiling from the command line * (using the groovyc script). * <p> * If calling inside a process and you don't want the JVM to exit on an * error call commandLineCompile(String[]), which this method simply wraps * * @param args command line arguments */ public static void main(String[] args) { commandLineCompileWithErrorHandling(args, true); }
/** * Same as main(args) except that exceptions are thrown out instead of causing * the VM to exit. */ public static void commandLineCompile(String[] args) throws Exception { commandLineCompile(args, true); }
public RootLoader run() { return new RootLoader(lc); } });
private RootLoader makeRoot() { String[] list = taskClasspath.list(); LoaderConfiguration lc = new LoaderConfiguration(); for (int i=0; i<list.length; i++) { if (list[i].matches(".*ant-[^/]*jar$")) { continue; } if (list[i].matches(".*commons-logging-[^/]*jar$")) { continue; } if (list[i].matches(".*xerces-[^/]*jar$")) { continue; } lc.addFile(list[i]); } return new RootLoader(lc); }
/** * For Exception. */ protected void report( Exception e, boolean child ) { println( e.getMessage() ); stacktrace( e, false ); }
protected void runTest(String[] names) throws Exception { List files = new ArrayList(); for (int i = 0; i < names.length; i++) { String name = names[i]; File file = new File("src/test/groovy/" + name); files.add(file); assertTrue("Could not find source file: " + file, file.exists()); } compiler.compile((File[]) files.toArray(new File[names.length])); }
public static void doCompilation(CompilerConfiguration configuration, CompilationUnit unit, String[] filenames) throws Exception { doCompilation(configuration, unit, filenames, true); }
public void testCommandLine() throws Exception { try { FileSystemCompiler.commandLineCompile(new String[] {"--bogus-option"}); fail("Compiler fails to reject bogus command line"); } catch (Exception re) { // this is why shouldFail {} exists in Groovy tests } File dir = new File("target/test-generated-classes/cl"); dir.mkdirs(); FileSystemCompiler.commandLineCompile(new String[] {"src/test/groovy/LittleClosureTest.groovy", "-d", dir.getPath()}); }
public static boolean validateFiles(String[] filenames) { return checkFiles(filenames) == 0; }
public static void main(String args[]) { try { rootLoader(args); } catch (Throwable t) { t.printStackTrace(); } } }
/** Prints version information to stderr. * @see #displayVersion(PrintWriter) */ public static void displayVersion() { displayVersion(new PrintWriter(System.err, true)); }
/** * Writes the error to the specified <code>PrintStream</code>. */ public void write( PrintStream stream ) { this.output = stream; dispatch( base, false ); stream.flush(); }
/** * returns the URL of a resource, or null if it is not found */ public URL getResource(String name) { URL url = findResource(name); if (url == null) url = super.getResource(name); return url; }
/** Prints the usage help message for the {@link CompilationOptions} to the specified PrintWriter. * @since 2.5 */ public static void displayHelp(final PrintWriter writer) { configureParser(new CompilationOptions()).usage(writer); }
protected void runTest(String name) throws Exception { File file = new File("src/test/groovy/" + name); assertTrue("Could not find source file: " + file, file.exists()); compiler.compile(file); }
/** Prints version information to the specified PrintWriter. * @since 2.5 */ public static void displayVersion(final PrintWriter writer) { for (String line : new VersionProvider().getVersion()) { writer.println(line); } }
public void testMethodCall() throws Exception { //runTest("ClosureMethodTest.groovy"); //runTest("tree/VerboseTreeTest.groovy"); //runTest("tree/NestedClosureBugTest.groovy"); runTest("tree/SmallTreeTest.groovy"); //runTest("LittleClosureTest.groovy"); }
public void testMethodCall() throws Exception { runTest(new String[] {"ClosureMethodTest.groovy"}); runTest(new String[] {"tree/VerboseTreeTest.groovy"}); runTest(new String[] {"tree/NestedClosureBugTest.groovy"}); runTest(new String[] {"tree/SmallTreeTest.groovy"}); runTest(new String[] {"LittleClosureTest.groovy"}); runTest(new String[] {"JointJava.java", "JointGroovy.groovy"}); }
/** * For everything else. */ protected void report( Throwable e, boolean child ) { println( ">>> a serious error occurred: " + e.getMessage() ); stacktrace( e, true ); }
/** * For GroovyException. */ protected void report( GroovyExceptionInterface e, boolean child ) { println( ((Exception)e).getMessage() ); stacktrace( (Exception)e, false ); }