ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Glick <Jesse.Gl...@netbeans.com>
Subject Re: "depends" gets executed before "if"
Date Fri, 01 Sep 2000 14:37:01 GMT
Kevin Toomey wrote:
> Given the build.xml statements below, I expected that my input and
> output directories would get deleted only if the property cleanAll was
> set. That's not the case. The "depends" targets get executed first,
> then the "if" is checked. I can get around this easily enough, by
> moving the "if" checks to the two delete_* tasks.
> Am I missing something in thinking that "if" and "unless" should be
> checked prior to performing depends"?

Well, they're not...they only apply to the target they are placed on,
and I believe they are checked at runtime when that target is reached.
The "depends" analysis is done statically before any targets are run. I
can see how this would be considered confusing. Anyway, just add the
if-test to the subtargets; or move the subtargets into the body of a
conditional target, thus:

<target name="clean" depends="maybeCleanAll">
  <!-- do light clean tasks -->
</target>
<target name="maybeCleanAll" if="cleanAll">
  <ant dir="." target="reallyCleanAll"/>
</target>
<target name="reallyCleanAll"
depends="delete_class_files,delete_source_files"/>

Clumsy and not very efficient but you can make it work.

-Jesse

-- 
Jesse Glick   <mailto:Jesse.Glick@netbeans.com>
NetBeans, Open APIs  <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR

Mime
View raw message