Download Jar. Libraryless. Click here for Pure Java version (18173L/119K).
!7 static S v = "x30"; static S sourceID = "#1001638"; static S javaTarget = "11"; // now using Java 11 for "var" keyword static S ecjSnippetID = #1400533; // ecj compiler to be bundled into x30.jar // #1400467 static S compilerBotID = "#1001155"; static int compressionLevel = 9; // Zip compression - highest level set flag hotwire_here. p { loading "Updating JavaX!" { sendToAllVMs("prepare for javax upgrade"); File jarFile = new File(programDir(), v + ".jar"); File deployedFile = new File(userHome(), ".javax/" + jarFile.getName()); S oldMD5 = deployedFile == null ? null : md5(deployedFile); if (oldMD5 != null) print("Current md5: " + oldMD5); S s = loadPage(tb_mainServer() + "/tb-int/get-transpiled.php?id=" + parseSnippetID(sourceID) + "&raw=1&withlibs=1"); S libs = firstLine(s); s = dropFirstLine(s); s += x30_makeUtilsSource(); saveProgramTextFile("raw.java", s); L<S> tok = javaTok(s); // TODO: generate & compile DynamicMethods.java javax_prepareX30SourceForDeployment(tok); 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 = format("Please compile this Java text: * for java version *", join(tok), javaTarget); print("Question to bot: " + shorten(botQuestion, 200)); print("..." + takeLast(botQuestion, 200)); print("Parses? " + match3("Please compile this Java text: * for java version *", botQuestion)); Class compilerBot = hotwireDependent(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?"); long transpilationDate = parseFirstLong(replace(jextract("myTranspilationDate_value = *", tok), "L", "")); saveTextFile(new File(classesDir, "transpilationDate"), strOrNull(transpilationDate)); print("Now making jar."); File ecj = loadLibrary(ecjSnippetID); FileOutputStream fout = new FileOutputStream(jarFile); ZipOutputStream zout = new ZipOutputStream(fout); zout.setLevel(compressionLevel); makeManifestWithMainClass(zout, v); dir2zip_recurse(new File(classesDir), zout); zip2zip_exceptManifest(ecj, zout); zout.close(); fout.close(); print("ok, made " + jarFile.getAbsolutePath() + " (" + jarFile.length() + " bytes)"); copyFile(jarFile, deployedFile); print("Deployed to " + deployedFile.getAbsolutePath()); S newMD5 = md5(deployedFile); if (eq(oldMD5, newMD5)) print("File unchanged."); else print("File changed. New MD5: " + newMD5); print(); setConsoleTitle(infoBoxAndReturn("JavaX successfully updated!")); } if (isMain() && !headless()) { sleepSeconds(5); cleanKill(); } }
Began life as a copy of #1001601
download show line numbers debug dex old transpilations
Travelled to 39 computer(s): aoiabmzegqzx, aqvamacmveew, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, dhtvkmknsjym, djztyncnmsck, ekrmjmnbrukm, etmzoiygucik, gwrvuhgaqvyk, hpgrupgrauku, hszllmzzlmie, imzmzdywqqli, irmadwmeruwu, ishqpsrjomds, iveijnkanddl, jtubtzbbkimh, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, nzrhlmtlsyqh, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, snaazhdonpnp, teubizvjbppd, triorysbatvj, tslmcundralx, tvejysmllsmz, vdyxwxlmubrt, vouqrxazstgt, vpdwwinrgdga, wtqryiryparv, xeobevbjagfg, ychswryhhvyu, ymdyxumozjwr
No comments. add comment
Snippet ID: | #1001639 |
Snippet name: | Update JavaX! [deploys into {userhome}/.javax] |
Eternal ID of this version: | #1001639/39 |
Text MD5: | c510751dd676e8c09bdaecfc138b5f0d |
Transpilation MD5: | 05e80ce36d4bcc5d7acb58c1c002d2a6 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-30 16:54:11 |
Source code size: | 3451 bytes / 93 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 1080 / 6957 |
Version history: | 38 change(s) |
Referenced in: | [show references] |