-
Notifications
You must be signed in to change notification settings - Fork 0
/
html5build.xml
98 lines (84 loc) · 3.81 KB
/
html5build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<project name="html5build" default="buildHtml5">
<fail message="sourceDir required" unless="sourceDir"/>
<fail message="outputDir required" unless="outputDir"/>
<fail message="classpath required" unless="classpath"/>
<fail message="minify required" unless="minify"/>
<condition property="minifySet">
<equals arg1="${minify}" arg2="true"/>
</condition>
<path id="classpathId">
<pathelement path="${classpath}"/>
</path>
<mkdir dir="${outputDir}"/>
<target name="htmlConcat">
<!-- Concat all html files into one file -->
<copy file="${sourceDir}/index.html" todir="${outputDir}" overwrite="true"/>
<loadresource property="pages">
<concat>
<fileset dir="${sourceDir}" includes="*.html" excludes="index.html"/>
<footer><![CDATA[</body>]]></footer>
</concat>
</loadresource>
<replace file="${outputDir}/index.html" value="${pages}">
<replacetoken><![CDATA[</body>]]></replacetoken>
</replace>
</target>
<target name="htmlMinify" depends="htmlConcat" if="minifySet">
<java classpathref="classpathId" classname="com.googlecode.htmlcompressor.CmdLineCompressor">
<arg line="${outputDir}/index.html"/>
<arg line="-o ${outputDir}/index.html"/>
</java>
</target>
<target name="jsConcat">
<!-- Concat all javascript files into one file -->
<java classpathref="classpathId" classname="org.mozilla.javascript.tools.shell.Main">
<arg line="${basedir}/misc/requirejs/r.js -o"/>
<arg line="baseUrl=src/main/webapp name=lib/almond"/>
<arg line="include=main mainConfigFile=src/main/webapp/main.js"/>
<arg line="out=${outputDir}/main.js waitSeconds=60 optimize=none"/>
</java>
</target>
<target name="jsMinify" if="minifySet">
<!-- Minify javascript -->
<java classpathref="classpathId" classname="com.google.javascript.jscomp.CommandLineRunner">
<arg line="--js ${outputDir}/main.js"/>
<arg line="--compilation_level SIMPLE_OPTIMIZATIONS"/>
<arg line="--language_in ECMASCRIPT5"/>
<arg line="--js_output_file ${outputDir}/main.min.js"/>
</java>
<move file="${outputDir}/main.min.js" tofile="${outputDir}/main.js" overwrite="true"/>
</target>
<target name="js" depends="jsConcat, jsMinify">
<!-- include generated main.js in index.html -->
<replace file="${outputDir}/index.html">
<replacetoken><![CDATA[src="lib/require.js"]]></replacetoken>
<replacevalue><![CDATA[src="main.js"]]></replacevalue>
</replace>
</target>
<target name="cssConcat">
<!-- Concat all css includes into one file -->
<java classpathref="classpathId" classname="org.mozilla.javascript.tools.shell.Main">
<arg line="${basedir}/misc/requirejs/r.js -o"/>
<arg line="cssIn=src/main/webapp/main.css"/>
<arg line="out=${outputDir}/main.css"/>
</java>
</target>
<target name="cssMinify" if="minifySet">
<java classpathref="classpathId" classname="com.yahoo.platform.yui.compressor.YUICompressor">
<arg line="${outputDir}/main.css"/>
<arg line="-o ${outputDir}/main.css"/>
</java>
</target>
<target name="copyResources">
<copy todir="${outputDir}">
<fileset dir="${sourceDir}" includes="*.xml"/>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<copy todir="${outputDir}">
<fileset dir="${sourceDir}" includes="**/*.gif, **/*.png"/>
</copy>
</target>
<target name="buildHtml5" depends="copyResources, htmlConcat, htmlMinify, js, cssConcat, cssMinify"/>
</project>