!747 m { static S v = "x27"; static S javaTarget = "1.6"; // compile JavaX for everyone static int compressionLevel = 9; // Zip compression - highest level p { S s = loadPage("http://tinybrain.de:8080/tb-int/get-transpiled.php?id=1001148&raw=1"); L tok = javaTok(s); renameToken(tok, "StringFunc", "StrF"); for (L c : allClasses(tok)) { S name = getClassDeclarationName(c); if (name.equals("main")) clearAllTokens(c); else if (name.equals(v) && !c.get(1).equals("public")) c.set(1, "public " + c.get(1)); } S javaFile = v + ".java"; saveTextFile(javaFile, join(tok)); print("ok, made " + javaFile); print("Now compiling. Making a compiler bot just for the occasion."); S botQuestion = "Please compile this Java text: " + quote(join(tok)) + " for java version " + quote(javaTarget); print("Question to bot: " + shorten(botQuestion, 200)); //print("Parses? " + match3("Please compile this Java text: *", botQuestion)); Class compilerBot = hotwire("#1001155"); // We should initialize it or so... we're being lazy here. Works for now. S answer = cast call(compilerBot, "answer", botQuestion); print("Bot said: " + answer); if (answer == null) fail(); new Matches m; if (!match3("ok, *", answer, m)) 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."); S jarFile = v + ".jar"; File ecj = loadLibrary("#1001164"); // ecj.zip FileOutputStream fout = new FileOutputStream(jarFile); ZipOutputStream zout = new ZipOutputStream(fout); zout.setLevel(compressionLevel); makeManifest(zout); dir2zip(classesDir, zout); zip2zip(ecj, zout); zout.close(); fout.close(); print("ok, made " + jarFile + " (" + new File(jarFile).length() + " bytes)"); } static void makeManifest(ZipOutputStream outZip) ctex { outZip.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); outZip.write(toUtf8("Manifest-Version: 1.0\n" + "Main-Class: " + v + "\n\n")); } }