Download Jar. Transpiled version (12373L) is out of date.
1 | !7 |
2 | |
3 | sS defaultJavaTarget = "1.8"; |
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 | |
26 | File jar = computations.get(srcMD5/*, snippetID)*/, -> { |
27 | remutable transpiledSrc; |
28 | int i = transpiledSrc.indexOf('\n'); |
29 | S libs = transpiledSrc.substring(0, Math.max(0, i)); |
30 | printVars(+snippetID, +libs); |
31 | transpiledSrc = transpiledSrc.substring(i+1); |
32 | S javaTarget = or(params.get('javaTarget), defaultJavaTarget); |
33 | CompilerBot.verbose = true; |
34 | ret CompilerBot.compile(transpiledSrc, libs, javaTarget, snippetID); |
35 | }); |
36 | |
37 | bool withLibs = eq("1", params.get("withLibs")); |
38 | if (withLibs) { |
39 | Pair<S, LS> srcAndLibs = extractLibsFromTranspilation(transpiledSrc); |
40 | if (nempty(srcAndLibs.b)) { |
41 | File jar2 = appendToBaseFileName(jar, ".with-libs"); |
42 | if (fileLength(jar2) <= 22) { |
43 | mergeJars_manifestFromFirst(flattenLists( |
44 | jar, |
45 | map loadLibraryOrSrcLib(srcAndLibs.b) |
46 | ), jar2); |
47 | } |
48 | jar = jar2; |
49 | } |
50 | } |
51 | |
52 | bool noCompiler = eq("1", params.get("noCompiler")); |
53 | if (noCompiler) { |
54 | File jar2 = appendToBaseFileName(jar, ".no-compiler"); |
55 | if (fileLength(jar2) <= 22) { |
56 | temp var jarOut = zipOutputStream(jar2); |
57 | zip2zip(jar, jarOut); |
58 | zip2zip(pathToJavaxJar(), jarOut, name -> ! |
59 | startsWithOneOf(name, "org/eclipse/", "META-INF/")); |
60 | } |
61 | printFileInfo(jar = jar2); |
62 | } |
63 | |
64 | bool withX30 = eq("1", params.get("withX30")); |
65 | if (withX30) { |
66 | File jar2 = appendToBaseFileName(jar, ".with-x30"); |
67 | if (fileLength(jar2) <= 22) { |
68 | mergeJars_manifestFromFirst(jar, pathToJavaxJar(), jar2); |
69 | } |
70 | jar = jar2; |
71 | } |
72 | |
73 | bool noSrc = eq("1", params.get("noSrc")); |
74 | |
75 | bool dynamicObjectOnly = eq("dynamicObjectOnly", params.get("mode")); |
76 | if (dynamicObjectOnly) { |
77 | File jar2 = appendToBaseFileName(jar, ".dynamicObjectOnly" + stringIf(noSrc, ".noSrc")); |
78 | if (fileLength(jar2) <= 22) { |
79 | temp var jarOut = zipOutputStream(jar2); |
80 | bool withSrc = !noSrc; |
81 | zip2zip(jar, jarOut, name -> withSrc || !endsWith(name, ".java")); |
82 | zip2zip(pathToJavaxJar(), jarOut, name -> contains(name, "DynamicObject")); |
83 | } |
84 | jar = jar2; |
85 | } |
86 | |
87 | print("Serving jar for " + snippetID + ": " + renderFileInfo(jar)); |
88 | ret subBot_serveFileWithName(jar, psI(snippetID) + ".jar", "application/java-archive"); |
89 | } |
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: | #1033462 |
Snippet name: | Jar Web Bot [backup] |
Eternal ID of this version: | #1033462/3 |
Text MD5: | bf2f474ba04e629ade40c40fefa48e7b |
Author: | stefan |
Category: | javax / web |
Type: | JavaX module |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-28 22:22:55 |
Source code size: | 3041 bytes / 89 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 254 / 984 |
Version history: | 2 change(s) |
Referenced in: | [show references] |