Jalview-JS/JAL-3253-applet Creating
[jalview.git] / buildcore.xml
1 <project name="JSmol" default="toJs" basedir=".">
2
3   <taskdef resource="net/sf/antcontrib/antcontrib.properties">
4     <classpath>
5       <pathelement location="./utils/ant-contrib-1.0b3.jar" />
6     </classpath>
7   </taskdef>
8
9   <target name="build-all-cores" id="build-all-cores" depends="toJs">
10     <foreach target="CallToJs" param="classlist">
11       <path>
12         <fileset dir="./classlists/" includes="*.txt" />
13       </path>
14     </foreach>
15   </target>
16
17   <target name="CallToJs" id="CallToJs" description="Don't call this directly - used by build-all-cores to configure the toJs task for each set of classes in classlist">
18     <basename property="core.name.txt" file="${classlist}"/>
19     <propertyregex property="core.name" input="${core.name.txt}" replace="" regexp="\.txt"/>
20     <antcall target="toJs"/>
21   </target>
22
23   <target name="toJs" id="toJs">
24     <!-- sensible defaults for default target -->
25     <property name="site" value="site"/>
26     <property name="site.path" value="${site}/swingjs" />
27     <property name="core.name" value="_jalview" />
28     <property name="classlist"  
29       description="Class list .txt generated by java2script classloader to be bundled into corefile - default is _j2sclasslist.txt" 
30       value="_j2sclasslist.txt" />
31     <!-- create a NON svn local directory only containing JS files
32         
33         <echo>Deleting the site directory.</echo>
34                 <delete quiet="true" dir="site" />
35     -->
36
37         
38         <!-- concatentate the stevesoft files -->
39     <concat destfile="${site.path}/j2s/com/stevesoft/core.js">
40         <fileset dir="${site.path}/j2s/com/stevesoft">
41           <include name="**/*.js" />
42                 <exclude name="core.js" />
43                 <exclude name="Regex.js" />
44         </fileset>
45     </concat>
46     <antcall target="call-core">
47       <param name="call-core.name" value="_stevesoft" />
48       <param name="call-core.list" value="com/stevesoft/core.js" />
49     </antcall>
50
51         
52     <!-- make core files -->
53
54     <echo>Building core file '${core.name}' - warnings are OK; "does not exist" is trouble</echo>
55     <echo>Reading core class list from file ${classlist}</echo>
56     <loadresource property="coreclasses">
57       <file file="${classlist}"/>
58     </loadresource>
59
60     <antcall target="call-core">
61       <param name="call-core.name" value="${core.name}" />
62       <param name="call-core.list" value="
63                         core/coreswingjs.js
64                 ${coreclasses}
65                 " />
66     </antcall>
67     <antcall target="publish-core-template"/>
68   </target>
69
70   <target name="publish-core-template" id="publish-core-template" description="Creates a new file ${template.name}_${core.name} from ${template.html} in ${site} which include core file ${core.name} in the Info block">
71     <!-- TODO: extend to process all html templates -->
72     <property name="template.html" value="jalview_bin_Jalview.html"/>
73     <property name="template.name" value="JalviewJS"/>
74
75     <echo>......Now copying ${site}/${template.html} as ${$template.name}_${core.name}.html with core:"${core.name}", added to the Info block.</echo>
76     <copy file="${site}/${template.html}" tofile="${site}/${template.name}_${core.name}.html"/>
77     <replace token="NONE" value="${core.name}" file="${site}/${template.name}_${core.name}.html"/>
78
79   </target>
80
81
82   <target name="call-core" id="call-core">
83     <echo>......Creating core${call-core.name}.js</echo>
84     <concat destfile="${site.path}/js/core/tmp.js">
85       <filelist dir="${site.path}/j2s" files="${call-core.list}" />
86     </concat>
87
88     <replace dir="${site.path}/js/core" includes="tmp.js" token="Clazz." value="Clazz_"/>
89     <replace dir="${site.path}/js/core" includes="tmp.js" token="Clazz__" value="Clazz._"/>
90     <echo>......Generating ${site.path}/j2s/core/core${call-core.name}.js</echo>
91     <concat destfile="${site.path}/j2s/core/core${call-core.name}.js">
92       <filelist dir="${site.path}/js" files="
93                         core/coretop2.js
94                         core/tmp.js
95                         core/corebottom2.js
96                         " />
97     </concat>
98     <echo>......Generating ${site.path}/j2s/core/core${call-core.name}.z.js</echo>
99     <java jar="tools/closure_compiler.jar" fork="true" dir="${site.path}/j2s/core" failonerror="false">
100       <arg line="--js core${call-core.name}.js --js_output_file core${call-core.name}.z.js" />
101     </java>
102     <delete quiet="true" file="${site.path}/js/core/tmp.js" />
103   </target>
104
105
106
107 </project>