<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Weiqi Gao&#039;s Observations - ant tag</title>
  <link>http://www.weiqigao.com/blog/tags/ant/</link>
  <description>Sharing My Experience...</description>
  <language>en</language>
  <copyright>Weiqi Gao</copyright>
  <lastBuildDate>Fri, 11 May 2012 12:48:36 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  <image>
    <url>http://pebble.sourceforge.net/common/images/powered-by-pebble.gif</url>
    <title>Weiqi Gao&#039;s Observations</title>
    <link>http://www.weiqigao.com/blog/</link>
  </image>
  
  
  <item>
    <title>Breaking Version Inertia: Ant: import and macrodef</title>
    <link>http://www.weiqigao.com/blog/2008/04/14/breaking_version_inertia_ant_import_and_macrodef.html</link>
    
      
        <description>
          &lt;p&gt;I&#039;ve been using Ant since the very early days.  (&#034;Tomcat is built with Ant.  What is Ant?&#034;  Remember those days?)  Since my use of ant does not usually involve anything esoteric, I have fallen victim to &lt;a href= &#034;http://www.weiqigao.com/blog/2004/08/17/software_version_inertia.html&#034; &gt;version inertia&lt;/a&gt;.  Ant 1.4, 1.5, 1.6, 1.7 came out over the years, and I didn&#039;t much glance at the release notes.&lt;/p&gt;

&lt;p&gt;Meanwhile, some of my &lt;tt&gt;build.xml&lt;/tt&gt; files has grown organically.  Since the code is modularized with a nice &#034;B depends on A, C depends on B, etc...&#034; structure, the &lt;tt&gt;build.xml&lt;/tt&gt; reflects that with targets like &#034;compile-A&#034;, &#034;compile-A-test&#034;, &#034;run-A-test&#034;, &#034;compile-B&#034;, &#034;compile-B-test&#034;, &#034;run-B-test&#034;, ..., each with their own classpath definition.&lt;/p&gt;

&lt;p&gt;And as we added modules, we copy and pasted big chunks of Ant code, bloating the build file.&lt;/p&gt;

&lt;p&gt;This become unbearable recently.  And I looked for ways to make the build file manageable again.  That&#039;s when I found the two new features of Ant: &lt;a href= &#034;http://ant.apache.org/manual/CoreTasks/import.html&#034; style=&#034;color:red&#034;&gt;&lt;tt&gt;import&lt;/tt&gt;&lt;/a&gt; and &lt;a href= &#034;http://ant.apache.org/manual/CoreTasks/macrodef.html&#034; style=&#034;color:red&#034;&gt;&lt;tt&gt;macrodef&lt;/tt&gt;&lt;/a&gt;.  Both are available in the latest Ant 1.7.0 release.&lt;/p&gt;

&lt;p&gt;I won&#039;t bore you with the details of how these two tasks work.  But it did allow me to break my build file into a
  &lt;pre style=&#034;margin-left:3em&#034;&gt;template-build.xml&lt;/pre&gt;
which contains a set of macro definitions, and a bunch of
  &lt;pre style=&#034;margin-left:3em&#034;&gt;A-build.xml
B-build.xml
...&lt;/pre&gt;
files each importing &lt;tt&gt;template-build.xml&lt;/tt&gt; and instantiate the set of targets for a module.  The &lt;tt&gt;build.xml&lt;/tt&gt; then imports all the &lt;tt&gt;A-build.xml&lt;/tt&gt;, ... files and use all the targets in a systematical way.&lt;/p&gt;

&lt;p&gt;If you are using Ant, &lt;tt&gt;import&lt;/tt&gt; and &lt;tt&gt;macrodef&lt;/tt&gt; are your friends, just like if you are using C, &lt;tt&gt;#import&lt;/tt&gt; and &lt;tt&gt;#define&lt;/tt&gt; are your friends.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2008/04/14/breaking_version_inertia_ant_import_and_macrodef.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2008/04/14/breaking_version_inertia_ant_import_and_macrodef.html</guid>
    <pubDate>Mon, 14 Apr 2008 17:06:23 GMT</pubDate>
  </item>
  
  <item>
    <title>Thursday Ant Quiz</title>
    <link>http://www.weiqigao.com/blog/2008/03/13/thursday_ant_quiz.html</link>
    
      
        <description>
          &lt;p&gt;I&#039;m tearing my hairs out, so I think you should do the same.  I&#039;ll make you, as a matter of fact, by way of a Thursday Ant quiz:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;The Set Up&lt;/b&gt;: There are two files in the current directory: &lt;tt&gt;Foo.java&lt;/tt&gt; and &lt;tt&gt;Foo.class&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Q&lt;/b&gt;: Write an Apache Ant 1.7.0 compatible &lt;tt&gt;build.xml&lt;/tt&gt; file in the directory, which, when invoked with the &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt;, removes &lt;tt&gt;Foo.class&lt;/tt&gt; but not &lt;tt&gt;Foo.java&lt;/tt&gt;.  You cannot use the word &#034;&lt;tt&gt;Foo&lt;/tt&gt;&#034; in the build file.&lt;/p&gt;

&lt;p&gt;No Googling, no peeking into the online Ant manual or any Ant books.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2008/03/13/thursday_ant_quiz.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2008/03/13/thursday_ant_quiz.html</guid>
    <pubDate>Thu, 13 Mar 2008 18:27:36 GMT</pubDate>
  </item>
  
  </channel>
</rss>

