You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David Sills <DS...@datasourceinc.com> on 2010/10/11 18:30:51 UTC

Question about the Include task

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

 


Re: Question about the Include task

Posted by Michael Shea <mi...@nitido.com>.
If I understand your issue, you have a build.xml file in a common-build 
dir, and you want to load properties from files in the common-build 
directory, and also from the directory of the build that is referencing 
your common build?

I do this in my builds:

build.xml for a given project:
--------------------------
<project name="some-project">
<!-- Load local properties - this must define "common-build.dir"-->
<property file="${basedir}/local.properties"/>

<!-- Define location of common build.xml file -->
<property name="common-build.xml" value="${common-build.dir}/build.xml"/>

<!-- Import the common build file xml file-->
<import file="${common.build.xml}"/>
</project>


common-build.xml, shared by all projects:
--------------------------
<project name="common-build" .....>

<!-- Get directory storing the "common-build" build.xml file -->
<dirname property="common-build.basedir" file="${ant.file.common-build}" />

<!-- Load project-specific build.properties -->
<property file="${basedir}/build.properties"/>

<!-- Load common build.properties -->
<property file="${common-build.basedir}/build.properties />

<!-- Do lots of other stuff here.... -->

</project>

  Btw, although it's not perfect (and last time I tried I couldn't get 
it to work with ant 1.8), I find the Eclipse Ant debugger very useful, 
especially for debugging issues of unset properties.


Mike Shea.

On 10-10-11 12:30 PM, David Sills wrote:
> 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
>
>
>
>
>    


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


Re: Question about the Include task

Posted by Michael Shea <mi...@nitido.com>.
If I understand your issue, you have a build.xml file in a common-build 
dir, and you want to load properties from files in the common-build 
directory, and also from the directory of the build that is referencing 
your common build?

I do this in my builds:

build.xml for a given project:
--------------------------
<project name="some-project">
<!-- Load local properties - this must define "common-build.dir"-->
<property file="${basedir}/local.properties"/>

<!-- Define location of common build.xml file -->
<property name="common-build.xml" value="${common-build.dir}/build.xml"/>

<!-- Import the common build file xml file-->
<import file="${common.build.xml}"/>
</project>


common-build.xml, shared by all projects:
--------------------------
<project name="common-build" .....>

<!-- Get directory storing the "common-build" build.xml file -->
<dirname property="common-build.basedir" file="${ant.file.common-build}" />

<!-- Load project-specific build.properties -->
<property file="${basedir}/build.properties"/>

<!-- Load common build.properties -->
<property file="${common-build.basedir}/build.properties />

<!-- Do lots of other stuff here.... -->

</project>

  Btw, although it's not perfect (and last time I tried I couldn't get 
it to work with ant 1.8), I find the Eclipse Ant debugger very useful, 
especially for debugging issues of unset properties.


Mike Shea.


On 10-10-11 12:30 PM, David Sills wrote:
> 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
>    


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