Libraryless. Click here for Pure Java version (1119L/8K/27K).
!747 m { static S v = "x29"; static S sourceID = "#1001600"; static S javaTarget = "1.6"; // compile JavaX for everyone static S compilerBotID = "#1001155"; static int compressionLevel = 9; // Zip compression - highest level p { S s = loadPage("http://tinybrain.de:8080/tb-int/get-transpiled.php?id=" + parseSnippetID(sourceID) + "&raw=1"); saveProgramTextFile("raw.java", s); L<S> tok = javaTok(s); renameToken(tok, "StringFunc", "StrF"); for (L<S> 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)); } File javaFile = new File(programDir(), v + ".java"); saveTextFile(javaFile, join(tok)); print("ok, made " + javaFile.getAbsolutePath()); 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(compilerBotID); // 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)) 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 jarFile = new File(programDir(), 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.getAbsolutePath() + " (" + jarFile.length() + " bytes)"); File deployedFile = new File(userHome(), ".javax/" + jarFile.getName()); copyFile(jarFile, deployedFile); print("Deployed to " + deployedFile.getAbsolutePath()); } 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")); } }
Began life as a copy of #1001371
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001601 |
Snippet name: | x29.jar maker module - deploys into {userhome}/.javax |
Eternal ID of this version: | #1001601/1 |
Text MD5: | 9abcece15d4f6b19e44e41270a39c03d |
Transpilation MD5: | e4f553d864d7fbd4d600502bd787ad1f |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-26 18:06:55 |
Source code size: | 2801 bytes / 74 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 636 / 685 |
Referenced in: | [show references] |