sclass JavaCompilation { File srcDir; L libraries; File classesDir; bool verbose = true; S sourceLevel = "11"; S moreOptions = "-warn:none"; L sources; File optionsFile; S compilerOutput; swappable void invokeJavaCompiler() { compilerOutput = invokeEcj_direct(optionsFile); } run { // collect sources sources = findJavaSourceFiles(srcDir); if (sources.isEmpty()) throw new IOException("No sources found"); // compile optionsFile = File.createTempFile("ecj", "", javaxTempDir()); try { if (verbose) printWithMS("Compiling " + sources.size() + " source(s) to " + classesDir.getPath()); if (verbose) printWithMS("Libraries: " + libraries); S options = unnull(moreOptions) + " -source " + sourceLevel + " -target " + sourceLevel; options += " -d " + pqO(classesDir.getPath()); libraries.add(pathToJavaxJar()); makeOptionsFileForJavaCompiler(optionsFile, sources, libraries, options); if (verbose) printWithMS("Options: " + loadTextFile(optionsFile)); classesDir.mkdirs(); time "invokeJavaCompiler" { invokeJavaCompiler(); } } finally { optionsFile.delete(); } } }