!7 sS mainClassName = "StefansOS"; static S v = "x30"; static S sourceID = #1001638; static S javaTarget = "1.8"; // compile JavaX for everyone static S ecjSnippetID = #1400467; static S compilerBotID = #1001155; static int compressionLevel = 9; // Zip compression - highest level p { File jarFile = javaxArtifactsDir("Stefans-OS.jar"); S s = getServerTranspiled(sourceID); S libs = firstLine(s); s = dropFirstLine(s); S mainCode = getServerTranspiledWithoutLibs(#1016060); mainCode = jreplace(mainCode, "main.class", mainClassName + ".class"); mainCode = jreplace(mainCode, "class main", "class " + mainClassName); s = moveImportsUp(s + "\n" + mainCode); s += x30_makeUtilsSource(); L tok = javaTok(s); javax_prepareX30SourceForDeployment(tok); jreplace(tok, "public class " + v, "class " + v); S src = join(tok); File javaFile = new File(programDir(), mainClassName + ".java"); saveTextFile(javaFile, src); print("ok, made " + javaFile.getAbsolutePath()); print("Now compiling."); S botQuestion = "Please compile this Java text: " + quote(src) + " 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_recurse(new File(classesDir), zout); zip2zip_exceptManifest(ecj, zout); zout.close(); makeExecutable(jarFile); print("ok, made " + jarFile.getAbsolutePath() + " (" + jarFile.length() + " bytes)"); }