ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniels, Doug" <Doug.Dani...@gdc4s.com>
Subject RE: Preset execution environment
Date Wed, 14 Apr 2004 16:53:06 GMT
I had some thoughts on importing in default common.xml files, optionally and automatically
if you define them at the same level as your build.xml, but the current import task doesn't
support all the features I'm looking for. What are people's thoughts on this:

Here is a proposed solution although it doesn't really do what you'd want it to do, which
is to be able to optionally import a common.xml from your current build directory if it exists,
and use those as the main targets. 

What you'd have to do is in every build file you import the top level MAIN common.xml, but
in that common.xml it tries to import <import file="${basedir}/common.xml" optional="true"
/> By using ${basedir} which will be your build.xml's directory where you import the common.xml,
this allows you to optionally import in a LOCAL common.xml at your build.xml's directory.

Here are some examples to elaborate:
/project/common.xml

<project name="commonMain">

  <import file="${basedir}/common.xml"/>

  <target name="build"> <echo>MAIN BUILD</echo> </target>

</project>

/project/some/where/build.xml

<project name="common">

  <import file="/project/common.xml" optional="true"/>

</project>


/project/some/where/common.xml

<project name="commonLocal">

  <target name="build"> <echo>LOCAL BUILD</echo> </target>

</project>

Now just run the /project/some/where/build.xml. Here's the problem though, the imports work
fine but when we import the LOCAL common.xml (/project/some/where/common.xml) into the MAIN
common.xml (/project/common.xml) it acts as if the MAIN common.xml overrides the LOCAL common.xml,
but what we want to have happen is the LOCAL common.xml to override the main. So the local
build target is now defined as commonLocal.build, and the MAIN build target is called just
build. When really we want the MAIN build task to be overridden and become commonMain.build,
and the local build target to become build.

What I propose is an attribute to the <import ...> task to say whether the imported
file should act like the parent build or should the file being imported act as the child build.
Something like this:
<import file="${basedir}/common.xml" parent="true" />

SO that the imported file doesn't have its targets over.

Another possible solution would be to have imports work depending on which target was defined
first. So say you import the LOCAL common.xml after you've defined all the targets, then it
would override the MAIN common.xml targets and reference them as commonMain.build.

Or I tried this other way because I thought if I defined the target first and then imported
in new targets the old ones would be overridden and the newly imported targets would become
the default, but it still acted the same way.

<project name="common">

  <target name="build"> <echo>MAIN BUILD</echo> </target>

  <import file="${basedir}/common.xml"/>

</project>




~ Doug Daniels

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


Mime
View raw message