I'm having a real problem with the Include task (unfortunately, it's
hard to search for useful information on this task, as "include" and
"task" are really common on the archive lists). I'm trying to reuse
variables that are set within each separate project in an included Ant
build file outside the projects, but this does not seem to work at all.

 

In other words, in my build file I start by including the common build
file after reading a local properties file:

 

  <property name="build.dir" value="build"/>

  <property file="${build.dir}/localfiles.properties"/>

  <include file="${common.build.dir}/common-build.xml" as="common"/>

 

The localfiles.properties defines the "common.build.dir" property:

 

common.build.dir=../../../build

 

I would assume that in the common-build.xml I could use:

 

  <property file="${build.dir}/build.properties"/>

  <property file="${common.build.dir}/common-build.properties"/>

 

However, it doesn't read those properties. In the
common-build.properties, I set a property:

 

ivy.settings.dir=${common.build.dir}

 

and in the common-build.xml I use that property:

 

  <target name="resolve" depends="init">

    <ivy:configure file="${ivy.settings.dir}/ivysettings.xml"/>

    <ivy:resolve file="${ivy.dep.file}" conf="runtime"/>

  </target>

 

The error tells me:

 

C:\Projects\dsi java common\build\common-build.xml:33: settings file
does not exist: C:\Projects\dsi java
common\source\dsi-common\${ivy.settings.dir}\ivysettings.xml

 

So it's not reading and setting the "ivy.settings.dir" property. Which I
assume means it's not reading my properties file (especially as even if
I change "ivy.settings.dir=." I get the same error).

 

I tried passing a propertyset with "common.build.dir" as a nested
resource in the include, but then I get an error message telling me that
PropertyResource is not supported in the plugin (I assume the Eclipse
plugin, as I'm using Ant 1.8.1, which should have propertysets, but who
knows? as the error message appears nowhere on the web I can find).

 

I'm so used to the antcall "inheritall" and "inheritrefs" that perhaps I
am wrong to think that this sort of inheritance should even work.

 

I would have thought that include would act just like you expect - as
though the contents of the included file were written in the original
build file; perhaps with some special details about overriding targets.
What I wouldn't have expected was such a fuss over properties.

 

Any and all ideas muchly appreciated.

 

David Sills

 

Reply via email to