ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martijn Kruithof <mart...@kruithof.xs4all.nl>
Subject Re: [patch] Having <uptodate> execute a nested <sequential> if the target is out of date
Date Fri, 19 Sep 2003 22:27:53 GMT
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>&lt;sequential&gt;</code> is present.</td>
>    </tr>
>    <tr>
>      <td valign="top">value</td>
> @@ -70,6 +71,10 @@
>  <p>The nested <code>&lt;mapper&gt;</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>&lt;sequential&gt;</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>  &lt;uptodate property=&quot;xmlBuild.notRequired&quot; targetfile=&quot;${deploy}\xmlClasses.jar&quot;
&gt;
> 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


Mime
View raw message