|
| 1 | +<project name="swingjs" default="createApps" basedir="."> |
| 2 | + |
| 3 | +<!-- buildTestSite.xml for distribution - for building a test site in a new SwingJS project / --> |
| 4 | + |
| 5 | + |
| 6 | + <target name="createApps" id="createApps"> |
| 7 | + |
| 8 | + <!-- set import.swingjs to false if swingjs project is not checked out or to not use swingjs/zip/swingjs.zip --> |
| 9 | + |
| 10 | + <property name="import.swingjs" value="false"/> |
| 11 | + |
| 12 | + <property name="project.path" value="." /> |
| 13 | + <property name="site.path" value="site/swingjs" /> |
| 14 | + <property name="swingjs.path" value="../swingjs" /> |
| 15 | + <property name="closure.jar" value="tools/closure_compiler.jar" /> |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + <!-- <if> construct needs ant-contrib.jar --> |
| 20 | + <taskdef resource="net/sf/antcontrib/antlib.xml"> |
| 21 | + <classpath> |
| 22 | + <pathelement location="tools/ant-contrib.jar" /> |
| 23 | + </classpath> |
| 24 | + </taskdef> |
| 25 | + |
| 26 | + <!-- create a NON svn local directory only containing JS files --> |
| 27 | + |
| 28 | + <echo>deleting site directory</echo> |
| 29 | + <delete quiet="true" failonerror="false" dir="site" /> |
| 30 | + <mkdir dir="site/tmp" /> |
| 31 | + <mkdir dir="site/tmp/org" /> |
| 32 | + <mkdir dir="site/tmp/com" /> |
| 33 | + <mkdir dir="site/tmp/test" /> |
| 34 | + <mkdir dir="site/tmp/edu" /> |
| 35 | + |
| 36 | + <echo>adding SwingJS project files</echo> |
| 37 | + <if><equals arg1="${import.swingjs}" arg2="true" /><then> |
| 38 | + <echo>...getting ${swingjs.path}/zip/swingjs_core_site.zip</echo> |
| 39 | + <copy file="${swingjs.path}/zip/swingjs_core_site.zip" todir="zip" /> |
| 40 | + </then><else> |
| 41 | + <echo>...using zip/swingjs_core_site.zip</echo> |
| 42 | + </else> |
| 43 | + </if> |
| 44 | + <unzip src="zip/swingjs_core_site.zip" dest="site" /> |
| 45 | + |
| 46 | + <echo>replacing SwingJS.min.js with SwingJS.full.js</echo> |
| 47 | + <copy failonerror="false" file="${site.path}/SwingJS.min.js" |
| 48 | + tofile="${site.path}/js/SwingJS.min.js" /> |
| 49 | + <copy file="${site.path}/js/SwingJS.full.js" |
| 50 | + tofile="${site.path}/SwingJS.min.js" /> |
| 51 | + |
| 52 | + <echo>adding dev files for use without core files</echo> |
| 53 | + <copy todir="site/swingjs" failonerror="false" overwrite="true" > |
| 54 | + <fileset dir="dev"> |
| 55 | + <include name="**/*" /> |
| 56 | + </fileset> |
| 57 | + </copy> |
| 58 | + <replace dir="site/swingjs/j2s/core" includes="package.js" token="(J2S._debugCode)" value="(true)"/> |
| 59 | + |
| 60 | + |
| 61 | +<!-- working here --> |
| 62 | + |
| 63 | + <echo>...adding html files</echo> |
| 64 | + <copy todir="site/swingjs/examples" failonerror="false" overwrite="true" > |
| 65 | + <fileset dir="html"> |
| 66 | + <include name="**/*" /> |
| 67 | + </fileset> |
| 68 | + </copy> |
| 69 | + |
| 70 | + <echo>...fixing Proxy calls (should allow test for this)</echo> |
| 71 | + <replaceregexp match="(\w)Proxy\.(\w+) \(" replace="\1Proxy.$invokeMethod('\2'," flags="g" byline="true" > |
| 72 | + <fileset dir="bin"> |
| 73 | + <include name="**/*.js" /> |
| 74 | + </fileset> |
| 75 | + </replaceregexp> |
| 76 | + |
| 77 | + <echo>...removing initialization code blocks {...} in decorateAsClass calls</echo> |
| 78 | + <replaceregexp match="(Clazz\.decorateAsClass \(function \(\) \{[^{}]*)(\n\{[^{]*\})([^{]*\})" replace="\1\3" flags="g" byline="false" > |
| 79 | + <fileset dir="bin"> |
| 80 | + <include name="**/*.js" /> |
| 81 | + </fileset> |
| 82 | + </replaceregexp> |
| 83 | + |
| 84 | + <echo>...fixing "jsjava" references</echo> |
| 85 | + <replace dir="bin" includes="**/*.js" token="jsjava" value="java" /> |
| 86 | + <replace dir="bin" includes="**/*.js" token="javajs.util" value="JU" /> |
| 87 | + |
| 88 | + <!-- modify class names --> |
| 89 | + |
| 90 | + <echo>...removing j2s globals Class and JavaObject</echo> |
| 91 | + <echo>...replacing Class.forName with Clazz._4Name</echo> |
| 92 | + <replace dir="bin" includes="**/*.js" token="Class.forName" value="Clazz._4Name"/> |
| 93 | + <echo>...replacing JavaObject with Clazz._O</echo> |
| 94 | + <replace dir="bin" includes="**/*.js" token=" JavaObject" value=" Clazz._O"/> |
| 95 | + <echo>...removing all $fz references for sub/superclass common private function names</echo> |
| 96 | + <replace dir="bin" includes="**/*.js" token="($fz =" value=""/> |
| 97 | + <replace dir="bin" includes="**/*.js" token=", $fz.isPrivate = true, $fz)" value=""/> |
| 98 | + |
| 99 | + |
| 100 | + <echo>...abbreviating class name "javajs.util", and "com.jcraft.jzlib" to "JU"</echo> |
| 101 | + <replace dir="bin" includes="**/*.js" token="javajs.util" value="JU"/> |
| 102 | + <replace dir="bin" includes="**/*.js" token="com.jcraft.jzlib" value="JU"/> |
| 103 | + |
| 104 | + <echo>...fixing J2S compiler errors</echo> |
| 105 | + <echo>...replacing "new Boolean" with "Boolean.from" in com, org, and test</echo> |
| 106 | + <replace dir="bin" includes="**/*.js" token="new Boolean" value="Boolean.from"/> |
| 107 | + |
| 108 | + <!-- this will be important when the time comes that classes are combined into a single .z file. --> |
| 109 | + <echo>...changing "^c$ = " to "var c$ ="</echo> |
| 110 | + <replaceregexp match='^c\$\s*=' replace='var c$=' flags="gm" > |
| 111 | + <fileset dir="bin"> |
| 112 | + <include name="**/*.js" /> |
| 113 | + </fileset> |
| 114 | + </replaceregexp> |
| 115 | + <echo>...changing Clazz.pu$h() to Clazz.pu$h(c$)</echo> |
| 116 | + <replace dir="bin" includes="**/*.js" token="pu$h(self.c$)" value="pu$h(c$)"/> |
| 117 | + <replace dir="bin" includes="**/*.js" token="Clazz.pu$h()" value="Clazz.pu$h(c$)"/> |
| 118 | + <replace dir="bin" includes="**/*.js" token="Clazz.pu$h ()" value="Clazz.pu$h(c$)"/> |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + <echo>...copying all bin/*.js to j2s</echo> |
| 123 | + <copy todir="site/tmp" overwrite="true" > |
| 124 | + <fileset dir="bin"> |
| 125 | + <include name="**/*.js" /> |
| 126 | + </fileset> |
| 127 | + </copy> |
| 128 | + |
| 129 | + <echo>...adding to swingjs/j2s non-java files from src (for CalendarData, swingjs.jquery)</echo> |
| 130 | + <copy todir="site/swingjs/j2s" overwrite="true" > |
| 131 | + <fileset dir="src"> |
| 132 | + <include name="**/*" /> |
| 133 | + <exclude name="**/*.java" /> |
| 134 | + </fileset> |
| 135 | + </copy> |
| 136 | + |
| 137 | + |
| 138 | + <copy todir="site/swingjs/j2s" overwrite="true" > |
| 139 | + <fileset dir="site/tmp"> |
| 140 | + <include name="**/*.js" /> |
| 141 | + </fileset> |
| 142 | + </copy> |
| 143 | + |
| 144 | + <echo>deleting site/tmp directory</echo> |
| 145 | + <delete quiet="true" dir="site/tmp" /> |
| 146 | + |
| 147 | + <echo>Compiling is complete. use site/examples/testApp.xml for Java Applications; site/examples/testApplet.xml for Java Applets; </echo> |
| 148 | + |
| 149 | + |
| 150 | + </target> |
| 151 | + |
| 152 | + </project> |
0 commit comments