|
1 | 1 | <project name="JSmol" default="toJs" basedir="."> |
2 | | - |
3 | | - <!-- |
4 | | - |
5 | | - An important issue with SwingJS is that it requires several hundred Java |
6 | | - classes to be loaded. While in development mode this may be no problem, |
7 | | - it is not desirable for distribution. |
8 | | - |
9 | | - To solve this problem, SwingJS is designed to read one or more "core" |
10 | | - files when loading. (And, in the future, when accessing specific packages |
11 | | - or classes, but that work has not been completed, as of 2019.05.) |
12 | | - |
13 | | - The core file is simply a Google Closure Compiler minified concatenation |
14 | | - of all or most of the files needed for your application. This compiler is |
15 | | - in the tools folder you need to have copied to your project from the |
16 | | - sources/net.sf.j2s.java.core/dist directory of the java2script GitHub project. |
17 | | - |
18 | | - This ANT task, build-core.xml, creates a core file in site/swingjs/j2s/core/ |
19 | | - with the name core_xxx.js and its minified version, core_xxx.z.js, where you |
20 | | - can indicate what "_xxx" is, below. (The _ is not significant, but I recommend it.) |
21 | | - |
22 | | - This core file can be used to replace coreswingjs.z.js in the default |
23 | | - loading sequence. SwingJS will look for the value of the Info.core |
24 | | - key passed to the system from the HTML page. Possible values: |
25 | | - |
26 | | - core: "none" // do not use any core files - useful for debugging and core construction |
27 | | - core: null // (or just no "core" entry) - use coreswingjs.z.js |
28 | | - core: "_xxx" // use a core_xxx.z.js file that you have created |
29 | | - |
30 | | - Creating a customized core_xxx file |
31 | | - - - - - - - - - - - - - - - - - - - |
32 | | - |
33 | | - 1) Prepare _j2sclasslist.txt, a list of site/swingjs/j2s files for inclusion. |
34 | | - |
35 | | - You can do this by: |
36 | | - |
37 | | - a) Just creating it by hand. |
38 | | - b) Fully exercising your application via the site/*.html file |
39 | | - that is produced by the j2s transpiler and based on template.html |
40 | | - in your project directory, then clicking the get _j2sclasslist.txt link. |
41 | | - c) appending to the _j2sclasslist.txt that was used to create coreswingjs.z.js |
42 | | - (provided in the distribution). |
43 | | - d) Some combination of the above, or any other process of your design. |
44 | | - |
45 | | - _j2sclasslist.txt can have duplicate entries. build-core.xml will ignore the duplicates. |
46 | | - |
47 | | - If you need to, you can provide every file needed by your application |
48 | | - in _j2sclasslist.txt. However, that is not really necesssary if you are willing to |
49 | | - put the full swingjs/j2s directory on your site, allowing occasional additional |
50 | | - classes to be loaded on demand. It's totally up to you. |
51 | | - |
52 | | - 2. Edit build-core.xml, providing a meaningful core.name parameter, such as "_project". |
53 | | - |
54 | | - 3. Run build-core.xml. This will create the swingjs/j2s/core/ file. |
55 | | - |
56 | | - 4. In your HTML5 file, indicate |
57 | | - |
58 | | - Info = { |
59 | | - ... |
60 | | - core: "_project", |
61 | | - ... |
62 | | - } |
63 | | - |
64 | | - If you change the project template.html file to this and then do a |
65 | | - Project...Clean Build, all the test html files in site/ will be updated. |
66 | | - |
67 | | - That's it! |
68 | | - |
69 | | - If you want to not use the core at any time during testing, add |
70 | | - |
71 | | - ?j2snocore |
72 | | - |
73 | | - to the URL. |
74 | | - |
75 | | - If you want to see all the files being loaded, just to see if anything unexpected |
76 | | - is being loaded, use |
77 | | - |
78 | | - ?j2sverbose |
79 | | - |
80 | | - Any combination of these is fine, either in the query or the # reference: |
81 | | - |
82 | | - ?j2snocore j2sverbose |
83 | | - |
84 | | - or |
85 | | - |
86 | | - #j2snocore,j2sverbose |
87 | | - |
88 | | - for example. |
89 | | -
|
90 | | - Bob Hanson hansonr@stolaf.edu 2015.05.11 |
91 | | - |
92 | | - --> |
93 | | - |
94 | | - <property name="core.name" value="swingjs" /> |
95 | | - |
96 | | - |
97 | | - <property name="j2s.class.list.file" value="_j2sclasslist.txt" /> |
| 2 | + |
98 | 3 | <property name="site.path" value="site/swingjs" /> |
99 | 4 |
|
100 | 5 | <target name="toJs" id="toJs"> |
|
105 | 10 | <delete quiet="true" dir="site" /> |
106 | 11 | --> |
107 | 12 |
|
108 | | - <!-- make core files --> |
| 13 | + <echo>creating swingjs2.js</echo> |
| 14 | + <concat destfile="srcjs/swingjs2.js"> |
| 15 | + <filelist dir="srcjs/js" files="jquery.js,j2sJQueryExt.js,j2sApplet.js,j2sClazz.js,SwingJSApplet.js" /> |
| 16 | + </concat> |
109 | 17 |
|
| 18 | + <echo>copying srcjs files into site</echo> |
| 19 | + <copy todir="site/swingjs"> |
| 20 | + <fileset dir="srcjs"/> |
| 21 | + </copy> |
| 22 | + |
| 23 | + <!-- make core files --> |
| 24 | + |
110 | 25 | <echo>creating and compressing core files - warnings are OK; "does not exist" is trouble</echo> |
111 | | - <echo>reading core class list from file coreclasses</echo> |
| 26 | + |
112 | 27 | <loadresource property="coreclasses"> |
113 | | - <file file="${j2s.class.list.file}"/> |
| 28 | + <file file="_j2sclasslist.txt"/> |
114 | 29 | </loadresource> |
115 | | - <resourcecount property="line.count" count="0" when="eq"> |
116 | | - <tokens> |
117 | | - <concat> |
118 | | - <filterchain> |
119 | | - <tokenfilter> |
120 | | - <stringtokenizer delims="${line.separator}" /> |
121 | | - </tokenfilter> |
122 | | - </filterchain> |
123 | | - <propertyresource name="coreclasses" /> |
124 | | - </concat> |
125 | | - </tokens> |
126 | | - </resourcecount> |
127 | | - <echo message="${j2s.class.list.file} has ${line.count} unique lines" /> |
128 | | - |
129 | | - <!-- not including core/coreswingjs.js --> |
130 | 30 |
|
| 31 | + <echo>copying _j2sclasslist.txt into dist/</echo> |
| 32 | + <copy todir="dist" file="_j2sclasslist.txt" /> |
| 33 | + |
131 | 34 | <antcall target="call-core"> |
132 | | - <param name="call-core.name" value="${core.name}" /> |
| 35 | + <param name="call-core.name" value="swingjs" /> |
133 | 36 | <param name="call-core.list" value=" |
134 | 37 | ${coreclasses} |
135 | 38 | " /> |
136 | 39 | </antcall> |
137 | 40 |
|
138 | | - |
| 41 | + <echo>creating dist/SwingJS-site.zip </echo> |
| 42 | + <zip destfile="dist/SwingJS-site.zip" basedir="site" > |
| 43 | + <exclude name="swingjs/j2s/test/**"/> |
| 44 | + <exclude name="*.html"/> |
| 45 | + </zip> |
| 46 | + |
139 | 47 | </target> |
140 | 48 |
|
141 | 49 |
|
|
159 | 67 | <arg line="--js core${call-core.name}.js --js_output_file core${call-core.name}.z.js" /> |
160 | 68 | </java> |
161 | 69 | <delete quiet="true" file="${site.path}/js/core/tmp.js" /> |
162 | | - <length file="${site.path}/j2s/core/core${call-core.name}.z.js" property="core.length"/> |
163 | | - <echo>... ${site.path}/j2s/core/core${call-core.name}.z.js created [${core.length} bytes]</echo> |
164 | 70 | </target> |
165 | 71 |
|
166 | 72 |
|
|
0 commit comments