ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Possible Ant 1.7 alpha bug: property expansion.
Date Wed, 02 Jun 2004 19:46:23 GMT
> From: Jack J. Woehr [mailto:jax@purematrix.com]
> 
> Dominique Devienne wrote:
> 
> > I believe that ${${a}.${b}} is parsed as:
> >
> > getProperty("${a") + "." + getProperty("b") + "}", thus the result. --DD
> 
> Well, it sure looks like it is :-)
> 
> But is that result reasonable? It looks more to me like an artifact of a
> coding strategy being elevated to a principle.

First, don't shoot the messenger ;-)

Second, what's one to do? Ant by contract does not support nested
properties, so what's Ant to do when it sees on opening ${? It looks for the
closing curly brace, which is found after ${a, which is thus interpreted as
the property name to reference?

I duplicated the Ant logic using JDK 1.4 regex, and have the same logic
using the "\\$\\{([^\\}]+)\\}" regex (in Java code, thus the escapes). I
even have a test case that shows what you just discovered:

  protected void setUp() {
    _ve = new VariableEvaluator();
    _ve.putVariable("foo", "bar");
    _ve.putVariable("ding", "dong");
    _ve.putVariable("var${weird", "indeed");
  }

  public void test_evalString() {
    assertEval(_ve, "${var${varname}}", "${var${varname}}", true);
    assertEval(_ve, "${var${weird}}", "indeed}", false);
  }

--DD

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


Mime
View raw message