ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Evan McLean ...@deathsdoor.com>
Subject Re: Best Practices
Date Thu, 10 Jan 2002 02:56:26 GMT
At 04:28 PM 9/01/02 -0700, Herman, Dave wrote:
>Anyone who has suggestions, please send them to my home email address (can't
>spend time on this while at work), and I'll start compiling them.

I have a build file which has several targets that all depend on another 
target.  A cut down example for this is:

         <target name="build">
           <antcall target="build-app1"/>
           <antcall target="build-app2"/>
           <antcall target="build-app2"/>
         </target>

         <target name="compile">
           <javac .... />
         </target>

         <target name="build-app1" depends="compile">
           <jar .... />
         </target>

         <target name="build-app2" depends="compile">
           <jar .... />
         </target>

         <target name="build-app2" depends="compile">
           <jar .... />
         </target>

I was suprised to find that if I do a build, it runs the compile target 
three times, one for each of "build-app1", "build-app2" and "build-app3" 
even though the second and third run wont do anything because it is already 
compiled.

To stop this, I change the compile target to the following:

         <target name="compile" unless="compile.done">
           <javac .... />
           <property name="compile.done" value="true"/>
         </target>

This way, the compile target (and hence the javac file dependency logic) is 
only performed once.

This is also good for init tasks and such as well.

Of course this may be counter-productive if you actually want to run a 
target several times, perhaps with different properties set...

BTW, I don't know if you were planning on having a contributors page or 
anything like that, but please do not publish my email address.

E.

--
Evan McLean           Did you know that beating your head against
ev@deathsdoor.com     a brick wall burns 150 calories an hour?


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message