??xml version="1.0" encoding="utf-8" standalone="yes"?>精品国产不卡,亚洲成人va,亚洲v日韩v综合v精品vhttp://www.aygfsteel.com/tangyong/category/18898.htmlJava,生命中的支柱!zh-cnFri, 02 Mar 2007 18:20:19 GMTFri, 02 Mar 2007 18:20:19 GMT60[译]使用属性去控制构徏QUsing Properties to Control a BuildQ?/title><link>http://www.aygfsteel.com/tangyong/articles/92085.html</link><dc:creator>?x)飞的?/dc:creator><author>?x)飞的?/author><pubDate>Fri, 05 Jan 2007 11:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/tangyong/articles/92085.html</guid><wfw:comment>http://www.aygfsteel.com/tangyong/comments/92085.html</wfw:comment><comments>http://www.aygfsteel.com/tangyong/articles/92085.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/tangyong/comments/commentRss/92085.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/tangyong/services/trackbacks/92085.html</trackback:ping><description><![CDATA[ <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt" align="center"> <b> <span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-size: 12.0pt">[</span> </b> <b> <span style="FONT-SIZE: 14pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">?/span> </b> <b> <span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-size: 12.0pt">]</span> </b> <b> <span style="FONT-SIZE: 14pt; FONT-FAMILY: 'MS UI Gothic'; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">使用属性去控制构徏Q?/span> </b> <b> <i> <span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'MS UI Gothic'">Using Properties to Control a Build</span> </i> </b> <b> <span style="FONT-SIZE: 14pt; FONT-FAMILY: 'MS UI Gothic'; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">Q?/span> </b> <b> <span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'MS UI Gothic'"> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?> <o:p> </o:p> </span> </b> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt" align="center"> <b> <span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'MS UI Gothic'"> <span style="mso-spacerun: yes">                            </span> <span style="mso-spacerun: yes">       </span> </span> </b> <b> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">----</span> </b> <b> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">取自</span> </b> <b> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'"><<Pro Apache Ant>><o:p></o:p></span> </b> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <b> <span lang="EN-US" style="FONT-SIZE: 14pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'MS UI Gothic'"> </span> </b> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">Z(jin)匚w一个复杂的工程QQ何构建都可能变得复杂。但是,你也怸L惌执行构徏的每个部分,或者说如果条g满的话Q你也许惌仅仅执行某个特定的部分。当然你能够通过使用目标依赖来创Z个构建序列,q就意味着你能目标链接v来。用这个机Ӟ你甚臌够集成条Ӟ而这些条件会(x)Dq个构徏q程交叉hQƈ且会(x)创徏不同的发布。例如,CZ应用E序有一?/span> <i> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">stand-alone</span> </i> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">Java</span> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">客户端和Z</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">Web</span> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">的接口,管它们׃n?jin)数据库q接的代码。ؓ(f)q个应用E序的两个部分所做的构徏起始于分这两个部分前的共通代码,而分d决于你所构徏的是哪个部分?br /></span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'"> <br />下图昄?jin)这U情形:(x)</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> <o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"><img height="395" alt="r_1.bmp" src="http://www.aygfsteel.com/images/blogjava_net/tangyong/18999/r_1.bmp" width="581" border="0" /></span></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> </span> <br style="mso-ignore: vglayout" clear="all" /> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">使用依赖来模拟这个构E是_的简单。这P你L可以?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">stand-alone</span> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">目标单地讄</span> <i> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">depends</span> </i> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">Ҏ(gu)(</span> <i> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">attributes</span> </i> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">Q来依赖共通代码的构徏。对?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'">Web</span> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">应用E序目标也是一L(fng)?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> <o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">一个可以替换的Ҏ(gu)是?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'"><target></span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">的最后两个特性:(x)</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">if</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">unless</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">。这两个Ҏ(gu)会(x)影响C个目标是否运行,q且q行与否?x)取决于属性。设|?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">if</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">C个属性名意味着如果属性被讄?jin),那么目标应该会(x)运行。设|?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">unless</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">C个属性名意味着目标应该?x)运行除非该属性被讄?jin)。而该属性有什么值ƈ不重要,只要它被讄?jin)。在</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">Ant</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">中不存在</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">null</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> </span> </p> <hr /> <br style="mso-ignore: vglayout" clear="all" /> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <b> <span lang="EN-US" style="FONT-FAMILY: 'MS UI Gothic'">NOTE </span> </b> <span style="FONT-FAMILY: 'MS UI Gothic'">?/span> <span lang="EN-US" style="FONT-FAMILY: 'MS UI Gothic'; mso-fareast-font-family: 宋体">if</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'MS UI Gothic'; mso-hansi-font-family: 'MS UI Gothic'">?/span> <span lang="EN-US" style="FONT-FAMILY: 'MS UI Gothic'; mso-fareast-font-family: 宋体">unless</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'MS UI Gothic'; mso-hansi-font-family: 'MS UI Gothic'">Ҏ(gu)中讄的值应该是一个属性名Q不是该属性包含的倹{不要?/span> <span lang="EN-US" style="FONT-FAMILY: 'MS UI Gothic'; mso-fareast-font-family: 宋体">${ }</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'MS UI Gothic'; mso-hansi-font-family: 'MS UI Gothic'">Q除非你真的要设|一个属性名作ؓ(f)另一个属性的倹{?/span> <span lang="EN-US" style="FONT-FAMILY: 'MS UI Gothic'; mso-fareast-font-family: 宋体"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /?> <v:line id="_x0000_s1037" style="Z-INDEX: 3; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left; mso-position-horizontal: absolute; mso-position-vertical: absolute" coordsize="21600,21600" to="6in,8.5pt" from="0,8.5pt" strokeweight="2.25pt" strokecolor="#669"> </v:line> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'; mso-fareast-font-family: 'MS UI Gothic'"> </span> </p> <hr /> <br style="mso-ignore: vglayout" clear="all" /> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 'MS UI Gothic'; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">如果</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">if</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">unless</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">都设|了(jin)相同的属性名Q那?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">if</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">?x)重?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">unless</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">Q尽你没有l对的理由想q么做。你也应该要意识到这些设|不?x)?jing)响在</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">depends</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">Ҏ(gu)中目标的运行?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'"> <o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">但是Q应用程序的构徏q不Lq么单。例如,你也许想要获取ƈ构徏W三方的库,只有当你没有它们时。这意味着</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">Ant</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">必L查某个特定的文g是否存在</span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">build</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">目录l构中;如果文g存在Q那?/span> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'">Ant</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">蟩q上图中的前两个步骤。这带来了(jin)控制构徏的第一个元素:(x)</span> <i> <span lang="EN-US" style="FONT-FAMILY: 'Trebuchet MS'"><availabe></span> </i> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Trebuchet MS'; mso-hansi-font-family: 'Trebuchet MS'">?/span> </p> <img src ="http://www.aygfsteel.com/tangyong/aggbug/92085.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/tangyong/" target="_blank">?x)飞的?/a> 2007-01-05 19:22 <a href="http://www.aygfsteel.com/tangyong/articles/92085.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]一个比较完整的ANT实例http://www.aygfsteel.com/tangyong/articles/91479.html?x)飞的?/dc:creator>?x)飞的?/author>Wed, 03 Jan 2007 01:04:00 GMThttp://www.aygfsteel.com/tangyong/articles/91479.htmlhttp://www.aygfsteel.com/tangyong/comments/91479.htmlhttp://www.aygfsteel.com/tangyong/articles/91479.html#Feedback1http://www.aygfsteel.com/tangyong/comments/commentRss/91479.htmlhttp://www.aygfsteel.com/tangyong/services/trackbacks/91479.html代码
  1. <? xml   version = "1.0"   encoding = "gb2312" ?>   
  2. < project   name = "MyProject"   default = "dist"   basedir = "." >     
  3. <!--//name的值改为对应工E的名字   
  4.     //default的值改为需要的~省dQ运?ant"不指明Q务时执行的Q务)(j)   
  5. -- >   
  6.   
  7. <!--File and Directory Names  文g和目录设|?  
  8.   
  9.   app.name             发布到tomcat的应用的名字   
  10.   
  11.   app.version          应用的版本标?  
  12.   
  13.   build.home           ~译目标位置Q默认ؓ(f)"build"   
  14.   
  15.   catalina.home        tomcat根目录位|?  
  16.   
  17.   deploy.home          部v位置Q默认ؓ(f)"${catalina.home}/webapps/${app.name}"   
  18.   
  19.   dist.home            war包位|,默认?dist"   
  20.                        
  21.   
  22. -- >   
  23.   
  24.    < property   name = "app.name"        value = "myapp" />     
  25. <!--//value的值改为发布到tomcat的应用的名字   
  26.     //例如Q?/span> < property   name = "app.name"        value = "mytry" />     
  27. -- >   
  28.    < property   name = "app.version"     value = "1.0" />   
  29.    < property   name = "build.home"      value = "build" />   
  30.    < property   name = "catalina.home"   value = "D:\Tomcat5.0" />     
  31. <!--//value的值改Z安装tomcat的\?  
  32.     //例如Q?/span> < property   name = "catalina.home"   value = "G:\jakarta-tomcat-4.0.1\" />   
  33. -- >   
  34.    < property   name = "deploy.home"     value = "${catalina.home}/webapps/${app.name}" />   
  35.    < property   name = "dist.home"       value = "dist" />   
  36.   
  37. <!--Compilation Control Options ~译控制选项   
  38.   
  39.   compile.debug        是否包含debug信息   
  40.   
  41.   compile.deprecation     
  42.   
  43.   compile.optimize     是否优化~译   
  44.   
  45. -- >   
  46.   
  47.    < property   name = "compile.debug"         value = "true" />   
  48.    < property   name = "compile.deprecation"   value = "false" />   
  49.    < property   name = "compile.optimize"      value = "true" />   
  50.   
  51. <!-- Compilation Classpath 路径讄-->   
  52.   
  53.    < path   id = "compile.classpath" >   
  54.   
  55.      < pathelement   location = "${catalina.home}/common/classes" />   
  56.      < fileset   dir = "${catalina.home}/common/lib" >   
  57.        < include   name = "*.jar" />   
  58.      </ fileset >   
  59.   
  60.    </ path >   
  61.   
  62. <!--Clean Target 删除先前的目录结?->   
  63.   
  64.    < target   name = "clean"   
  65.     description = "Delete old build and dist directories" >   
  66.      < delete   dir = "${build.home}" />   
  67.      < delete   dir = "${dist.home}" />   
  68.    </ target >   
  69.   
  70. <!--Compile Target ~译代码Q在q之前先由prepare建立目录l构-->   
  71.   
  72.    < target   name = "compile"   depends = "prepare"   
  73.     description = "Compile Java sources" >   
  74.   
  75.      <!-- Compile Java classes as necessary -->   
  76.      < mkdir      dir = "${build.home}/WEB-INF/classes" />   
  77.      < javac   srcdir = "src"   
  78.            destdir = "${build.home}/WEB-INF/classes"   
  79.             debug = "${compile.debug}"   
  80.       deprecation = "${compile.deprecation}"   
  81.          optimize = "${compile.optimize}" >   
  82.          < classpath   refid = "compile.classpath" />   
  83.      </ javac >   
  84.   
  85.     
  86.      < copy    todir = "${build.home}/library/classes" >   
  87.      < fileset   dir = "src"   includes = "**/*.properties" />   
  88.      </ copy >   
  89.   
  90.    </ target >   
  91.   
  92. <!--Deploy Target 在tomcat下徏立应用目录ƈ部v应用-->   
  93.   
  94.    < target   name = "deploy"   depends = "compile"   
  95.     description = "Deploy application to servlet container" >   
  96.   
  97.      <!-- Copy the contents of the build directory -->   
  98.      < mkdir       dir = "${deploy.home}" />   
  99.      < copy      todir = "${deploy.home}" >   
  100.        < fileset   dir = "${build.home}" />   
  101.      </ copy >   
  102.   
  103.      < mkdir    dir = "${deploy.home}/WEB-INF/lib" />   
  104.   
  105.    </ target >   
  106.   
  107. <!--Dist Target 应用打包成warQ在q之前先执行javadoc和deploy-->   
  108.   
  109.    < target   name = "dist"   depends = "deploy,javadoc"   
  110.     description = "Create binary distribution" >   
  111.   
  112.      < copy      todir = "${dist.home}/docs" >   
  113.        < fileset   dir = "docs" />   
  114.      </ copy >   
  115.   
  116.      < jar   jarfile = "${dist.home}/${app.name}.war"   
  117.           basedir = "${deploy.home}" />   
  118.   
  119.    </ target >   
  120.   
  121. <!--Javadoc Target 生成javadoc-->   
  122.   
  123.    < target   name = "javadoc"   depends = "compile"   
  124.     description = "Create Javadoc API documentation" >   
  125.   
  126.      < mkdir            dir = "${dist.home}/docs/api" />   
  127.      < javadoc   sourcepath = "src"   
  128.                  destdir = "${dist.home}/docs/api"   
  129.             packagenames = "hello.*" />   
  130. <!--//改ؓ(f)需要制作javadoc的包名。如果不做javadocQ这里不必改。例如:(x)packagenames="hello.*"/>-->   
  131.    </ target >   
  132.   
  133. <!--Prepare Target 建立打包的目的目录结?->   
  134.   
  135.    < target   name = "prepare" >   
  136.   
  137.      < mkdir    dir = "${build.home}" />   
  138.      < copy   todir = "${build.home}" >   
  139.        < fileset   dir = "web" />   
  140.      </ copy >   
  141.    </ target >   
  142. </ project >   



]]>
[转蝲]利用 Ant ?JUnit q行增量开?/title><link>http://www.aygfsteel.com/tangyong/articles/91360.html</link><dc:creator>?x)飞的?/dc:creator><author>?x)飞的?/author><pubDate>Tue, 02 Jan 2007 05:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/tangyong/articles/91360.html</guid><wfw:comment>http://www.aygfsteel.com/tangyong/comments/91360.html</wfw:comment><comments>http://www.aygfsteel.com/tangyong/articles/91360.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/tangyong/comments/commentRss/91360.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/tangyong/services/trackbacks/91360.html</trackback:ping><description><![CDATA[     摘要: 利用 Ant ?JUnit q行增量开? 使用单元试来逐步改进代码   ...  <a href='http://www.aygfsteel.com/tangyong/articles/91360.html'>阅读全文</a><img src ="http://www.aygfsteel.com/tangyong/aggbug/91360.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/tangyong/" target="_blank">?x)飞的?/a> 2007-01-02 13:04 <a href="http://www.aygfsteel.com/tangyong/articles/91360.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转蝲]Ant 十五大最?jng)_?/title><link>http://www.aygfsteel.com/tangyong/articles/91351.html</link><dc:creator>?x)飞的?/dc:creator><author>?x)飞的?/author><pubDate>Tue, 02 Jan 2007 03:56:00 GMT</pubDate><guid>http://www.aygfsteel.com/tangyong/articles/91351.html</guid><wfw:comment>http://www.aygfsteel.com/tangyong/comments/91351.html</wfw:comment><comments>http://www.aygfsteel.com/tangyong/articles/91351.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/tangyong/comments/commentRss/91351.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/tangyong/services/trackbacks/91351.html</trackback:ping><description><![CDATA[ <h2> <strong>ANT</strong> <strong>十五大最?jng)_?/strong> <strong> </strong> </h2> <p>作者:(x)<a >Eric M. Burke</a>, coauthor of <a >Java Extreme Programming Cookbook</a></p> <p>原文Q?a >http://www.onjava.com/pub/a/onjava/2003/12/17/ant_bestpractices.html</a></p> <p>译者:(x)徐T<a href="msn:xt121@hotmail.com">MSN:xt121@hotmail.com</a></p> <p> </p> <p>在Ant出现之前Q构建和部vJava应用需要用包括特定^台的脚本、Make文g、各U版本的IDE甚至手工操作的“大杂烩”。现在,几乎所有的开源Java目都在使用AntQ大多数公司的内部项目也在用Ant。Ant在这些项目中的广泛用自然导致了(jin)读者对一整套Ant最?jng)_늚q切需求?/p> <p>本文ȝ?jin)我喜爱的Ant技巧或最?jng)_践,多数是从我亲w经历的目错误或我听说的其他hl历?“恐怖”故事中得到灉|的。比如,有h告诉我有个项目把XDoclet 生成的代码放入带有锁定文件功能的版本控制工具中。当开发者修Ҏ(gu)代码Ӟ他必记住手工检出(Check outQƈ锁定所有将要重新生成的文g。然后,手工q行代码生成器,只到q时他才能够让Ant~译代码Q这一Ҏ(gu)q存在如下一些问题:(x)</p> <ul> <li>生成的代码无法存储在版本控制pȝ中? </li> <li>AntQ本案例中是XdocletQ应该自动确定下一ơ构建涉?qing)的源文Ӟ而不应由E序员手工确定? </li> <li>Ant的构建文件应该定义好正确的Q务依赖关p,q样E序员就不必Z(jin)完成构徏而不得不按照特定序调用d?</li> </ul> <p>当我开始一个新目Ӟ我首先编写Ant构徏文g。Ant文g明确地定义构建的q程Qƈ被团队中的每个程序员使用。本文所列的技巧基于这L(fng)假定QAnt构徏文g是一个必Ml编写的重要文gQ它应在版本控制pȝ中得到维护,q被定期q行重构。下面是我的十五大Ant最?jng)_c(din)?/p> <h3>1. 采用一致的~码规范</h3> <p>Ant用户有的喜欢有的痛恨其构建文件的XML语法。与其蟩q这一令hqh的争ZQ不如让我们先看一些能保持XML构徏文gz的Ҏ(gu)?/p> <p>首先也是最重要的,p旉格式化你的XML让它看上d清晰。不论XML是否观QAnt都可以工作。但是丑陋的XML很难令hL。倘若你在d之间留出IQ有规则的羃q,每行文字不超q?0列左叻I那么XML令h惊讶地易诅R再加上使用能够高亮XML语法的优U~辑器或IDE工具Q你׃?x)有阅读的麻烦(ch)?/p> <p>同样Q精选含意明、容易读懂的词汇来命名Q务和属性。比如,<em>dir.reports</em>比<em>rpts</em>?em>?/em>特定的编码规范ƈ不重要,只要拿出一套规范ƈ坚持使用p?/p> <h3>2. ?em>build.xml</em>攑֜目根目录中</h3> <p>Ant构徏文g<em>build.xml</em>可以攑֜M位置Q但是放在项目顶U目录中可以保持目z。这是最常用的规范,开发者能够在目录中找到预期的<em>build.xml</em>。把构徏文g攑֜根目录中Q也能够使hҎ(gu)?jin)解目目录树(wi)中不同目录之间的逻辑关系。以下是一个典型的目目录层次Q?/p> <p>[root dir]<br />  | build.xml  <br />  +--src <br />  +--lib (包含W三?JAR? <br />  +--build (?buildd生成)  <br />  +--dist (?buildd生成) </p> <p>?em>build.xml</em>在顶U目录时Q假设你处于目某个子目录中Q只要输入:(x)ant -find compile 命o(h)Q不需要改变工作目录就能够以命令行方式~译代码。参?find告诉AntL存在于上U目录中?em>build.xml</em>q执行?/p> <h3>3. 使用单一的构建文?/h3> <p>有h喜欢一个大目分解成几个小的构建文Ӟ每个构徏文g分担整个构徏q程的一部分工作。这实是看法不同的问题Q但是应该认识到Q将构徏文g分割?x)增加对整体构徏q程的理解难度。要注意在单一构徏文g能够清楚表现构徏层次的情况下不要q工E化(over-engineer)?/p> <p>即你把目划分为多个构建文Ӟ也应使程序员能够在项目根目录下找到核?em>build.xml</em>。尽该文g只是实际构建工作委z下构徏文gQ也应保证该文g可用?/p> <h3>4. 提供良好的帮助说?/h3> <p>应尽量构徏文g自文档化。增加Q务描q是最单的Ҏ(gu)。当你输入ant -projecthelpӞ你就可以看到带有描述的Q务清单。比如,你可以这样定义Q务:(x)</p><target name="compile"  <br />   description="Compiles code, output goes to the build dir."> <p>最单的规则是把所有你惌E序员通过命o(h)行就可以调用的Q务都加上描述。对于一般用来执行中间处理过E的内部dQ比如生成代码或建立输出目录{,无法用描q属性?/p><p>q时Q可以通过在构建文件中加入XML注释来处理。或者专门定义一个helpdQ当E序员输入ant help时来昄详细的用说明?/p><target name="help" description="Display detailed usage information"><br />  <echo>Detailed help...</echo></target> <h3>5. 提供清除d</h3><p>每个构徏文g都应包含一个清除Q务,用来删除所有生成的文g和目录,使系l回到构建文件执行前的初始状态。执行清IZQ务后q存在的文g都应处在版本控制pȝ的管理之下。比如:(x)</p><target name="clean" <br />    description="Destroys all generated files and dirs."><br />  <delete dir="${dir.build}"/><br />  <delete dir="${dir.dist}"/><br /></target> <p>除非是在产生整个pȝ版本的特DQ务中Q否则不要自动调用cleand。当E序员仅仅执行编译Q务或其他dӞ他们不需要构建文件事先执行既令h讨厌又没有必要的清空d。要怿E序员能够确定何旉要清I所有文件?/p><h3>6. 使用ANT理d从属关系</h3><p>假设你的应用由Swing GUIlg、Web界面、EJB层和公共应用代码l成。在大型pȝ中,你需要清晰地定义每个Java包属于系l的哪一层。否则Q何一点修攚w要被q重新编译成百上千个文g。糟p的d从属关系理?x)导致过度复杂而脆qpȝ。改变GUI面板的设计不应造成Servlet和EJB的重~译?/p><p>当系l变得庞大后Q稍不注意就可能依赖于客户端的代码引入到服务端。这是因为典型的IDE目文g~译M文g都用单一的classpath。而Ant能让你更有效地控制构建活动?/p><p>设计你的Ant构徏文g~译大型目的步骤:(x)首先Q编译公共应用代码,编译结果打成JAR包文件。然后,~译上一层的目代码Q编译时依靠W一步生的JAR文g。不断重复这一q程Q直到最高层的代码编译完成?/p><p>分步构徏强化?jin)Q务从属关pȝ理。如果你工作在底层Java框架上,偶然引用到高层的GUI模板lgQ这时代码不需要编译。这是由于构建文件在~译底层框架时在源\径中没有包含高层GUI面板lg的代码?/p><h3>7. 定义q用文件\?/h3><p>如果文g路径在一个地方一ơ性集中定义,q在整个构徏文g中得到重用,那么构徏文g更易于理解。以下是q样做的一个例子:(x)</p><project name="sample" default="compile" basedir="."><br />  <path id="classpath.common"><br />    <pathelement location="${jdom.jar.withpath}"/><br />    ...etc  </path><br />  <path id="classpath.client"><br />    <pathelement location="${guistuff.jar.withpath}"/><br />    <pathelement location="${another.jar.withpath}"/><br />    <!-- reuse the common classpath --><br />    <path refid="classpath.common"/><br />  </path><br />  <target name="compile.common" depends="prepare"><br />    <javac destdir="${dir.build}" srcdir="${dir.src}"><br />          <classpath refid="classpath.common"/><br />          <include name="com/oreilly/common/**"/><br />    </javac><br />  </target><br /></project> <p>当项目不断增长构建日益复杂时Q这一技术越发体现出其h(hun)倹{你可能需要ؓ(f)~译不同层次的应用定义各自的文g路径Q比如运行单元测试的、运行应用程序的、运行Xdoclet的、生成JavaDocs的等{不同\径。这U组件化路径定义的方法比为每个Q务单独定义\径要优越得多。否则,很容易丢׃Q务从属关pȝ轨迹?/p><h3>8. 定义恰当的Q务从属关p?/h3><p>假设distd从属于jardQ那么哪个Q务从属于compiled哪个d从属于prepared呢?Ant构徏文g最l定义了(jin)d的从属关pdQ它必须被仔l地定义和维护?/p><p>应该定期(g)查Q务的从属关系以保证构建工作得到正执行。大的构建文仉着旉推移向于增加更多的dQ所以到最后可能由于不必要的从属关pd致构建工作非常困难。比如,你可能发现在E序员只需~译一些没有用EJB的GUI代码时又重新生成?jin)EJB代码?/p><p>以“优化”的名义忽略d的从属关pL另一U常见的错误。这U错误迫使程序员Z(jin)得到恰当的结果必记住ƈ按照特定的顺序调用一串Q务。更好的做法是:(x)提供描述清晰的公׃Q务,q些d包含正确的Q务从属关p;另外提供一套“专家”Q务让你能够手工执行个别的构徏步骤Q这些Q务不提供完整的构E,但是让那些专家用户在快速而恼人的~码期间能够跌某些步骤?/p><h3>9.使用属?/h3><p>M需要配|或可能发生变化的信息都应作为Ant属性定义下来。对于在构徏文g中多ơ出现的g同样处理。属性既可以在构建文件头部定义,也可以ؓ(f)?jin)更好的灉|性而在单独的属性文件中定义。以下是在构建文件中定义属性的样式Q?/p><project name="sample" default="compile" basedir="."><br />  <property name="dir.build" value="build"/><br />  <property name="dir.src" value="src"/><br />  <property name="jdom.home" value="../java-tools/jdom-b8"/><br />  <property name="jdom.jar" value="jdom.jar"/><br />  <property name="jdom.jar.withpath"<br />                    value="${jdom.home}/build/${jdom.jar}"/><br />    etc...<br /></project> <p>或者你可以使用属性文Ӟ(x)</p><project name="sample" default="compile" basedir="."><br />  <property file="sample.properties"/><br />   etc...<br /></project> <p>在属性文?<em>sample.properties</em>?</p>dir.build=build<br />dir.src=src<br />jdom.home=../java-tools/jdom-b8<br />jdom.jar=jdom.jarjdom.jar.withpath=${jdom.home}/build/${jdom.jar} <p>用一个独立的文g定义属性是有好处的Q它可以清晰地定义构Z的可配置部分。另外,在开发者工作在不同操作pȝ的情况下Q你可以在不同的q_上提供该文g的不同版本?/p><h3>10. 保持构徏q程独立</h3><p>Z(jin)最大限度的扩展性,不要应用外部路径和库文g。最重要的是不要依赖于程序员的CLASSPATH讄。取而代之的是,在构建文件中使用相对路径q定义自q路径。如果你引用?jin)绝对\径如<em>C:\java\tools</em>Q其他开发者未必用与你相同的目录l构Q所以就无法使用你的构徏文g?/p><p>如果你部|开放源码项目,应该提供包含~译代码所需的所有JAR文g的发行版本。当?dng)q是在遵守许可协议的基础上。对于内部项目,相关的JAR文g都应在版本控制系l的理中,q捡出(check outQ到大家都知道的位置?/p><p>当你必须引用外部路径Ӟ应将路径定义为属性。ɽE序员能够用适合他们自己的机器环境的参数重蝲q些属性。你也可以用以下语法引用环境变量:(x)</p><property environment="env"/><br /><property name="dir.jboss" value="${env.JBOSS_HOME}"/> <h3>11. 使用版本控制pȝ</h3><p>构徏文g是一个重要的制品Q应该像代码一栯行版本控制。当你标C的代码时Q也应用同样的标{标记构建文件。这样当你需要回溯到旧版本ƈq行构徏Ӟ能够使用相应版本的构建文件?/p><p>除构建文件之外,你还应在版本控制中维护第三方JAR文g。同Pq你能够重新构建旧版本的Y件。这也能够更Ҏ(gu)保证所有开发者拥有一致的JAR文gQ因Z们都是同构徏文g一起从版本控制pȝ中捡出的?/p><p>通常应避免在版本控制pȝ中存放构建成果。倘若你的源代码很好地得到?jin)版本控Ӟ那么通过构徏q程你能够重新生成Q何版本的产品?/p><h3>12. 把Ant作ؓ(f)“最公分母?/h3><p>假设你的开发团队用IDE工具Q当E序员通过点击图标p够构建整个应用时Z么还要ؓ(f)Ant而烦(ch)恼呢Q?/p><p>IDE的问题是一个关于团队一致性和重现性的问题。几乎所有的IDE设计初衷都是Z(jin)提高E序员的个h生率,而不是开发团队的持箋构徏。典型的IDE要求每个E序员定义自q目文g。程序员可能拥有不同的目录结构,可能使用不同版本的库文gQ还可能工作在不同的q_上。这导致出现这U情况:(x)在Bob那里q行良好的代码,到Sally那里无法运行?/p><p>不管你的开发团队用何UIDEQ一定要建立所有程序员都能够用的Ant构徏文g。要建立一个程序员在将C码提交版本控制系l前必须执行Ant构徏文g的规则。这确保代码是l过同一个Ant构徏文g构徏的。当出现问题Ӟ要用项目标准的Ant构徏文gQ而不是通过某个IDE来执行一个干净的构建?/p><p>E序员可以自由选择M他们?fn)惯使用的IDE工具或编辑器。但是Ant应作为公共基U以保证代码永远是可构徏的?/p><h3>13. 使用zipfileset属?/h3><p>Zl常使用Ant产生WAR、JAR、ZIP?EAR文g。这些文仉常都要求有一个特定的内部目录l构Q但其往往与你的源代码和编译环境的目录l构不匹配?/p><p>一个最常用的方法是写一个AntdQ按照期望的目录l构把一大堆文g拯C(f)时目录中Q然后生成压~文件。这不是最有效的方法。用zipfileset属性是更好的解x案。它让你从Q何位|选择文gQ然后把它们按照不同目录l构放进压羃文g中。以下是一个例子:(x)</p><ear earfile="${dir.dist.server}/payroll.ear"<br />    appxml="${dir.resources}/application.xml"><br />  <fileset dir="${dir.build}" includes="commonServer.jar"/><br />  <fileset dir="${dir.build}"><br />    <include name="payroll-ejb.jar"/><br />  </fileset><br />  <zipfileset dir="${dir.build}" prefix="lib"><br />    <include name="hr.jar"/><br />    <include name="billing.jar"/><br />  </zipfileset><br />  <fileset dir="."><br />    <include name="lib/jdom.jar"/><br />    <include name="lib/log4j.jar"/><br />    <include name="lib/ojdbc14.jar"/><br />  </fileset><br />  <zipfileset dir="${dir.generated.src}" prefix="META-INF"><br />    <include name="jboss-app.xml"/><br />  </zipfileset><br /></ear> <p>在这个例子中Q所有JAR文g都放在EAR文g包的<em>lib</em>目录中。hr.jar和billing.jar是从构徏目录拯q来的。因此我们用zipfileset属性把它们Ud到EAR文g包内部的<em>lib</em>目录。prefix属性指定了(jin)其在EAR文g中的目标路径?/p><h3>14. 试Cleand</h3><p>假设你的构徏文g中有clean和compile的Q务,执行以下的测试。第一步,执行ant cleanQ第二步Q执行ant compileQ第三步Q再执行ant compile。第三步应该不作M事情。如果文件再ơ被~译Q说明你的构建文件有问题?/p><p>构徏文g应该只在与输出文件相兌的输入文件发生变化时执行d。一个构建文件在不必执行诸如~译、拷贝或其他工作d的时候执行这些Q务是低效的。当目规模增长Ӟ即是小的低效工作也?x)成为大的问题?/p><h3>15. 避免特定q_的Ant装</h3><p>不管什么原因,有h喜欢用简单的、名U叫?em>compile</em>之类的批文g或脚本装载他们的产品。当你去看脚本的内容你会(x)发现以下内容Q?/p><p>ant compile</p><p>其实开发h员都很熟(zhn)AntQƈ且完全能够自己键入ant compile。请不要仅仅Z(jin)调用Ant而用特定^台的脚本。这只会(x)使其他h在首ơ用你的脚本时增加学习(fn)和理解的?ch)扰。除此之外,你不可能提供适用于每个操作系l的脚本Q这是真正烦(ch)扰其他用L(fng)地方?/p><h3>ȝ</h3><p>太多的公怾靠手工方法和特别E序来编译代码和生成软g发布版本。那些不使用Ant或类似工具定义构E的开发团队,p?jin)太多的旉来捕捉代码编译过E中出现的问题:(x)在某些开发者那里编译成功的代码Q到另一些开发者那里却p|?jin)?/p><p>生成q维护构本不是一富有魅力的工作Q但却是一必需的工作。一个好的Ant构徏文g你能够集中到更喜Ƣ的工作——写代码中去Q?/p><h3>参?/h3><ul><li><a >Ant</a></li><li><a >AntGraph</a>: Ant依赖性的可视化工? </li><li><a >Ant: The Definitive Guide</a>, O'Reilly </li><li><a >Java Extreme Programming Cookbook</a>, O'Reilly</li></ul><img src ="http://www.aygfsteel.com/tangyong/aggbug/91351.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/tangyong/" target="_blank">?x)飞的?/a> 2007-01-02 11:56 <a href="http://www.aygfsteel.com/tangyong/articles/91351.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˫</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ݰ</a>| <a href="http://" target="_blank">ʯ</a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">ػ</a>| <a href="http://" target="_blank">书</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͷ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">С</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">۽</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ļ</a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank">̩˳</a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank">˳</a>| <a href="http://" target="_blank">ľ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ű</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>