Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ant Build Tool

5,326 views

Published on

Using Ant with Yahoo Compressor

Published in: Technology
  • Be the first to comment

Ant Build Tool

  1. 1. 06/03/09 HUGE / ParentsConnect / HUGE 45 Main Street, 2nd Floor NY NY 11201 718.625.4843 www.hugeinc.com step-by-step guide Ant Build Tool May 22nd, 2008
  2. 2. Introduction <ul><li>Ant is a Java-based build tool . </li></ul><ul><li>It is kind of like Make , without Make's wrinkles and with the full portability of pure Java code. </li></ul>HUGE / Ant
  3. 3. Prerequisites <ul><li>apache ant ( http://ant.apache.org/ ) </li></ul><ul><li>yui compressor ( http://developer.yahoo.com/yui/compressor/ ) </li></ul><ul><li>yui compressor ant task ( http://code.google.com/p/javaflight-code/ ) </li></ul>HUGE / Ant
  4. 4. Installation <ul><li>download ant binary files, uncompress it, and add bin folder to system path </li></ul><ul><li>download yahoo compressor and copy yuicompressor-x.x.x.jar to ant’s lib folder </li></ul><ul><li>download yahoo compressor ant task and copy yui-compressor-ant-taks-x.x.jar to ant’s lib folder </li></ul>HUGE / Ant
  5. 5. Folder Structure <ul><li>trunk/deploy </li></ul><ul><ul><li>/wwwroot </li></ul></ul><ul><ul><ul><li>/css </li></ul></ul></ul><ul><ul><ul><li>/js </li></ul></ul></ul><ul><ul><ul><li>/img </li></ul></ul></ul><ul><ul><ul><li>/inc </li></ul></ul></ul><ul><ul><li>build.xml </li></ul></ul><ul><ul><li>/wwwroot-compressed </li></ul></ul>HUGE / Ant
  6. 6. 1. Build Script <ul><li><project name=“HUGE&quot; default=&quot;build&quot; basedir=&quot;.&quot;> </li></ul><ul><li><taskdef name=&quot;yui-compressor&quot; classname=&quot;net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask&quot;></taskdef> </li></ul><ul><li><property name=&quot;src&quot; location=&quot; wwwroot &quot;/> </li></ul><ul><li><property name=&quot;build&quot; location=&quot; wwwroot-compressed &quot;/> </li></ul><ul><li>... </li></ul><ul><li></project> </li></ul>HUGE / Ant
  7. 7. 2. Build Script <ul><li><target name=&quot;build&quot; description=&quot;generate the distribution&quot;> </li></ul><ul><li>… </li></ul><ul><li></target> </li></ul>HUGE / Ant
  8. 8. 3. Build Script <ul><li><target name=&quot;compress&quot; depends=&quot;build&quot; description=&quot;compress javascript and css&quot;> </li></ul><ul><li>… </li></ul><ul><li></target> </li></ul>HUGE / Ant
  9. 9. 4. Build Script (clean target) <ul><li><target name=&quot;clean&quot; description=&quot;clean up&quot;> </li></ul><ul><li><delete dir=&quot;${build}&quot;> </li></ul><ul><li><include name=&quot;**/*&quot;/> </li></ul><ul><li></delete> </li></ul><ul><li></target> </li></ul>HUGE / Ant
  10. 10. 5. Build Script (build target) <ul><li><copy todir=&quot;${build}&quot;> </li></ul><ul><li><fileset dir=&quot;${src}&quot; excludes=&quot;css/global/,css/weeks/,js/global/,js/weeks/&quot; /> </li></ul><ul><li></copy> </li></ul><ul><li><concat destfile=&quot;${build}/js/min/weeks.js&quot;> </li></ul><ul><li><fileset dir=&quot;${src}/js/global/&quot;/> </li></ul><ul><li><fileset dir=&quot;${src}/js/weeks/&quot;/> </li></ul><ul><li></concat> </li></ul><ul><li><concat destfile=&quot;${build}/css/min/weeks.css&quot;> </li></ul><ul><li><fileset dir=&quot;${src}/css/global/&quot;/> </li></ul><ul><li><fileset dir=&quot;${src}/css/weeks/&quot;/> </li></ul><ul><li></concat> </li></ul>HUGE / Ant
  11. 11. 6. Build Script (build target) <ul><li><move file=&quot;${build}/inc/weeks/ head-css-min.jsp &quot; </li></ul><ul><li>tofile=&quot;${build}/inc/weeks/ head-css.jsp &quot;/> </li></ul><ul><li><move file=&quot;${build}/inc/weeks/ head-js-min.jsp &quot; </li></ul><ul><li>tofile=&quot;${build}/inc/weeks/ head-js.jsp &quot;/> </li></ul>HUGE / Ant
  12. 12. 7. Build Script (head-css) <ul><li><%@ include file=&quot;inc/weeks/head-css.jsp&quot; %> </li></ul><ul><li><link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/global/01-reset.css&quot; /> </li></ul><ul><li><link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/global/02-font.css&quot; /> </li></ul><ul><li><link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/global/03-global.css&quot; /> </li></ul><ul><li><link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/global/box.css&quot; /> </li></ul><ul><li><link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/global/footer.css&quot; /> </li></ul><ul><li><link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/global/header.css&quot; /> </li></ul><ul><li><link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/min/weeks.css&quot; /> </li></ul><ul><li>(head-css-min.jsp) </li></ul>HUGE / Ant
  13. 13. 8. Build Script (head-js) <ul><li><%@ include file=&quot;inc/weeks/head-js.jsp&quot; %> </li></ul><ul><li><script type=&quot;text/javascript&quot; src=&quot;js/global/0_jquery-1.2.4.min.js&quot;></script> </li></ul><ul><li><script type=&quot;text/javascript&quot; src=&quot;js/weeks/0_ui.core.min.js&quot;></script> </li></ul><ul><li><script type=&quot;text/javascript&quot; src=&quot;js/weeks/1_ui.accordion.min.js&quot;></script> </li></ul><ul><li><script type=&quot;text/javascript&quot; src=&quot;js/weeks/2_ui.tabs.min.js&quot;></script> </li></ul><ul><li><script type=&quot;text/javascript&quot; src=&quot;js/min/weeks.js&quot;></script> </li></ul><ul><li>(head-js-min.jsp) </li></ul>HUGE / Ant
  14. 14. 9. Build Script (compress target) <ul><li><mkdir dir=&quot; ${build}/js/compress &quot;/> </li></ul><ul><li><yui-compressor warn=&quot;false“ munge=&quot;true“ jsSuffix=&quot;.js“ preserveallsemicolons=&quot;false“ </li></ul><ul><li>fromdir=&quot; ${build}/js &quot; todir=&quot; ${build}/js/compress &quot;> </li></ul><ul><li></yui-compressor> </li></ul><ul><li><copy todir=&quot; ${build}/js &quot;> </li></ul><ul><li><fileset dir=&quot; ${build}/js/compress &quot;/> </li></ul><ul><li></copy> </li></ul><ul><li><delete dir=&quot; ${build}/js/compress &quot;/> </li></ul>HUGE / Ant
  15. 15. 10. Build Script (compress target) <ul><li><mkdir dir=&quot; ${build}/css/compress &quot;/> </li></ul><ul><li><yui-compressor warn=&quot;false” munge=&quot;true“ cssSuffix=&quot;.css&quot; </li></ul><ul><li> fromdir=&quot; ${build}/css “ todir=&quot; ${build}/css/compress &quot;> </li></ul><ul><li></yui-compressor> </li></ul><ul><li><copy todir=&quot; ${build}/css &quot;> </li></ul><ul><li><fileset dir=&quot; ${build}/css/compress &quot;/> </li></ul><ul><li></copy> </li></ul><ul><li><delete dir=&quot; ${build}/css/compress &quot;/> </li></ul>HUGE / Ant
  16. 16. Build Sucessfull HUGE / Ant

×