You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Paul Mclachlan <pd...@msn.com> on 2003/09/19 22:18:13 UTC
[patch] Having execute a nested if the target
is out of date
Basically, I've added the capability for <uptodate> to have a nested
<sequential> task that only gets executed if the targets are out of
date. At present I have to create a whole other <target> to do the
dependency check so that the primary target and have an
unless="blah.uptodate".
This would make my ant script have fewer 'unnecessary' targets & seems
like a good idea. (To me, anyway).
- Paul
Re: [patch] Having execute a nested if the target is out of date
Posted by peter reilly <pe...@corvil.com>.
In ant-contrib, there is an <outofdate> task
that contains a <sequential> which
gets executed if the target(s) is(are) out of date.
http://ant-contrib.sourceforge.net/
Peter.
On Saturday 20 September 2003 01:32, Paul Mclachlan wrote:
> Martijn Kruithof wrote:
> > If you make something like this (I don't see a direct benefit), why
> > not make uptodate an taskcontainer so that you can wrap any task in
> > there without the need of indirection via the sequential task.
>
> But if you make <uptodate> a task container itself, it couldn't have
> nested elements that *weren't* tasks (such as it's existing feature of
> nested <srcfiles> or nested <mapper>). Right? Or maybe I'm missing
> something. But (even if I was) it seems like if you adopt this approach
> in general (and make it work), you could have problems with a task name
> conflicting with the name of a normally nested element.
>
> I think it's much better to use a nested <sequential>. It wouldn't have
> to be called "sequential", of course, we could call it something else,
> like "runIfOutOfDate", but <sequential> seemed more fitting (since
> people will - presumably - already know what it does & what it should
> contain)
>
> - Paul
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: [patch] Having execute a nested if the
target is out of date
Posted by Paul Mclachlan <pd...@msn.com>.
Martijn Kruithof wrote:
> If you make something like this (I don't see a direct benefit), why
> not make uptodate an taskcontainer so that you can wrap any task in
> there without the need of indirection via the sequential task.
But if you make <uptodate> a task container itself, it couldn't have
nested elements that *weren't* tasks (such as it's existing feature of
nested <srcfiles> or nested <mapper>). Right? Or maybe I'm missing
something. But (even if I was) it seems like if you adopt this approach
in general (and make it work), you could have problems with a task name
conflicting with the name of a normally nested element.
I think it's much better to use a nested <sequential>. It wouldn't have
to be called "sequential", of course, we could call it something else,
like "runIfOutOfDate", but <sequential> seemed more fitting (since
people will - presumably - already know what it does & what it should
contain)
- Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: [patch] Having execute a nested if the
target is out of date
Posted by Martijn Kruithof <ma...@kruithof.xs4all.nl>.
Hi,
If you make something like this (I don't see a direct benefit), why not
make uptodate an taskcontainer so that you can wrap any task in there
without the need of indirection via the sequential task.
Kind regards, Martijn.
Paul Mclachlan wrote:
> Basically, I've added the capability for <uptodate> to have a nested
> <sequential> task that only gets executed if the targets are out of
> date. At present I have to create a whole other <target> to do the
> dependency check so that the primary target and have an
> unless="blah.uptodate".
>
> This would make my ant script have fewer 'unnecessary' targets & seems
> like a good idea. (To me, anyway).
>
> - Paul
>
>
> ------------------------------------------------------------------------
>
> Index: docs/manual/CoreTasks/uptodate.html
> ===================================================================
> RCS file: /home/cvspublic/ant/docs/manual/CoreTasks/uptodate.html,v
> retrieving revision 1.11
> diff -u -r1.11 uptodate.html
> --- docs/manual/CoreTasks/uptodate.html 1 Jun 2002 12:26:33 -0000 1.11
> +++ docs/manual/CoreTasks/uptodate.html 19 Sep 2003 20:11:48 -0000
> @@ -37,7 +37,8 @@
> <tr>
> <td valign="top">property</td>
> <td valign="top">The name of the property to set.</td>
> - <td valign="top" align="center">Yes</td>
> + <td valign="top" align="center">Yes, unless a nested
> + <code><sequential></code> is present.</td>
> </tr>
> <tr>
> <td valign="top">value</td>
> @@ -70,6 +71,10 @@
> <p>The nested <code><mapper></code> element allows you to specify
> a set of target files to check for being up-to-date with respect to a
> set of source files.</p>
> +
> +<h4><a name="sequential">sequential</a></h4>
> +<p>The nested <code><sequential></code> element allows you to specify a
> +set of tasks to run when the source files are out of date.</p>
>
> <h3>Examples</h3>
> <pre> <uptodate property="xmlBuild.notRequired" targetfile="${deploy}\xmlClasses.jar" >
> Index: src/main/org/apache/tools/ant/taskdefs/UpToDate.java
> ===================================================================
> RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/UpToDate.java,v
> retrieving revision 1.32
> diff -u -r1.32 UpToDate.java
> --- src/main/org/apache/tools/ant/taskdefs/UpToDate.java 13 Aug 2003 14:46:15 -0000 1.32
> +++ src/main/org/apache/tools/ant/taskdefs/UpToDate.java 19 Sep 2003 20:12:07 -0000
> @@ -91,6 +91,7 @@
> private File _sourceFile;
> private File _targetFile;
> private Vector sourceFileSets = new Vector();
> + private Sequential _sequential = null;
>
> protected Mapper mapperElement = null;
>
> @@ -218,14 +219,21 @@
> return upToDate;
> }
>
> + public void addSequential( Sequential s ) {
> + if( _sequential != null ) {
> + throw new BuildException( "Only one nested <sequential> permitted", getLocation() );
> + }
> +
> + _sequential = s;
> + }
>
> /**
> * Sets property to true if target file(s) have a more recent timestamp
> * than (each of) the corresponding source file(s).
> */
> public void execute() throws BuildException {
> - if (_property == null) {
> - throw new BuildException("property attribute is required.",
> + if (_property == null && _sequential == null) {
> + throw new BuildException("property attribute or nested <sequential> required.",
> getLocation());
> }
> boolean upToDate = eval();
> @@ -237,6 +245,11 @@
> } else {
> log("All target files are up-to-date.",
> Project.MSG_VERBOSE);
> + }
> + }
> + else {
> + if (_sequential != null) {
> + _sequential.perform();
> }
> }
> }
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org