!7 sS mainClassName = "StefansOS"; static S v = "x30"; static S sourceID = #1001638; static S javaTarget = "1.6"; // compile JavaX for everyone static S ecjSnippetID = #1011501; // ecj.zip static S compilerBotID = #1001155; static int compressionLevel = 9; // Zip compression - highest level p { File jarFile = new File(programDir(), "Stefans OS.jar"); S s = getServerTranspiled(sourceID); S libs = firstLine(s); s = dropFirstLine(s); L tok = javaTok(s); javax_prepareX30SourceForDeployment(tok); File javaFile = new File(programDir(), v + ".java"); S src = join(tok); src += [[ class ]] + mainClassName + [[ { public static void main(String[] args) { x30.main("#1016005"); } } ]]; saveTextFile(javaFile, src); print("ok, made " + javaFile.getAbsolutePath()); print("Now compiling."); S botQuestion = "Please compile this Java text: " + quote(join(tok)) + " for java version " + quote(javaTarget); print("Question to bot: " + shorten(botQuestion, 200)); Class compilerBot = hotwire(compilerBotID); S answer = cast call(compilerBot, "answer", botQuestion); print("Bot said: " + answer); if (answer == null) fail(); new Matches m; if (!match3("ok, *", answer, m)) if (match3("Compile error", answer)) fail("Compile Error."); else fail("I don't understand the bot, exiting"); S classesDir = unquote(m.m[0]); print("I think the classes dir is: " + classesDir); if (!new File(classesDir).isDirectory()) fail("huh?"); print("Now making jar."); File ecj = loadLibrary(ecjSnippetID); ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(jarFile)); zout.setLevel(compressionLevel); makeManifestWithMainClass(zout, mainClassName); dir2zip(classesDir, zout); zip2zip_exceptManifest(ecj, zout); zout.close(); print("ok, made " + jarFile.getAbsolutePath() + " (" + jarFile.length() + " bytes)"); }