Showing
5 changed files
with
838 additions
and
0 deletions
etc/build/Xml2Js.class
0 → 100644
No preview for this file type
etc/build/Xml2Js.java
0 → 100644
1 | +import java.io.BufferedReader; | ||
2 | +import java.io.ByteArrayOutputStream; | ||
3 | +import java.io.File; | ||
4 | +import java.io.FileInputStream; | ||
5 | +import java.io.FileWriter; | ||
6 | +import java.io.IOException; | ||
7 | +import java.io.InputStream; | ||
8 | +import java.io.InputStreamReader; | ||
9 | +import java.io.UnsupportedEncodingException; | ||
10 | +import java.net.URLEncoder; | ||
11 | +import java.util.Arrays; | ||
12 | +import java.util.HashSet; | ||
13 | +import java.util.Iterator; | ||
14 | +import java.util.LinkedList; | ||
15 | +import java.util.List; | ||
16 | +import java.util.Set; | ||
17 | +import java.util.zip.Deflater; | ||
18 | + | ||
19 | +public class Xml2Js | ||
20 | +{ | ||
21 | + /** | ||
22 | + * | ||
23 | + */ | ||
24 | + protected static final int IO_BUFFER_SIZE = 4 * 1024; | ||
25 | + | ||
26 | + /** | ||
27 | + * | ||
28 | + */ | ||
29 | + public static String CHARSET_FOR_URL_ENCODING = "UTF-8"; | ||
30 | + | ||
31 | + /** | ||
32 | + * | ||
33 | + * @param path | ||
34 | + * @return | ||
35 | + */ | ||
36 | + public List<String> walk(File base, File root) throws IOException | ||
37 | + { | ||
38 | + if (root == null) | ||
39 | + { | ||
40 | + root = base; | ||
41 | + } | ||
42 | + | ||
43 | + List<String> result = new LinkedList<String>(); | ||
44 | + String basePath = base.getCanonicalPath(); | ||
45 | + File[] list = root.listFiles(); | ||
46 | + | ||
47 | + if (list != null) | ||
48 | + { | ||
49 | + for (File f : list) | ||
50 | + { | ||
51 | + if (f.isDirectory()) | ||
52 | + { | ||
53 | + result.addAll(walk(base, f)); | ||
54 | + } | ||
55 | + else if (f.getCanonicalPath().toLowerCase().endsWith(".xml")) | ||
56 | + { | ||
57 | + String name = f.getCanonicalPath() | ||
58 | + .substring(basePath.length() + 1); | ||
59 | + result.add( | ||
60 | + "f['" + name + "'] = '" + processFile(f) + "';\n"); | ||
61 | + } | ||
62 | + } | ||
63 | + } | ||
64 | + | ||
65 | + return result; | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * | ||
70 | + * @param file | ||
71 | + * @return | ||
72 | + * @throws IOException | ||
73 | + */ | ||
74 | + public static String processFile(File file) throws IOException | ||
75 | + { | ||
76 | + System.out.println("Processing " + file.getCanonicalPath() + "..."); | ||
77 | + | ||
78 | + Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true); | ||
79 | + byte[] inBytes = encodeURIComponent( | ||
80 | + readInputStream(new FileInputStream(file)), | ||
81 | + CHARSET_FOR_URL_ENCODING).getBytes("UTF-8"); | ||
82 | + deflater.setInput(inBytes); | ||
83 | + | ||
84 | + ByteArrayOutputStream outputStream = new ByteArrayOutputStream( | ||
85 | + inBytes.length); | ||
86 | + deflater.finish(); | ||
87 | + byte[] buffer = new byte[IO_BUFFER_SIZE]; | ||
88 | + | ||
89 | + while (!deflater.finished()) | ||
90 | + { | ||
91 | + int count = deflater.deflate(buffer); // returns the generated code... index | ||
92 | + outputStream.write(buffer, 0, count); | ||
93 | + } | ||
94 | + | ||
95 | + outputStream.close(); | ||
96 | + | ||
97 | + return encodeToString(outputStream.toByteArray(), false); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * | ||
102 | + * @param stream | ||
103 | + * @return | ||
104 | + * @throws IOException | ||
105 | + */ | ||
106 | + public static String readInputStream(InputStream stream) throws IOException | ||
107 | + { | ||
108 | + BufferedReader reader = new BufferedReader( | ||
109 | + new InputStreamReader(stream)); | ||
110 | + StringBuffer result = new StringBuffer(); | ||
111 | + String tmp = reader.readLine(); | ||
112 | + | ||
113 | + while (tmp != null) | ||
114 | + { | ||
115 | + result.append(tmp.trim()); | ||
116 | + tmp = reader.readLine(); | ||
117 | + } | ||
118 | + | ||
119 | + reader.close(); | ||
120 | + | ||
121 | + return result.toString(); | ||
122 | + } | ||
123 | + | ||
124 | + public static String encodeURIComponent(String s, String charset) | ||
125 | + { | ||
126 | + if (s == null) | ||
127 | + { | ||
128 | + return null; | ||
129 | + } | ||
130 | + else | ||
131 | + { | ||
132 | + String result; | ||
133 | + | ||
134 | + try | ||
135 | + { | ||
136 | + result = URLEncoder.encode(s, charset).replaceAll("\\+", "%20") | ||
137 | + .replaceAll("\\%21", "!").replaceAll("\\%27", "'") | ||
138 | + .replaceAll("\\%28", "(").replaceAll("\\%29", ")") | ||
139 | + .replaceAll("\\%7E", "~"); | ||
140 | + } | ||
141 | + catch (UnsupportedEncodingException e) | ||
142 | + { | ||
143 | + // This exception should never occur | ||
144 | + result = s; | ||
145 | + } | ||
146 | + | ||
147 | + return result; | ||
148 | + } | ||
149 | + } | ||
150 | + | ||
151 | + private static final char[] CA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" | ||
152 | + .toCharArray(); | ||
153 | + | ||
154 | + private static final int[] IA = new int[256]; | ||
155 | + static | ||
156 | + { | ||
157 | + Arrays.fill(IA, -1); | ||
158 | + for (int i = 0, iS = CA.length; i < iS; i++) | ||
159 | + IA[CA[i]] = i; | ||
160 | + IA['='] = 0; | ||
161 | + } | ||
162 | + | ||
163 | + // **************************************************************************************** | ||
164 | + // * char[] version | ||
165 | + // **************************************************************************************** | ||
166 | + | ||
167 | + /** Encodes a raw byte array into a BASE64 <code>char[]</code> representation i accordance with RFC 2045. | ||
168 | + * @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. | ||
169 | + * @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> | ||
170 | + * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a | ||
171 | + * little faster. | ||
172 | + * @return A BASE64 encoded array. Never <code>null</code>. | ||
173 | + */ | ||
174 | + public final static char[] encodeToChar(byte[] sArr, boolean lineSep) | ||
175 | + { | ||
176 | + // Check special case | ||
177 | + int sLen = sArr != null ? sArr.length : 0; | ||
178 | + if (sLen == 0) | ||
179 | + return new char[0]; | ||
180 | + | ||
181 | + int eLen = (sLen / 3) * 3; // Length of even 24-bits. | ||
182 | + int cCnt = ((sLen - 1) / 3 + 1) << 2; // Returned character count | ||
183 | + int dLen = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array | ||
184 | + char[] dArr = new char[dLen]; | ||
185 | + | ||
186 | + // Encode even 24-bits | ||
187 | + for (int s = 0, d = 0, cc = 0; s < eLen;) | ||
188 | + { | ||
189 | + // Copy next three bytes into lower 24 bits of int, paying attension to sign. | ||
190 | + int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | ||
191 | + | (sArr[s++] & 0xff); | ||
192 | + | ||
193 | + // Encode the int into four chars | ||
194 | + dArr[d++] = CA[(i >>> 18) & 0x3f]; | ||
195 | + dArr[d++] = CA[(i >>> 12) & 0x3f]; | ||
196 | + dArr[d++] = CA[(i >>> 6) & 0x3f]; | ||
197 | + dArr[d++] = CA[i & 0x3f]; | ||
198 | + | ||
199 | + // Add optional line separator | ||
200 | + if (lineSep && ++cc == 19 && d < dLen - 2) | ||
201 | + { | ||
202 | + dArr[d++] = '\r'; | ||
203 | + dArr[d++] = '\n'; | ||
204 | + cc = 0; | ||
205 | + } | ||
206 | + } | ||
207 | + | ||
208 | + // Pad and encode last bits if source isn't even 24 bits. | ||
209 | + int left = sLen - eLen; // 0 - 2. | ||
210 | + if (left > 0) | ||
211 | + { | ||
212 | + // Prepare the int | ||
213 | + int i = ((sArr[eLen] & 0xff) << 10) | ||
214 | + | (left == 2 ? ((sArr[sLen - 1] & 0xff) << 2) : 0); | ||
215 | + | ||
216 | + // Set last four chars | ||
217 | + dArr[dLen - 4] = CA[i >> 12]; | ||
218 | + dArr[dLen - 3] = CA[(i >>> 6) & 0x3f]; | ||
219 | + dArr[dLen - 2] = left == 2 ? CA[i & 0x3f] : '='; | ||
220 | + dArr[dLen - 1] = '='; | ||
221 | + } | ||
222 | + return dArr; | ||
223 | + } | ||
224 | + | ||
225 | + // **************************************************************************************** | ||
226 | + // * String version | ||
227 | + // **************************************************************************************** | ||
228 | + | ||
229 | + /** Encodes a raw byte array into a BASE64 <code>String</code> representation i accordance with RFC 2045. | ||
230 | + * @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. | ||
231 | + * @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> | ||
232 | + * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a | ||
233 | + * little faster. | ||
234 | + * @return A BASE64 encoded array. Never <code>null</code>. | ||
235 | + */ | ||
236 | + public final static String encodeToString(byte[] sArr, boolean lineSep) | ||
237 | + { | ||
238 | + // Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower. | ||
239 | + return new String(encodeToChar(sArr, lineSep)); | ||
240 | + } | ||
241 | + | ||
242 | + /** | ||
243 | + * Main | ||
244 | + */ | ||
245 | + public static void main(String[] args) | ||
246 | + { | ||
247 | + if (args.length < 2) | ||
248 | + { | ||
249 | + System.out.println("Usage: xml2js path file"); | ||
250 | + } | ||
251 | + else | ||
252 | + { | ||
253 | + try | ||
254 | + { | ||
255 | + Xml2Js fw = new Xml2Js(); | ||
256 | + | ||
257 | + // Generates result | ||
258 | + StringBuffer result = new StringBuffer(); | ||
259 | + result.append("(function() {\nvar f = {};\n"); | ||
260 | + | ||
261 | + List<String> files = fw | ||
262 | + .walk(new File(new File(".").getCanonicalPath() | ||
263 | + + File.separator + args[0]), null); | ||
264 | + Iterator<String> it = files.iterator(); | ||
265 | + | ||
266 | + while (it.hasNext()) | ||
267 | + { | ||
268 | + result.append(it.next()); | ||
269 | + } | ||
270 | + | ||
271 | + result.append("\n"); | ||
272 | + result.append("var l = mxStencilRegistry.loadStencil;\n\n"); | ||
273 | + result.append( | ||
274 | + "mxStencilRegistry.loadStencil = function(filename, fn)\n{\n"); | ||
275 | + result.append(" var t = f[filename.substring(STENCIL_PATH.length + 1)];\n"); | ||
276 | + result.append(" var s = null;\n"); | ||
277 | + result.append(" if (t != null) {\n"); | ||
278 | + result.append(" t = pako.inflateRaw(Uint8Array.from(atob(t), function (c) {\n"); | ||
279 | + result.append(" return c.charCodeAt(0);\n"); | ||
280 | + result.append(" }), {to: 'string'});\n"); | ||
281 | + result.append(" s = decodeURIComponent(t);\n"); | ||
282 | + result.append(" }\n"); | ||
283 | + result.append(" if (fn != null && s != null) {\n"); | ||
284 | + result.append( | ||
285 | + " window.setTimeout(function(){fn(mxUtils.parseXml(s))}, 0);\n"); | ||
286 | + result.append(" } else {\n"); | ||
287 | + result.append( | ||
288 | + " return (s != null) ? mxUtils.parseXml(s) : l.apply(this, arguments)\n"); | ||
289 | + result.append(" }\n"); | ||
290 | + result.append("};\n"); | ||
291 | + result.append("})();\n"); | ||
292 | + | ||
293 | + FileWriter writer = new FileWriter( | ||
294 | + new File(new File(".").getCanonicalPath() | ||
295 | + + File.separator + args[1])); | ||
296 | + writer.write(result.toString()); | ||
297 | + writer.flush(); | ||
298 | + writer.close(); | ||
299 | + } | ||
300 | + catch (IOException ex) | ||
301 | + { | ||
302 | + ex.printStackTrace(); | ||
303 | + } | ||
304 | + } | ||
305 | + } | ||
306 | +} |
etc/build/build.properties
0 → 100644
etc/build/build.xml
0 → 100644
1 | +<?xml version="1.0"?> | ||
2 | +<project basedir="." default="all"> | ||
3 | + | ||
4 | + <property file="build.properties.local" /> | ||
5 | + <property file="build.properties" /> | ||
6 | + <taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="${jscompiler}" /> | ||
7 | + | ||
8 | + <target name="merge"> | ||
9 | + <concat destfile="${basedir}/../../build/shapes.js" fixlastline="yes" append="no"> | ||
10 | + <fileset dir="${war.dir}/shapes" includes="**/*.js"/> | ||
11 | + <fileset dir="${war.dir}/stencils" includes="**/*.js"/> | ||
12 | + </concat> | ||
13 | + | ||
14 | + <java fork="false" classname="Xml2Js" classpath="."> | ||
15 | + <arg value="../../src/main/webapp/stencils"/> | ||
16 | + <arg value="../../src/main/webapp/js/stencils.min.js"/> | ||
17 | + </java> | ||
18 | + | ||
19 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/shapes-14-6-5.min.js"> | ||
20 | + <sources dir="${basedir}/../../build"> | ||
21 | + <file name="shapes.js" /> | ||
22 | + </sources> | ||
23 | + </jscomp> | ||
24 | + | ||
25 | + <tstamp> | ||
26 | + <format property="time.stamp" pattern="MM/dd/yyyy hh:mm aa" unit="hour"/> | ||
27 | + </tstamp> | ||
28 | + | ||
29 | + <delete dir="${basedir}/../../build"/> | ||
30 | + </target> | ||
31 | + | ||
32 | + <target name="app" depends="merge"> | ||
33 | + <delete file="${basedir}/.tmp0.js"/> | ||
34 | + <echo file="${basedir}/.tmp0.js"> | ||
35 | + window.PROXY_URL = window.PROXY_URL || 'https://viewer.diagrams.net/proxy'; | ||
36 | + window.SHAPES_PATH = window.SHAPES_PATH || 'https://viewer.diagrams.net/shapes'; | ||
37 | + window.STENCIL_PATH = window.STENCIL_PATH || 'https://viewer.diagrams.net/stencils'; | ||
38 | + window.GRAPH_IMAGE_PATH = window.GRAPH_IMAGE_PATH || 'https://viewer.diagrams.net/img'; | ||
39 | + window.mxImageBasePath = window.mxImageBasePath || 'https://viewer.diagrams.net/mxgraph/images'; | ||
40 | + window.mxBasePath = window.mxBasePath || 'https://viewer.diagrams.net/mxgraph/'; | ||
41 | + window.mxLoadStylesheets = window.mxLoadStylesheets || false; | ||
42 | + </echo> | ||
43 | + | ||
44 | + <delete file="${basedir}/.tmp1.js"/> | ||
45 | + <copy file="${war.dir}/styles/default.xml" tofile="${basedir}/.tmp1.xml" overwrite="true"/> | ||
46 | + <replaceregexp file="${basedir}/.tmp1.xml" match="${line.separator}" flags="g" replace=""/> | ||
47 | + <replaceregexp file="${basedir}/.tmp1.xml" match="\t" flags="g" replace=""/> | ||
48 | + <replaceregexp file="${basedir}/.tmp1.xml" match="'" flags="g" replace="\\\\'" byline="true"/> | ||
49 | + | ||
50 | + <delete file="${basedir}/Graph-Stylesheet.js"/> | ||
51 | + <echo file="${basedir}/Graph-Stylesheet.js">Graph.prototype.defaultThemes['default-style2'] = mxUtils.parseXml(`</echo> | ||
52 | + <concat destfile="${basedir}/Graph-Stylesheet.js" fixlastline="no" append="true"> | ||
53 | + <filelist dir="${basedir}" files=".tmp1.xml"/> | ||
54 | + </concat> | ||
55 | + <echo file="${basedir}/Graph-Stylesheet.js" append="true">`).documentElement;</echo> | ||
56 | + <echo file="${basedir}/Graph-Stylesheet.js" append="true">Graph.prototype.defaultThemes['darkTheme'] = Graph.prototype.defaultThemes['default-style2'];</echo> | ||
57 | + | ||
58 | + <delete file="${basedir}/.tmp2.xml"/> | ||
59 | + <copy file="${war.dir}/resources/dia.txt" tofile="${basedir}/.tmp2.xml" overwrite="true"/> | ||
60 | + <replaceregexp file="${basedir}/.tmp2.xml" match="${line.separator}" flags="g" replace="\\\\n"/> | ||
61 | + <replaceregexp file="${basedir}/.tmp2.xml" match="'" flags="g" replace="\\\\'" byline="true"/> | ||
62 | + | ||
63 | + <delete file="${basedir}/Graph-Resources.js"/> | ||
64 | + <echo file="${basedir}/Graph-Resources.js">mxResources.parse(`</echo> | ||
65 | + <concat destfile="${basedir}/Graph-Resources.js" fixlastline="no" append="true"> | ||
66 | + <filelist dir="${basedir}" files=".tmp2.xml"/> | ||
67 | + </concat> | ||
68 | + <echo file="${basedir}/Graph-Resources.js" append="true">`);</echo> | ||
69 | + | ||
70 | + <jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${basedir}/grapheditor.min.js"> | ||
71 | + <sources dir="${grapheditor.dir}"> | ||
72 | + <file name="Editor.js" /> | ||
73 | + <file name="EditorUi.js" /> | ||
74 | + <file name="Sidebar.js" /> | ||
75 | + <file name="Graph.js" /> | ||
76 | + <file name="Format.js" /> | ||
77 | + <file name="Shapes.js" /> | ||
78 | + <file name="Actions.js" /> | ||
79 | + <file name="Menus.js" /> | ||
80 | + <file name="Toolbar.js" /> | ||
81 | + <file name="Dialogs.js" /> | ||
82 | + </sources> | ||
83 | + </jscomp> | ||
84 | + | ||
85 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${basedir}/sidebar.min.js"> | ||
86 | + <sources dir="${war.dir}/js/diagramly/sidebar"> | ||
87 | + <file name="Sidebar.js" /> | ||
88 | + <file name="Sidebar-ActiveDirectory.js" /> | ||
89 | + <file name="Sidebar-Advanced.js" /> | ||
90 | + <file name="Sidebar-AlliedTelesis.js" /> | ||
91 | + <file name="Sidebar-Android.js" /> | ||
92 | + <file name="Sidebar-ArchiMate.js" /> | ||
93 | + <file name="Sidebar-ArchiMate3.js" /> | ||
94 | + <file name="Sidebar-Arrows2.js" /> | ||
95 | + <file name="Sidebar-Atlassian.js" /> | ||
96 | + <file name="Sidebar-AWS.js" /> | ||
97 | + <file name="Sidebar-AWS3.js" /> | ||
98 | + <file name="Sidebar-AWS3D.js" /> | ||
99 | + <file name="Sidebar-AWS4.js" /> | ||
100 | + <file name="Sidebar-AWS4b.js" /> | ||
101 | + <file name="Sidebar-Azure.js" /> | ||
102 | + <file name="Sidebar-Azure2.js" /> | ||
103 | + <file name="Sidebar-Basic.js" /> | ||
104 | + <file name="Sidebar-Bootstrap.js" /> | ||
105 | + <file name="Sidebar-BPMN.js" /> | ||
106 | + <file name="Sidebar-C4.js" /> | ||
107 | + <file name="Sidebar-Cabinet.js" /> | ||
108 | + <file name="Sidebar-Cisco.js" /> | ||
109 | + <file name="Sidebar-Cisco19.js" /> | ||
110 | + <file name="Sidebar-CiscoSafe.js" /> | ||
111 | + <file name="Sidebar-Citrix.js" /> | ||
112 | + <file name="Sidebar-Cumulus.js" /> | ||
113 | + <file name="Sidebar-DFD.js" /> | ||
114 | + <file name="Sidebar-EIP.js" /> | ||
115 | + <file name="Sidebar-Electrical.js" /> | ||
116 | + <file name="Sidebar-ER.js" /> | ||
117 | + <file name="Sidebar-Floorplan.js" /> | ||
118 | + <file name="Sidebar-Flowchart.js" /> | ||
119 | + <file name="Sidebar-FluidPower.js" /> | ||
120 | + <file name="Sidebar-GCP.js" /> | ||
121 | + <file name="Sidebar-GCP2.js" /> | ||
122 | + <file name="Sidebar-GCPIcons.js" /> | ||
123 | + <file name="Sidebar-Gmdl.js" /> | ||
124 | + <file name="Sidebar-IBM.js" /> | ||
125 | + <file name="Sidebar-Infographic.js" /> | ||
126 | + <file name="Sidebar-Ios.js" /> | ||
127 | + <file name="Sidebar-Ios7.js" /> | ||
128 | + <file name="Sidebar-Kubernetes.js" /> | ||
129 | + <file name="Sidebar-LeanMapping.js" /> | ||
130 | + <file name="Sidebar-Mockup.js" /> | ||
131 | + <file name="Sidebar-MSCAE.js" /> | ||
132 | + <file name="Sidebar-Network.js" /> | ||
133 | + <file name="Sidebar-Office.js" /> | ||
134 | + <file name="Sidebar-PID.js" /> | ||
135 | + <file name="Sidebar-Rack.js" /> | ||
136 | + <file name="Sidebar-Signs.js" /> | ||
137 | + <file name="Sidebar-Sitemap.js" /> | ||
138 | + <file name="Sidebar-Sysml.js" /> | ||
139 | + <file name="Sidebar-ThreatModeling.js" /> | ||
140 | + <file name="Sidebar-UML25.js" /> | ||
141 | + <file name="Sidebar-Veeam.js" /> | ||
142 | + <file name="Sidebar-Veeam2.js" /> | ||
143 | + <file name="Sidebar-VVD.js" /> | ||
144 | + <file name="Sidebar-WebIcons.js" /> | ||
145 | + </sources> | ||
146 | + </jscomp> | ||
147 | + | ||
148 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${basedir}/client.min.js"> | ||
149 | + <sources dir="${war.dir}/js/deflate"> | ||
150 | + <file name="base64.js" /> | ||
151 | + </sources> | ||
152 | + | ||
153 | + <sources dir="${war.dir}/js/diagramly"> | ||
154 | + <file name="Init.js" /> | ||
155 | + </sources> | ||
156 | + | ||
157 | + <sources dir="${grapheditor.dir}"> | ||
158 | + <file name="Init.js" /> | ||
159 | + </sources> | ||
160 | + | ||
161 | + <sources dir="${war.dir}/mxgraph"> | ||
162 | + <file name="mxClient.js" /> | ||
163 | + </sources> | ||
164 | + | ||
165 | + <sources dir="${war.dir}/js/jscolor"> | ||
166 | + <file name="jscolor.js" /> | ||
167 | + </sources> | ||
168 | + </jscomp> | ||
169 | + | ||
170 | + <jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${basedir}/.tmp0.min.js"> | ||
171 | + <sources dir="${basedir}"> | ||
172 | + <file name=".tmp0.js"/> | ||
173 | + </sources> | ||
174 | + </jscomp> | ||
175 | + | ||
176 | + <jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${basedir}/.tmp1.js"> | ||
177 | + <sources dir="${grapheditor.dir}"> | ||
178 | + <file name="Editor.js" /> | ||
179 | + <file name="EditorUi.js" /> | ||
180 | + <file name="Graph.js" /> | ||
181 | + <file name="Shapes.js" /> | ||
182 | + <file name="Actions.js" /> | ||
183 | + </sources> | ||
184 | + | ||
185 | + <sources dir="${war.dir}/js/diagramly"> | ||
186 | + <file name="DrawioFile.js" /> | ||
187 | + <file name="LocalFile.js" /> | ||
188 | + <file name="Editor.js" /> | ||
189 | + <file name="EditorUi.js" /> | ||
190 | + <file name="Pages.js" /> | ||
191 | + <file name="Trees.js" /> | ||
192 | + <file name="Minimal.js" /> | ||
193 | + <file name="DrawioComment.js" /> | ||
194 | + <file name="DrawioUser.js" /> | ||
195 | + </sources> | ||
196 | + | ||
197 | + <sources dir="${basedir}"> | ||
198 | + <file name="Graph-Resources.js" /> | ||
199 | + <file name="Graph-Stylesheet.js" /> | ||
200 | + </sources> | ||
201 | + | ||
202 | + <sources dir="${war.dir}/js/diagramly"> | ||
203 | + <file name="GraphViewer.js" /> | ||
204 | + </sources> | ||
205 | + </jscomp> | ||
206 | + | ||
207 | + <concat destfile="${basedir}/base-viewer.min.js" fixlastline="yes" append="no"> | ||
208 | + <filelist dir="${basedir}" files=".tmp0.min.js"/> | ||
209 | + <filelist dir="${war.dir}/js/spin" files="spin.min.js"/> | ||
210 | + <filelist dir="${war.dir}/js/sanitizer" files="sanitizer.min.js"/> | ||
211 | + <filelist dir="${war.dir}/js/deflate" files="pako.min.js"/> | ||
212 | + <filelist dir="${war.dir}/js/rough" files="rough.min.js"/> | ||
213 | + <filelist dir="${basedir}" files="client.min.js,.tmp1.js"/> | ||
214 | + </concat> | ||
215 | + | ||
216 | + <loadfile property="version" srcFile="../../VERSION"/> | ||
217 | + <replace file="${basedir}/base-viewer.min.js" token="@DRAWIO-VERSION@" value="${version}"/> | ||
218 | + | ||
219 | + <echo file="${basedir}/.tmp2.js"> | ||
220 | + (function() | ||
221 | + { | ||
222 | + Editor.initMath(); | ||
223 | + GraphViewer.initCss(); | ||
224 | + | ||
225 | + if (window.onDrawioViewerLoad != null) | ||
226 | + { | ||
227 | + window.onDrawioViewerLoad(); | ||
228 | + } | ||
229 | + else | ||
230 | + { | ||
231 | + GraphViewer.processElements(); | ||
232 | + } | ||
233 | + })(); | ||
234 | + </echo> | ||
235 | + | ||
236 | + <jscomp compilationLevel="simple" forceRecompile="true" debug="false" output="${basedir}/.tmp2.min.js"> | ||
237 | + <sources dir="${basedir}"> | ||
238 | + <file name=".tmp2.js"/> | ||
239 | + </sources> | ||
240 | + </jscomp> | ||
241 | + | ||
242 | + <concat destfile="${war.dir}/js/viewer.min.js" fixlastline="yes" append="no"> | ||
243 | + <filelist dir="${basedir}" files="base-viewer.min.js,.tmp2.min.js"/> | ||
244 | + </concat> | ||
245 | + | ||
246 | + <!-- Disables eval for JS (uses shapes-14-6-5.min.js) and registers PWA --> | ||
247 | + <echo file="${basedir}/.tmp3.js"> | ||
248 | + mxStencilRegistry.allowEval = false; | ||
249 | + | ||
250 | + (function() | ||
251 | + { | ||
252 | + try | ||
253 | + { | ||
254 | + if (Editor.enableServiceWorker) | ||
255 | + { | ||
256 | + navigator.serviceWorker.register('/service-worker.js'); | ||
257 | + } | ||
258 | + } | ||
259 | + catch (e) | ||
260 | + { | ||
261 | + if (window.console != null) | ||
262 | + { | ||
263 | + console.error(e); | ||
264 | + } | ||
265 | + } | ||
266 | + })(); | ||
267 | + </echo> | ||
268 | + | ||
269 | + <concat destfile="${war.dir}/js/viewer-static.min.js" fixlastline="yes" append="no"> | ||
270 | + <filelist dir="${basedir}" files="base-viewer.min.js"/> | ||
271 | + <filelist dir="${war.dir}/js" files="shapes-14-6-5.min.js"/> | ||
272 | + <filelist dir="${basedir}" files=".tmp3.js,.tmp2.min.js"/> | ||
273 | + </concat> | ||
274 | + | ||
275 | + <delete file="${war.dir}/js/extensions.min.js"/> | ||
276 | + <delete file="${basedir}/.tmp0.js"/> | ||
277 | + <delete file="${basedir}/.tmp0.min.js"/> | ||
278 | + <delete file="${basedir}/.tmp1.js"/> | ||
279 | + <delete file="${basedir}/.tmp2.js"/> | ||
280 | + <delete file="${basedir}/.tmp2.min.js"/> | ||
281 | + <delete file="${basedir}/.tmp3.js"/> | ||
282 | + <delete file="${basedir}/.tmp1.xml"/> | ||
283 | + <delete file="${basedir}/.tmp2.xml"/> | ||
284 | + | ||
285 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${basedir}/.tmp1.js"> | ||
286 | + <sources dir="${war.dir}/js/diagramly"> | ||
287 | + <file name="DrawioFile.js" /> | ||
288 | + <file name="LocalFile.js" /> | ||
289 | + <file name="LocalLibrary.js" /> | ||
290 | + <file name="StorageFile.js" /> | ||
291 | + <file name="StorageLibrary.js" /> | ||
292 | + <file name="RemoteFile.js" /> | ||
293 | + <file name="RemoteLibrary.js" /> | ||
294 | + <file name="UrlLibrary.js" /> | ||
295 | + <file name="EmbedFile.js" /> | ||
296 | + <file name="Dialogs.js" /> | ||
297 | + <file name="Editor.js" /> | ||
298 | + <file name="EditorUi.js" /> | ||
299 | + <file name="DiffSync.js" /> | ||
300 | + <file name="Settings.js" /> | ||
301 | + <file name="DrawioFileSync.js" /> | ||
302 | + <file name="App.js" /> | ||
303 | + <file name="Menus.js" /> | ||
304 | + <file name="Pages.js" /> | ||
305 | + <file name="Trees.js" /> | ||
306 | + <file name="Minimal.js" /> | ||
307 | + <file name="DistanceGuides.js" /> | ||
308 | + <file name="mxRuler.js" /> | ||
309 | + <file name="mxFreehand.js" /> | ||
310 | + <file name="DrawioUser.js" /> | ||
311 | + <file name="DrawioComment.js" /> | ||
312 | + </sources> | ||
313 | + | ||
314 | + <sources dir="${basedir}"> | ||
315 | + <file name="Graph-Stylesheet.js" /> | ||
316 | + </sources> | ||
317 | + </jscomp> | ||
318 | + | ||
319 | + <concat destfile="${basedir}/base.min.js" fixlastline="yes" append="no"> | ||
320 | + <filelist dir="${war.dir}/js/spin" files="spin.min.js"/> | ||
321 | + <filelist dir="${war.dir}/js/sanitizer" files="sanitizer.min.js"/> | ||
322 | + <filelist dir="${war.dir}/js/cryptojs" files="aes.min.js"/> | ||
323 | + <filelist dir="${war.dir}/js/deflate" files="pako.min.js"/> | ||
324 | + <filelist dir="${war.dir}/js/rough" files="rough.min.js"/> | ||
325 | + <filelist dir="${war.dir}/js/freehand" files="perfect-freehand.js"/> | ||
326 | + <filelist dir="${basedir}" files="client.min.js,grapheditor.min.js,sidebar.min.js,.tmp1.js"/> | ||
327 | + </concat> | ||
328 | + | ||
329 | + <replace file="${basedir}/base.min.js" token="@DRAWIO-VERSION@" value="${version}"/> | ||
330 | + | ||
331 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/extensions.min.js"> | ||
332 | + <sources dir="${war.dir}/js/diagramly"> | ||
333 | + <file name="Extensions.js" /> | ||
334 | + </sources> | ||
335 | + <sources dir="${war.dir}/js/diagramly/vsdx"> | ||
336 | + <file name="VsdxExport.js" /> | ||
337 | + <file name="mxVsdxCanvas2D.js" /> | ||
338 | + <file name="bmpDecoder.js" /> | ||
339 | + <file name="importer.js" /> | ||
340 | + </sources> | ||
341 | + <sources dir="${war.dir}/js/diagramly/graphml"> | ||
342 | + <file name="mxGraphMlCodec.js" /> | ||
343 | + </sources> | ||
344 | + </jscomp> | ||
345 | + | ||
346 | + <delete file="${war.dir}/js/orgchart.min.js"/> | ||
347 | + <concat destfile="${war.dir}/js/orgchart.min.js" fixlastline="yes" append="no"> | ||
348 | + <filelist dir="${war.dir}/js/orgchart" files="bridge.min.js,bridge.collections.min.js,OrgChart.Layout.min.js"/> | ||
349 | + </concat> | ||
350 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${basedir}/.tmp3.js"> | ||
351 | + <sources dir="${war.dir}/js/orgchart"> | ||
352 | + <file name="mxOrgChartLayout.js" /> | ||
353 | + </sources> | ||
354 | + </jscomp> | ||
355 | + <concat destfile="${war.dir}/js/orgchart.min.js" fixlastline="yes" append="yes"> | ||
356 | + <filelist dir="${basedir}" files=".tmp3.js"/> | ||
357 | + </concat> | ||
358 | + <delete file="${basedir}/.tmp3.js"/> | ||
359 | + | ||
360 | + <concat destfile="${war.dir}/js/extensions.min.js" fixlastline="yes" append="yes"> | ||
361 | + <fileset file="${war.dir}/js/jszip/jszip.min.js"/> | ||
362 | + <fileset file="${war.dir}/js/mermaid/mermaid.min.js"/> | ||
363 | + <fileset file="${war.dir}/js/orgchart.min.js"/> | ||
364 | + </concat> | ||
365 | + | ||
366 | + <delete file="${basedir}/.tmp1.js"/> | ||
367 | + | ||
368 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${basedir}/.tmp1.js"> | ||
369 | + <sources dir="${war.dir}/js/diagramly"> | ||
370 | + <file name="DrawioFile.js" /> | ||
371 | + <file name="LocalFile.js" /> | ||
372 | + <file name="LocalLibrary.js" /> | ||
373 | + <file name="StorageFile.js" /> | ||
374 | + <file name="StorageLibrary.js" /> | ||
375 | + <file name="RemoteFile.js" /> | ||
376 | + <file name="RemoteLibrary.js" /> | ||
377 | + <file name="UrlLibrary.js" /> | ||
378 | + <file name="EmbedFile.js" /> | ||
379 | + <file name="Dialogs.js" /> | ||
380 | + <file name="Editor.js" /> | ||
381 | + <file name="EditorUi.js" /> | ||
382 | + <file name="DiffSync.js" /> | ||
383 | + <file name="Settings.js" /> | ||
384 | + <file name="DrawioFileSync.js" /> | ||
385 | + </sources> | ||
386 | + | ||
387 | + <sources dir="${basedir}"> | ||
388 | + <file name="Graph-Stylesheet.js" /> | ||
389 | + </sources> | ||
390 | + | ||
391 | + <sources dir="${war.dir}/js/diagramly/util"> | ||
392 | + <file name="mxAsyncCanvas.js" /> | ||
393 | + <file name="mxJsCanvas.js" /> | ||
394 | + </sources> | ||
395 | + | ||
396 | + <sources dir="${war.dir}/js/diagramly"> | ||
397 | + <file name="DrawioClient.js" /> | ||
398 | + <file name="DrawioUser.js" /> | ||
399 | + <file name="DriveFile.js" /> | ||
400 | + <file name="DriveLibrary.js" /> | ||
401 | + <file name="DriveClient.js" /> | ||
402 | + <file name="DropboxFile.js" /> | ||
403 | + <file name="DropboxLibrary.js" /> | ||
404 | + <file name="DropboxClient.js" /> | ||
405 | + <file name="OneDriveFile.js" /> | ||
406 | + <file name="OneDriveLibrary.js" /> | ||
407 | + <file name="OneDriveClient.js" /> | ||
408 | + <file name="GitHubFile.js" /> | ||
409 | + <file name="GitHubLibrary.js" /> | ||
410 | + <file name="GitHubClient.js" /> | ||
411 | + <file name="TrelloFile.js" /> | ||
412 | + <file name="TrelloLibrary.js" /> | ||
413 | + <file name="TrelloClient.js" /> | ||
414 | + <file name="GitLabFile.js" /> | ||
415 | + <file name="GitLabLibrary.js" /> | ||
416 | + <file name="GitLabClient.js" /> | ||
417 | + <file name="DrawioComment.js" /> | ||
418 | + <file name="DriveComment.js" /> | ||
419 | + </sources> | ||
420 | + | ||
421 | + <sources dir="${war.dir}/js/onedrive"> | ||
422 | + <file name="mxODPicker.js" /> | ||
423 | + </sources> | ||
424 | + | ||
425 | + <sources dir="${war.dir}/js/diagramly"> | ||
426 | + <file name="App.js" /> | ||
427 | + <file name="Menus.js" /> | ||
428 | + <file name="Pages.js" /> | ||
429 | + <file name="Trees.js" /> | ||
430 | + <file name="Minimal.js" /> | ||
431 | + <file name="DistanceGuides.js" /> | ||
432 | + <file name="mxRuler.js" /> | ||
433 | + <file name="mxFreehand.js" /> | ||
434 | + <file name="P2PCollab.js" /> | ||
435 | + </sources> | ||
436 | + </jscomp> | ||
437 | + | ||
438 | + <concat destfile="${war.dir}/js/app.min.js" fixlastline="yes" append="no"> | ||
439 | + <filelist dir="${war.dir}/js/spin" files="spin.min.js"/> | ||
440 | + <filelist dir="${war.dir}/js/sanitizer" files="sanitizer.min.js"/> | ||
441 | + <filelist dir="${war.dir}/js/cryptojs" files="aes.min.js"/> | ||
442 | + <filelist dir="${war.dir}/js/deflate" files="pako.min.js"/> | ||
443 | + <filelist dir="${war.dir}/js/rough" files="rough.min.js"/> | ||
444 | + <filelist dir="${war.dir}/js/freehand" files="perfect-freehand.js"/> | ||
445 | + <filelist dir="${basedir}" files="client.min.js,grapheditor.min.js,sidebar.min.js,.tmp1.js"/> | ||
446 | + </concat> | ||
447 | + | ||
448 | + <replace file="${war.dir}/js/app.min.js" token="@DRAWIO-VERSION@" value="${version}"/> | ||
449 | + | ||
450 | + <delete file="${basedir}/Graph-Stylesheet.js"/> | ||
451 | + <delete file="${basedir}/Graph-Resources.js"/> | ||
452 | + <delete file="${basedir}/grapheditor.min.js"/> | ||
453 | + <delete file="${basedir}/sidebar.min.js"/> | ||
454 | + <delete file="${basedir}/client.min.js"/> | ||
455 | + <delete file="${basedir}/.tmp1.js"/> | ||
456 | + </target> | ||
457 | + | ||
458 | + <target name="atlas" depends="app"> | ||
459 | + <copy file="${basedir}/base-viewer.min.js" tofile="${war.dir}/js/atlas-viewer.min.js" overwrite="true"/> | ||
460 | + | ||
461 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${basedir}/.tmp0.js"> | ||
462 | + <sources dir="${war.dir}/connect/common/js"> | ||
463 | + <file name="mxReader.js" /> | ||
464 | + </sources> | ||
465 | + </jscomp> | ||
466 | + | ||
467 | + <concat destfile="${war.dir}/js/atlas.min.js" fixlastline="yes" append="no"> | ||
468 | + <file name="${basedir}/base.min.js" /> | ||
469 | + <file name="${war.dir}/js/extensions.min.js" /> | ||
470 | + <file name="${basedir}/.tmp0.js" /> | ||
471 | + </concat> | ||
472 | + | ||
473 | + <delete file="${basedir}/.tmp0.js"/> | ||
474 | + </target> | ||
475 | + | ||
476 | + <target name="integrate" depends="atlas"> | ||
477 | + <copy file="${war.dir}/js/atlas.min.js" tofile="${war.dir}/js/integrate.min.js" overwrite="true"/> | ||
478 | + | ||
479 | + <jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${basedir}/.tmp0.js"> | ||
480 | + <sources dir="${basedir}/../integrate"> | ||
481 | + <file name="Integrate.js" /> | ||
482 | + </sources> | ||
483 | + </jscomp> | ||
484 | + | ||
485 | + <concat destfile="${war.dir}/js/integrate.min.js" fixlastline="yes" append="yes"> | ||
486 | + <file name="${war.dir}/js/shapes-14-6-5.min.js" /> | ||
487 | + <file name="${war.dir}/js/stencils.min.js" /> | ||
488 | + <file name="${basedir}/.tmp0.js" /> | ||
489 | + </concat> | ||
490 | + | ||
491 | + <delete file="${basedir}/.tmp0.js"/> | ||
492 | + </target> | ||
493 | + | ||
494 | + <target name="all" depends="app, integrate"> | ||
495 | + <delete file="${war.dir}/js/atlas-viewer.min.js"/> | ||
496 | + <delete file="${war.dir}/js/atlas.min.js"/> | ||
497 | + </target> | ||
498 | + | ||
499 | + <!-- ================== Stand-alone war creation ============================= --> | ||
500 | + | ||
501 | + <path id="javac.class.path"> | ||
502 | + <fileset dir="${war.dir}/WEB-INF/lib" /> | ||
503 | + </path> | ||
504 | + | ||
505 | + <target name="javac" description="Java compilation"> | ||
506 | + <mkdir dir="${javac.dir}"/> | ||
507 | + <javac includeantruntime="false" srcdir="${src.dir}" excludes="**/EmbedServlet2.java" destdir="${javac.dir}"> | ||
508 | + <classpath refid="javac.class.path" /> | ||
509 | + </javac> | ||
510 | + <copy todir="${javac.dir}" file="${src.dir}/log4j.properties" /> | ||
511 | + </target> | ||
512 | + | ||
513 | + <target name="clean" description="Cleans build directories"> | ||
514 | + <delete dir="${javac.dir}"/> | ||
515 | + <delete dir="${build.dir}"/> | ||
516 | + <delete file="${basedir}/base.min.js"/> | ||
517 | + <delete file="${basedir}/base-viewer.min.js"/> | ||
518 | + </target> | ||
519 | + | ||
520 | + <target name="war" depends="app, javac" description="Create the stand-alone war file"> | ||
521 | + <zip destfile="${build.dir}/${war.name}" basedir="${war.dir}" > | ||
522 | + </zip> | ||
523 | + </target> | ||
524 | + | ||
525 | +</project> |
etc/build/compiler.jar
0 → 100644
No preview for this file type