You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Tim Dawson <td...@is.com> on 2000/12/15 00:03:37 UTC

configuration builds ...or... behavior not c onsistent with

Aside from the inconsistent naming (should be <filter file="foo"...> to be
consistent with <property file="foo...">), I've noticed that properties
don't do conversions on property values that reference other properties.
before I give details, I'll explain how we use filters & why we'd want this.

We like to do "configuration" builds. We set up development, test, and
production build configurations, and sometimes more than that, for example a
dev cluster build vs. a standard dev build. Anyway, we use a "config"
property that we provide a defualt value for, but can override on the
command line, e.g. "ant install -Dconfig=test".

Now, we basically want the same set of config properties to be available as
filters, since occasionally the same value is needed in both. For example,
the name of the server is needed when computing the installdir used by ANT,
and also within the start script.  Here's where we want recursive
expansion... when the value references another key.

This is how we set up our properties:

  <property name="config" value="dev" /> <!-- default config -->
  <property file="intranet.properties" />
  <property file="build-${config}.properties" />
  <property file="build-local.properties" />
  <property file="build.properties" />

the build.properties file contains the following lines

  weblogic-home=C:/weblogic
  server-name=intranet-${config}
  install-dir=${weblogic-home}/${server-name}

and my build-local.properties file contains

  weblogic-home=C:/devtools/weblogic-510

This all works fine with properties... if I do an <echo>, install-dir
correctly reports C:/devtools/weblogic-510/intranet-dev (three
substitutions).

But if I do a <filter> and <copy> using the following filter commands... 

    <filter filtersfile="build.properties" />
    <filter filtersfile="build-${config}.properties" />
    <filter filtersfile="build-local.properties" />

it replaces 

  set SERVER_NAME=@server-name@

with 

  set SERVER_NAME=intranet-${config}

instead of 

  set SERVER_NAME=intranet-dev

Now, the only way to get this to work correctly is that I'm lucky that we
use the same file for filters as well as properties, so I can do this...

    <filter filtersfile="build.properties" />
    <filter filtersfile="build-${config}.properties" />
    <filter filtersfile="build-local.properties" />
    <filter token="config" value="${config}" />
    <filter token="server-name" value="${server-name}" />

Only by overriding the tokens with the properties can I get things to work.

Does anybody else do config builds like this?  Am I doing the right thing? I
would think that recursive substitution in filters would be an obvious
addition...

Thanks for any feedback...

Tim