ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roger Vaughn <rvau...@seaconinc.com>
Subject Immutable Properties in 1.1?
Date Thu, 20 Jul 2000 19:42:15 GMT
I just downloaded and started using Ant 1.1, and I have to say that I DO
NOT LIKE the fact that I can no longer redefine properties once
defined.  This, to me, is very painfully reminiscent of macro
definitions in Make (where the last definition in the file wins - and
NOT in target processing order.

I have to agree that the example given on the download page is worth
preventing, but I have been using redefined properties for perfectly
legitimate purposes - to simplify constructing sets of similar targets
in my builds.

For example, I do this:

<target name="jar1">
  <property name="jarfile" value="jar1.jar"/>
  <property name="includes" value="**/somefiles"/>
  <!-- some code that uses ${jarfile} and ${includes} -->
</target>

<target name="jar2">
  <property name="jarfile" value="jar2.jar"/>
  <property name="includes" value="**/someotherfiles"/>
  <!-- some code that uses ${jarfile} and ${includes} -->
</target>

In this example, the task code is exactly the same, allowing me to
easily create similar targets, or quickly replace code blocks for many
targets at once.  The properties are treated as local variables and hold
all of the values that cause the individual targets to differ.  With
immutable properties, however, I have to custom-code each block and
cannot easily change the code executed without a lot of manual work - or
at least after spending just as much time coming up with some hefty
regexps to do it for me.

Some of this would be alleviated by allowing access to the project and
target names as properties (hint, hint...), but this still wouldn't
allow complete flexibility.

I vote for bringing back mutable properties.  I also vote for leaving in
access to the System properties.  The fact that "...all Java code has
access to the system property list via the java.lang.System class..."
doesn't do me a darn bit of good in the middle of an Ant build file --
it isn't Java code.  Certain properties such as "user.dir" and "os.name"
are extremely useful at build time.  I do not find access to these
confusing, as no good Java programmer should be redefining system
properties (user., java. and os.) anyway.

As an alternative, I might propose adding target-local variables that
behave like properties, but only within target scope.

Roger Vaughn



Mime
View raw message