devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

<project default="all" xmlns:ac="antlib:net.sf.antcontrib">
  <description>
    This build file is designed to report the performance
    of ant from various releases.
    to use:
    * install ant-contrib.jar to ($ANT_HOME|$HOME/.ant)/lib
    * install beanshell jar and bsf jar
    * use unix (with bash) or install cygwin
    * set the env variables {whichever needs testing}
      ANT_HOME
      ANT_HOME_6_5 (the directory containing ant 1.6.5)
      ANT_HOME_6_4
      ANT_HOME_5_4
    
    * run ant
    For example:
       export ANT_HOME="c:/cygwin/home/me/svn/trunk/dist"
       export ANT_HOME_5_4="l:/apps/apache-ant-1.5.4"
       ant.bat

    TODO: more build files.
  </description>
  <property environment="env"/>

  <target name="all" depends="gen,do-times"/>

  <target name="clean">
    <delete quiet="yes" dir="build"/>
  </target>

  <macrodef name="run-ant-files">
    <attribute name="env-ant"/>
    <sequential>
      <ac:if>
        <isset property="@{env-ant}"/>
        <then>
          <ac:shellscript shell="bash">
            export ANT_HOME=${@{env-ant}}
            echo $ANT_HOME
            echo -n "--  props.xml     --: "
            $ANT_HOME/bin/ant -f build/gen/props.xml | grep time
            echo -n "-- ant-call.xml   --: "
            $ANT_HOME/bin/ant -f build/gen/ant-call.xml | grep time
          </ac:shellscript>
        </then>
      </ac:if>
    </sequential>
  </macrodef>
  
  <target name="do-times">
    <run-ant-files env-ant="env.ANT_HOME"/>
    <run-ant-files env-ant="env.ANT_HOME_6_5"/>
    <run-ant-files env-ant="env.ANT_HOME_6_2"/>
    <run-ant-files env-ant="env.ANT_HOME_5_4"/>
  </target>


  <target name="gen-dirs">
    <mkdir dir="build/gen"/>
  </target>

  <target name="avail">
    <available property="avail.props.xml"
               file="props.xml" filepath="build/gen"/>
    <available property="avail.ant-call.xml"
               file="ant-call.xml" filepath="build/gen"/>
  </target>

  <target name="gen-props" depends="gen-dirs,avail" unless="avail.props.xml">
    <script language="beanshell">
      import java.io.*;
      out = new PrintWriter(new BufferedWriter(new FileWriter(
          "build/gen/props.xml")));
      out.println("<project name='props' default='props'>");
      out.println("  <target name='props'>");
      for (int i = 0; i < 20000; ++i) {
          out.println(
              "    <property name='prop" + i + "' value='val'/>");
      }
      out.println("  </target>");
      out.println("</project>");
      out.close();
      self.log("Created build/gen/props.xml");
    </script>
  </target>

  <target name="gen-ant-call" depends="gen-dirs,avail"
          unless="avail.ant-call.xml">
    <script language="beanshell">
      import java.io.*;
      out = new PrintWriter(new BufferedWriter(new FileWriter(
          "build/gen/ant-call.xml")));
      out.println("<project name='ant-call' default='call'>");
      out.println("  <target name='me'/>");
      out.println("  <target name='call'>");
      for (int i = 0; i < 1000; ++i) {
          out.println("    <antcall target='me'/>");
      }
      out.println("  </target>");
      out.println("</project>");
      out.close();
      self.log("Created build/gen/ant-call.xml");
    </script>
  </target>

  <target name="gen" depends="gen-ant-call,gen-props"/>
</project>




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com