Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
98 lines (84 sloc) 3.81 KB
<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>