ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: <import optional="true"> and inherited targets
Date Fri, 09 Apr 2004 19:24:02 GMT
> From: Matt Benson [mailto:gudnabrsam@yahoo.com]
> If I have a file base.xml which defines, briefly:
> 
> <project name="base">
>   <target name="build" depends="..." />
> </project>
> 
> Then my build.xml imports it:
> 
>   <import file="./base.xml" optional="true" />
> 
> and overrides build to do some extra stuff:
> 
>   <target name="build" depends="base.build">
>     ...
>   </target>
> 
> How can I keep from failing the build when the
> base.build target is not found?

You can't.

Optional="true" is only meaningful as an <include>.
The Ant developers refused to have a separate <include>
task, since you could use <import> as an <include>.

I don't see another use of optional="true" but for the
use case of load an optional build file to be *included*
in the _importing_ build file, to complement and/or
configure it.

I do something like:

<project ...>
  <import file="users/${user.name}/${ant.project.name}-build.xml"
          optional="true" />
  
  <target ... />
  ...
</project>

Each user can load any properties it wants, and override the
build's behavior. S/he can also define its own tasks, relevant
he her/him only. Like generating the Ctags for that projects to
use in VIM, in my case. --DD

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


Mime
View raw message