How can I execute a task conditionally?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bent_Dalager
Posted On:   Tuesday, October 16, 2001 09:30 AM

I am currently doing a an apply task to compile a bunch of IDL files to Java source files. This always happens since there is no sensible timestamping to stop it when it isn't necessary. For example, I have no idea which generated Java files belong to which IDL source file. The java-to-idl tool I use just generates unconditionally so there is no help there. What I want to do is touch a file when I start building each IDL and use this touched file to determine whether or not to build each IDL file. My apply statement typically looks something like; (there's also some command line switches to jidl but you get the    More>>


I am currently doing a an apply task to compile a bunch of IDL
files to Java source files. This always happens since there is
no sensible timestamping to stop it when it isn't necessary.
For
example, I have no idea which generated Java files belong to
which IDL source file.
The java-to-idl tool I use just generates unconditionally so there
is no help there.
What I want to do is touch a file when I start building
each IDL and use this touched file to determine whether or not
to build each IDL file.



My apply statement typically looks something like;

			




(there's also some command line switches to jidl but you get the
idea)


I don't know how many IDL files there are so I can't make one
target per file. So, what I need to happen is for the apply task
to process each file in its fileset conditionally based either
upon properties or a timestamp check that I can specify.



This doesn't appear to be possible. This surprises me a bit
as I had expected Ant to allow some degree of creativity in
timestamp checking :-). Am I missing something?



The candidates for a solution that I have found do not seem
very useful in this case. There is dependset, which only removes
target files and that isn't very helpful since jidl doesn't
care. There is
condistion/uptodate, which
set a property, but I can see no way to have this property
affect the behaviour of apply except by making each jidl
call a separate target.

   <<Less

Re: How can I execute a task conditionally?

Posted By:   Erik_Hatcher  
Posted On:   Wednesday, October 17, 2001 03:53 AM

Check out the and tasks. With those, plus a target with an 'if' attribute around your task and you should achieve the functionality you desire. Post back if you have more questions or issues with this.

Re: How can I execute a task conditionally?

Posted By:   Bent_Dalager  
Posted On:   Tuesday, October 16, 2001 10:31 AM


I hate talking to myself :-)



Anyway, the following seems to solve my problem. Is that a
delusion or am I on to something?



I basically generate (by using - I would have loved to
use for this) one timestamp file for each source IDL
and then use this for 's built-in timestamp checking
via the .




























About | Sitemap | Contact