ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: <import optional="true"> and inherited targets
Date Fri, 09 Apr 2004 19:24:02 GMT
> From: Matt Benson []
> 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="">
>     ...
>   </target>
> How can I keep from failing the build when the
> 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/${}/${}-build.xml"
          optional="true" />
  <target ... />

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:
For additional commands, e-mail:

View raw message