ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nishant Kumar <knish...@postmark.net>
Subject conditional sequence
Date Wed, 15 Oct 2003 16:08:31 GMT
hi,
	i have written a small task combining the sequential task and the
if/unless condition of target. i call it conditional sequential. as of
now uptodate checks need a separate target. for example, from the docs

<target name="chkXmlBuild">
  <uptodate property="xmlBuild.notRequired"
	targetfile="${deploy}\xmlClasses.jar" >
    <srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
  </uptodate>
</target>

<target name="xmlBuild" depends="chkXmlBuild"
	unless="xmlBuild.notRequired">
  
	DO SOMETHING
</target>

problem with this approach is that this way of check leads to something
like private and public targets. some that are to be used internally and
others thatthe users can call. but looking at it one cannot tell which
is which.

using my task one change keep both task in the same target.

<target name="xmlBuild">
    <conditionalsequential unless="xmlBuild.notRequired" checkafter="1">
       <uptodate property="xmlBuild.notRequired" 
		targetfile="${deploy}\xmlClasses.jar" >
            	<srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
       </uptodate>
	
       DO SOMETHING
    </conditionalsequential>
</target>

in this after the first (checkafter=1) task (ie uptodate) the unless
condition is checked just like done in target. if it succeeds then the
execution continues otherwise not.

i feel this is a cleaner way. kindly send me you comments.

i have attached the code which is just copy paste of Sequential task and
Target class.

thanks,
nishant.
-- 
Nishant Kumar <knishant@postmark.net>

Mime
View raw message