ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Vogel <pvo...@arsin.com>
Subject PATCH: Attributes of Target can reference properties
Date Mon, 18 Jun 2001 19:52:54 GMT
--- ProjectHelper.java  Fri Jun  8 03:11:27 2001
+++ ProjectHelper.java.new      Mon Jun 18 12:39:38 2001
@@ -385,7 +385,8 @@

             for (int i = 0; i < attrs.getLength(); i++) {
                 String key = attrs.getName(i);
-                String value = attrs.getValue(i);
+               String value = replaceProperties(project, attrs.getValue(i),
+                                                project.getProperties());

                 if (key.equals("name")) {
                     name = value;


The idea here is to allow dependencies to be somewhat dynamic, for example,
we
have a "targets.xml" file that has things that look like this:

<property name="dist" value="globaldist"/>

<target name="dist" depends="${dist}"/>

<target name="globaldist" depends="build">
    ....
</target>

<target name="noop"/>

Where a build.xml that does an XML include of target.xml can then
do this before it includes target.xml:

<property name="dist" value="localdist, globaldist"/>

to add some non-default steps to the dist target, or this:

<property name="compile" value="noop"/>

To indicate that there is nothing to compile in this tree...

We find this incredibly powerful for "templating" our build process.  It
could be argued that
"real" templates (using XSLT, etc.) are the "right" solution for this, but I
don't want to go into
that argument, and I don't want to wait for ant2 to effectively templatize
my build.  

This is a fairly standard sort of pattern when abstracting functionality
into a common set of
files -- to enable a local definition of a target to override a global
definition, since the local
tree obviously knows more about its circumstances than the global stuff.
Since target definition
duplication isn't allowed (as opposed to just silently ignoring the second
definition of a target,
for example) and would be truly ugly if it were,  this seems the most
effective method of following
this sort of build design pattern.

Thanks!
-Peter




Mime
View raw message