Download Jar. Transpiled version (17436L) is out of date.
1 | !7 |
2 | |
3 | sS defaultJavaTarget = "1.11"; |
4 | |
5 | sS standardCredentials() { ret ""; } // public snippets only |
6 | |
7 | // (transpilation md5, snippetID) => jar file |
8 | //static new SerializeComputations<PairS, File> computations; |
9 | // transpilation md5 => jar file |
10 | static new SerializeComputations<S, File> computations; |
11 | |
12 | html { |
13 | // lock lock; // now using SerializeComputations |
14 | |
15 | uri = dropPrefixSlash(uri); |
16 | S snippetID = fsI(uri); |
17 | if (!isSnippetPublic(snippetID)) fail("Snippet not public: " + snippetID); |
18 | S transpiledSrc = getServerTranspiled2(snippetID); |
19 | |
20 | // md5 check (if parameter supplied) |
21 | |
22 | S md5 = params.get('md5); |
23 | S srcMD5 = md5(transpiledSrc); |
24 | if (md5 != null && !eq(md5, srcMD5)) ret "md5 mismatch"; |
25 | bool forceCompilation = eq(params.get("forceCompilation"), "1"); |
26 | |
27 | File jar = computations.get(srcMD5/*, snippetID)*/, -> { |
28 | remutable transpiledSrc; |
29 | |
30 | new CompilerBot2 bot; |
31 | bot.forceCompilation = forceCompilation; |
32 | ret bot.compileSnippet(snippetID); |
33 | }); |
34 | |
35 | bool forceRepackage = eq("1", params.get("repackage")); |
36 | bool withLibs = eq("1", params.get("withLibs")); |
37 | bool noCompiler = eq("1", params.get("noCompiler")); |
38 | bool withX30 = eq("1", params.get("withX30")); |
39 | bool noSrc = eq("1", params.get("noSrc")); |
40 | bool dynamicObjectOnly = eq("dynamicObjectOnly", params.get("mode")); |
41 | S fileNameForBrowser = or2(params.get("filename"), psI(snippetID) + ".jar"); |
42 | |
43 | File jar2 = jar; |
44 | if (withLibs) jar2 = appendToBaseFileName(jar2, ".with-libs"); |
45 | if (noCompiler) jar2 = appendToBaseFileName(jar2, ".no-compiler"); |
46 | if (dynamicObjectOnly) jar2 = appendToBaseFileName(jar2, ".dynamicObjectOnly"); |
47 | if (noSrc) jar2 = appendToBaseFileName(jar2, ".noSrc"); |
48 | |
49 | if (!eq(jar, jar2)) { |
50 | if (fileLength(jar2) <= 22 || forceRepackage) { |
51 | temp var jarOut = zipOutputStream(jar2); |
52 | new Set<S> entries; |
53 | |
54 | text2zip(jarOut, "source.txt", f2s(jar2)); |
55 | |
56 | bool withSrc = !noSrc; |
57 | |
58 | zip2zip_collectFiles(jar, jarOut, entries, name -> withSrc || !endsWith(name, ".java")); |
59 | |
60 | if (withLibs) { |
61 | Pair<S, LS> srcAndLibs = extractLibsFromTranspilation(transpiledSrc); |
62 | fOr (S libID : srcAndLibs.b) { |
63 | File fixer = compilerBotDestDir("fixer" + psI(libID) + ".jar"); |
64 | |
65 | if (fileExists(fixer)) { |
66 | println("APPLYING FIXER: " + fixer); |
67 | zip2zip_collectFiles(fixer, jarOut, entries); |
68 | } |
69 | |
70 | zip2zip_collectFiles(loadLibraryOrSrcLib(libID), jarOut, entries); |
71 | /*if (withSrc && isSrcLib(libID)) |
72 | text2zip(jarOut, "lib" + libID + ".java", getServerTranspiledWithoutLibs(libID)); // TODO: use actual package and main class |
73 | */ |
74 | } |
75 | } |
76 | |
77 | if (withX30) |
78 | zip2zip_collectFiles(pathToJavaxJar(), jarOut, entries); |
79 | else if (noCompiler) |
80 | zip2zip_collectFiles(pathToJavaxJar(), jarOut, entries, name -> ! |
81 | startsWithOneOf(name, "org/eclipse/", "META-INF/")); |
82 | else if (dynamicObjectOnly) |
83 | zip2zip_collectFiles(pathToJavaxJar(), jarOut, entries, name -> contains(name, "DynamicObject")); |
84 | } |
85 | |
86 | jar = jar2; |
87 | } |
88 | |
89 | print("Serving jar for " + snippetID + ": " + renderFileInfo(jar)); |
90 | ret subBot_serveFileWithName(jar, fileNameForBrowser, "application/java-archive"); |
91 | } |
Began life as a copy of #1020140
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033533 |
Snippet name: | Jar Web Bot [old] |
Eternal ID of this version: | #1033533/7 |
Text MD5: | 4fa41b2af1901d1136d20ac10e7b1f17 |
Author: | stefan |
Category: | javax / web |
Type: | JavaX module (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-10-17 21:04:13 |
Source code size: | 3399 bytes / 91 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 283 / 986 |
Version history: | 6 change(s) |
Referenced in: | [show references] |