Although you are right that Scott can use the <available> task to see if the target is already created, I suspect Scott would want to run the <exec> target if one of the dependencies involved has been updated.
He should look at the <uptodate> task. This allows you to specify a bunch of dependencies, then if one of those dependencies is newer than the specified target, a property is then set. You can then check this property when you execute your actual task. Normal way to do this is something like this: <target name="exec-task-test"> <uptodate property="key.already.built" target="${keystore}"> <srcfiles> <fileset dir=.../> </srcfiles> </uptodate> <target name="execute-task" depends="exec-task-test" unless="key.already.built"> <exec ...> </target> The AntContrib <outofdate> task is much more flexible and easier to use. However, you have to install the AndContrib library in your Ant classpath, and you have to define a <taskdef> in your build file. So, most people simply opt for the uptodate task. On Tue, Dec 30, 2008 at 12:13 PM, Scot P. Floess <sflo...@nc.rr.com> wrote: > > You can try the following: > > Stock Ant: > > 1) Wrap your call to exec in a target, and place an "if" on the target: > > <project> > <condition property = "file.found"> > <available file = "your.file"/> > </condition> > > <target name="exec" if = "file.found"> > <exec...> > ... > </exec> > > <touch file = "your.file"/> > </target> > </project> > > 2) Use AntContrib's if task: > > <project> > <!-- include Ant Contrib here... --> > > <if> > <available file = "your.file"/> > <then> > <exec...> > ... > </exec> > > <touch file = "your.file"/> > </then> > </if> > </project> > > > > > On Mon, 29 Dec 2008, removeps-gene...@yahoo.com wrote: > >> How can I make the exec task smart enough so that it won't do anything if >> the file generated by the task has already been created? >> >> For example, >> >> <copy file="srcFile.txt" tofile="destFile.txt" verbose="true"/> >> >> does nothing the second time. Not sure how it works, but maybe if the >> timestamp of destFile.txt is equal to or larger than srcFile.txt than >> nothing happens. >> >> So what I want is something like a generatedfile argument for exec. For >> example: >> >> <exec executable="${java.home}/bin/keytool.exe" >> generatedfile="${keystore}"> >> <arg value="-genkey"/> >> <arg value="-alias"/> >> <arg value="${alias}"/> >> <arg value="-keyalg"/> >> <arg value="RSA"/> >> <arg value="-validity"/> >> <arg value="36000"/> >> <arg value="-keystore"/> >> <arg value="${keystore}"/> >> <arg value="-storepass"/> >> <arg value="${storepass}"/> >> <arg value="-keypass"/> >> <arg value="${keypass}"/> >> <arg value="-dname"/> >> <arg value="${dname}"/> >> </exec> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org >> For additional commands, e-mail: user-h...@ant.apache.org >> >> > > Scot P. Floess > 27 Lake Royale > Louisburg, NC 27549 > > 252-478-8087 (Home) > 919-754-4592 (Work) > > Chief Architect JPlate http://sourceforge.net/projects/jplate > Chief Architect JavaPIM http://sourceforge.net/projects/javapim > > Architect Keros http://sourceforge.net/projects/keros > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > For additional commands, e-mail: user-h...@ant.apache.org > > -- -- David Weintraub qazw...@gmail.com --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org