Because the project uses a lot of JS, in order to improve system efficiency, JS do compression processing.
Successful compression of more than one JS, you must go through the following two steps.
1. Merge multiple JS to become a JS.
2. Will and and after the JS compression processing.
The main ant configurations used are:
Copy Code code as follows:
<property name= "root" value= "WebRoot" ></property>
<property name= "JS" value= "${root}/js" ></property>
<property name= "Map_function_js" value= "${js}/mapfunc" ></property>
<property name= "Lib" value= "Lib"/>
<property name= ' build ' value= ' Build ' ></property>
<property name= "war" value= "war" ></property>
<property name= "War.info" value= "${war}/web-inf" ></property>
<property name= "War.lib" value= "${war.info}/lib" ></property>
<property name= "war.classes" value= "${war.info}/classes" ></property>
<property name= "Project.name" value= "Zjmap" ></property>
<property name= "CharSet" value= "Utf-8"/>
<property name= "src" value= "src"/>
<target name= "Create build Directory" >
<mkdir dir= "${build}"/>
</target>
Copy Code code as follows:
<!--to merge multiple js into a JS-->
<target name= "Merge js" depends= "Create build Directory" >
<concat destfile= "${build}/mapfuncall.js" encoding= "${charset}" outputencoding= "${charset}" >
<path path= "${map_function_js}/dc.js"/>
<path path= "${map_function_js}/stringutil.js"/>
<path path= "${map_function_js}/localdc.js"/>
<path path= "${map_function_js}/screen.js"/>
<path path= "${map_function_js}/wfsquery.js"/>
<path path= "${map_function_js}/map.js"/>
<path path= "${map_function_js}/query.js"/>
<path path= "${map_function_js}/classificationquery.js"/>
<path path= "${map_function_js}/busquery.js"/>
<path path= "${map_function_js}/routequery.js"/>
<path path= "${map_function_js}/cursorposition.js"/>
<path path= "${map_function_js}/bufferanalysis.js"/>
<path path= "${map_function_js}/divctrl.js"/>
<path path= "${map_function_js}/mark.js"/>
<path path= "${map_function_js}/overlayanalysis.js"/>
<path path= "${map_function_js}/buildquery.js"/>
<path path= "${map_function_js}/popshow.js"/>
<path path= "${map_function_js}/correct.js"/>
<path path= "${map_function_js}/style_result.js"/>
<path path= "${map_function_js}/style_ui.js"/>
<path path= "${map_function_js}/catalog.js"/>
<path path= "${map_function_js}/scenario.js"/>
<path path= "${map_function_js}/wfs.js"/>
<path path= "${map_function_js}/uuid.js"/>
<path path= "${map_function_js}/gps.js"/>
<path path= "${map_function_js}/typhoon.js"/>
<path path= "${map_function_js}/monitor.js"/>
<path path= "${map_function_js}/rainwater.js"/>
<path path= "${map_function_js}/approval.js"/>
<path path= "${map_function_js}/statistics.js"/>
<path path= "${map_function_js}/statisticsnew.js"/>
<path path= "${map_function_js}/otilecachecustom.js"/>
<path path= "${map_function_js}/bqtool.js"/>
<path path= "${map_function_js}/citypositionquery.js"/>
<path path= "${map_function_js}/ifieldservice.js"/>
<path path= "${map_function_js}/specialquery.js"/>
</concat>
<replaceregexp match= "@DEBUG @" replace= "" flags= "G" byline= "true" file= "${build}/mapfuncall.js" encoding= "${ CharSet} "/>
</target>
<!--use Yahoo UI for JS compression-->
<target name= "start compression" depends= "Merge js" >
<!--using Yahoo UI compression Mapfuncall.js-->
<antcall target= "Compressed Mapfuncall.js" ></antcall>
<!--using Yahoo UI compression Dataedit.js-->
<antcall target= "Compressed Dataedit.js" ></antcall>
<!--using Yahoo UI compression Isuggest.js-->
<antcall target= "Compressed Isuggest.js" ></antcall>
<!--Copy the compressed JS file-->
<antcall target= "Copy compressed JS file" ></antcall>
</target>
<target name= "Compressed Mapfuncall.js" >
<java jar= "${lib}/yui/yuicompressor-2.4.6.jar" fork= "true" >
<arg line= "--type js--charset utf-8 ${map_function_js}/mapfuncall.js-o ${build}/mapfuncall-min.js"/>
</java>
</target>
<target name= "Compressed Dataedit.js" >
<java jar= "${lib}/yui/yuicompressor-2.4.6.jar" fork= "true" >
<arg line= "--type js--charset utf-8 ${map_function_js}/dataedit.js-o ${build}/dataedit-min.js"/>
</java>
</target>
<target name= "Compressed Isuggest.js" >
<java jar= "${lib}/yui/yuicompressor-2.4.6.jar" fork= "true" >
<arg line= "--type js--charset utf-8 ${map_function_js}/isuggest.js-o ${build}/isuggest-min.js"/>
</java>
</target>
<target name= "Clear build Directory" depends= "start Compression" >
<delete dir= "${build}"/>
</target>
<target name= "Copy compressed JS file" >
<copy todir= "${map_function_js}" >
<fileset dir= "${build}" >
<include name= "**.js"/>
</fileset>
</copy>
</target>