fun execJavac(toCompile: String?, dir: File, jflexTestVersion: String): TestResult? { val p = Project()val javac = Javac() val path = Path(p, dir.toString())javac.setProject(p) javac.setSrcdir(path) javac.setDestdir(dir) javac.setTarget(javaVersion) javac.setSource(javaVersion) javac.setSourcepath(Path(p, "")) javac.setIncludes(toCompile) val classPath: Path = javac.createClasspath() classPath.setPath(System.getProperty("user.home") + "/.m2/repository/de/jflex/jflex/" + jflexTestVersion + "/jflex-" + jflexTestVersion + ".jar") val out = ByteArrayOutputStream() val outSafe: PrintStream = System.err System.setErr(PrintStream(out)) return try { javac.execute() TestResult(out.toString(), true) } catch (e: BuildException) { testResult(e.toString() + System.getProperty("line.separator") + out.toString(), false) finally { System.setErr(outSafe) } }
Call javac on toCompile in input dir . If toCompile is null , all *.java files below dir will be compiled .