You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2008/05/13 01:55:07 UTC
DO NOT REPLY [Bug 44980] New: Recursion in Ant
https://issues.apache.org/bugzilla/show_bug.cgi?id=44980
Summary: Recursion in Ant
Product: Ant
Version: 1.7.0
Platform: PC
URL: http://mail-archives.apache.org/mod_mbox/ant-
dev/200805.mbox/%3ccd22733f0805111551h53e15254jc96a29389
03dc93@mail.gmail.com%3e
OS/Version: Windows Vista
Status: NEW
Severity: normal
Priority: P2
Component: Core
AssignedTo: notifications@ant.apache.org
ReportedBy: lateralcoder@gmail.com
Created an attachment (id=21953)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=21953)
Ant Recursion Patch
Ant has some support for recursing a target down a build hierarchy in the form
of the following:
- fileset can specify a list of directories or build files
- antcontrib:for can do iteration
However each target has to handle recursion itself.
I have developed a patch (roughly 30 extra lines of code across 6 files) adds
two new
*dynamic* properties to Ant:
1) ant.project.target - the default target of the current project
2) ant.current.target - a comma-separated list of the actual targets
that were invoked on the current project
These properties are updated automatically, similar to ant.file or
ant.project.name.
The "recurse" macro uses the antcontrib:for task to iterate over
multiple targets (btw, the currnet antcontrib jar is missing the "for" task in
its properties). The macro can accept an explicit list of
targets, but I also wanted to be able to recurse on the targets that
were actually invoked.
Here's how you would use it:
<!-- define the "recurse" macro -->
<typedef file="recurse.xml"/>
<!-- "subdirs" is the ordered list of sub-folders that "recurse" uses -->
<filelist dir="." id="subdirs" files="x1,x2"/>
<!-- invokes the macro on the current target(s), which may be the
ones specified or falls back to the default target -->
<recurse/>
Alternatively:
<!-- invoke the macro on the specified targets -->
<recurse targets="this,that,other"/>
I've attached the patch. The "recurse" macro is trivial using the new
properties:
<?xml version="1.0"?>
<antlib xmlns:antcontrib="antlib:net.sf.antcontrib">
<macrodef name="recurse">
<attribute name="targets" default="${ant.current.target}"/>
<sequential>
<condition property="recurseTargets" value="${ant.project.target}"
else="@{targets}">
<equals arg1="@{targets}" arg2="" />
</condition>
<antcontrib:for list="${recurseTargets}" param="target">
<sequential>
<subant target="@{target}">
<filelist refid="subdirs"/>
</subant>
</sequential>
</antcontrib:for>
</sequential>
</macrodef>
</antlib>
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 44980] Add properties that reference the default
target and the target(s) specified on the command line
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44980
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS/Version|Windows Vista |All
Summary|Recursion in Ant |Add properties that
| |reference the default target
| |and the target(s) specified
| |on the command line
--- Comment #1 from Stefan Bodewig <bo...@apache.org> 2008-05-30 01:07:31 PST ---
personally I don't see any problems with adding the two properties you
suggested, will start a dedicated thread on the dev list.
I might disagree with minor details of the patch, in particular I'd probably
move the listTo... method into oata.util.CollectionUtils.
Even though the patch looks trivial, I'd appreciate tests ;-)
Those details can and will be hashed out within minutes once we agree that the
feature itself is desirable.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 44980] Recursion in Ant
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44980
Colm Smyth <la...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 44980] Add properties that reference the default
target and the target(s) specified on the command line
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44980
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #2 from Stefan Bodewig <bo...@apache.org> 2008-06-04 04:00:06 PST ---
http://svn.apache.org/viewvc?rev=663051&view=rev
http://svn.apache.org/viewvc?rev=663061&view=rev
By changing Project rather than Main to set the list of invoked targets no
longer was necessary to modify <*ant*> at all.
Thanks
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.