ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Goodnough" <Andrew.Goodno...@wicourts.gov>
Subject [PATCH] Ant Task - Proposed Enhancement
Date Thu, 13 Mar 2003 15:26:38 GMT
The current ant task runs an ant process for a specified build file in a
specified directory.  I wanted to be able to give it more than one
directory, and execute the build file found in each directory specified,
or give it a set of build files to execute.  This can be really useful
for building projects on which this project depends (could be
sub-projects but doesn't have to be).  I understand that this
enhancement overlaps with the proposed SubAnt task but I feel that this
function is really the domain of the existing Ant task, so rather than
adding another task, the Ant task should be enhanced - especially when
it only involves adding a couple contained types that users already know
how to use in other contexts.

This enhancement adds the ability to specify multiple directories with
the addition of a contained <dirset> type or multiple files with the
addition of a contained <fileset> type.  One can also specify both
DirSets and FileSets together, as well.  This allows the task to run ant
processes on the directories specified (by appending the default
"antFile" to them), or on the set of files specified.  {see
ANT_HOME\src\etc\testcases\taskdefs\ant.xml for examples in the attached
zip file}

I've run all of the current and new tests on the task and all passed. 
Most of the original logic flow is unchanged  (although it doesn't seem
that way due to refactoring).  In a nutshell, I added a for loop to the
execute method to loop through the each directory and each file
specifed, and execute the target on each. {see "diff.txt" in the
attached zip file}

Tell me what you think.

Andy



Using directory structure
*************************
/sub1
  build.xml
/sub2
  build.xml
/sub3
  build.xml


A typical build file could use the new task like this:

  <!-- excerpt from Project3/build.xml which depends on Project1 and
Project2 -->
  <!-- in order to build correctly -->
  <property name="subproject.dirs" value="Project1,Project2"/>

  <target name="compile-subprojects" if="subproject.dirs">
    <taskdef name="antnew"
classname="org.apache.tools.ant.taskdefs.AntNew"/>
    <antnew inheritAll="false" target="compile">
      <dirset dir=".." includes="${subproject.dirs}"/>     <!-- NEW
FEATURE -->
    </antnew>
  </target>

  <target name="compile" depends="compile-subprojects">
	...
  </target>


more examples pasted from testcases:

  <target name="test-dirset-inline-includes">
    <ant inheritAll="false" target="printMessage">
      <dirset dir="ant" includes="sub1,sub2,sub3"/>
    </ant>
  </target>

  <target name="test-dirset-contained-includes">
    <ant inheritAll="false" target="printMessage">
      <dirset dir="ant">
      	<include name="sub*"/>
      </dirset>
    </ant>
  </target>

  <target name="test-fileset-inline-includes">
    <ant inheritAll="false" target="printMessage">
      <fileset dir="ant"
includes="sub1/build.xml,sub2/build.xml,sub3/build.xml"/>
    </ant>
  </target>

  <target name="test-fileset-contained-includes">
    <ant inheritAll="false" target="printMessage">
      <fileset dir="ant">
        <include name="sub*/build.xml"/>
      </fileset>
    </ant>
  </target>

  <target name="test-fileset-and-dirset">
    <ant inheritAll="false" target="printMessage">
      <fileset dir="ant">
        <include name="sub1/build.xml"/>
      </fileset>
      <dirset dir="ant" includes="sub2,sub3"/>
    </ant>
  </target>

Mime
View raw message