You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2006/09/21 01:56:34 UTC

DO NOT REPLY [Bug 40561] New: - property expansion troubles in property files

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561

           Summary: property expansion troubles in property files
           Product: Ant
           Version: 1.6.5
          Platform: Other
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: asfBugzilla.stratic@spamgourmet.com


Properties values are not always expanded properly in property files like in
following example.

build.xml (snippet)
=========

<property file="default.properties" prefix="project" />
<echo>interfaces.format=${project.interfaces.format}</echo>
<echo>factories.format=${project.factories.format}</echo>
<echo>foo=${project.foo}</echo>

default.properties (snippet)
==================

interfaces.package=model
interfaces.prefix=
interfaces.suffix=BO
interfaces.format={1}.${project.interfaces.package}.${project.interfaces.prefix}{2}${project.interfaces.suffix}

factories.package=factory
factories.prefix=
factories.suffix=BOFactory
factories.format={1}.${project.factories.package}.${project.factories.prefix}{2}${project.factories.suffix}

foo={1}.${project.factories.package}.${project.factories.prefix}{2}${project.factories.suffix}

Output
======
interfaces.format={1}.model.{2}BO
factories.format={1}.${project.factories.package}.{2}${project.factories.suffix}   
foo={1}.factory.{2}BOFactory

Bug
====

* "interfaces.format" value is ok (and it is similar to "factories.format")
* All values are not expanded in "factories.format" property
* But the same expression expand properly when assigned to "foo"

Changing properties names can affect this behaviour.

Workaround: choose different names. Good luck...

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40561] - property expansion with prefix troubles in property files

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561


peterreilly@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|property expansion troubles |property expansion with
                   |in property files           |prefix troubles in property
                   |                            |files




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40561] - property expansion with prefix troubles in property files

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561





------- Additional Comments From asfBugzilla.stratic@spamgourmet.com  2006-09-21 12:42 -------
(In reply to comment #3)

Stripping the prefix did not work because there is another bug or lack of
documentation (I forgot to mention it, sorry).

 Peter's example works only if properties values have not been set previously.
So it works with given snippets. But, like in my case, if some property values
have been set previously (by another property file or by the build), then
property values are not evaluated properly like in following example with a
slightly modified build.

build.xml (modified snippet)
=========

<property name="project.factories.package" value="foo" />
<property file="default.properties" prefix="project" />
<echo>factories.format=${project.factories.format}</echo>

Output (with peter's proposal)
======
factories.format={1}.factory.{2}BOFactory

 The correct output should be:

factories.format={1}.foo.{2}BOFactory
 
 Property file local values take precedence and hide any previous property
value. It act like if properties (project.factories.package) were mutable !

 In our case, users should be able to override these default values. So, Peter's
proposal did not work for me.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40561] - property expansion with prefix troubles in property files

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561





------- Additional Comments From peterreilly@apache.org  2006-09-21 13:09 -------
I not not dispute that there there is a bug,
I am just not too sure about the solution.

Another solution to your problem using current ant would be to
have multiple property files:
  project_1.properties
  project_2.properties
etc
and get the properties by

<property file="${project_name}.properties"}

where project_1.properties would be:

project_1.interfaces.package=model
project_1.interfaces.prefix=
project_1.interfaces.suffix=BO
project_1.interfaces.format={1}.${project_1.interfaces.package}.${project_1.interfaces.prefix}{2}${project_1.interfaces.suffix}



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40561] - property expansion with prefix troubles in property files

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561





------- Additional Comments From asfBugzilla.stratic@spamgourmet.com  2006-09-21 10:27 -------
(In reply to comment #1)

Sometimes using prefixes is very useful. In this example, restricting property
file scope to access only a subset of properties is intentional and mandatory.
The build file is a generic one. It is included in many projects. Users can
change some behaviours using a property file but they are restricted to a given
subset (project properties in this case). Using prefixes is a perfect solution
to provide this kind of isolation between levels. Reusable parts can evolve
without breaking the others.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40561] - property expansion with prefix troubles in property files

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561





------- Additional Comments From efanomars@yahoo.com  2006-09-21 11:50 -------
(In reply to comment #2)
I tested your example in verbose mode with Ant1.7Beta2 and 
I get the following:

>ant -v

Property "project.interfaces.prefix" has not been set
Property "project.interfaces.suffix" has not been set
Property "project.factories.suffix" has not been set
Property "project.factories.suffix" has not been set
     [echo]
interfaces.format={1}.model.${project.interfaces.prefix}{2}${project.interfaces.suffix}
     [echo] factories.format={1}.factory.{2}${project.factories.suffix}
     [echo] foo={1}.factory.{2}${project.factories.suffix}

which is correct. 

What you get is very strange (and would be a bug IMHO).
As Peter mentioned properties in a property file 
are first resolved among themselves (because
the definitions are returned as a set and have
no ordering) and only afterwards are resolved
against the build's properties.

There are two things you could try:
1. 
Strip the prefix from the names as Peter said.

2. 
Define the project.xxx properties separately
in case you need these properties to be visible in
more than one prefixed property file.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40561] - property expansion with prefix troubles in property files

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561





------- Additional Comments From peterreilly@apache.org  2006-09-21 08:40 -------
A workaround is to not use the prefixed properties in
the property file. I do not think that using prefixed properties
are a good idea as it ties the property file to the
<project file=.. prefix=..> call.

As the property expansion is inconsistent in your example
this is a bug - either all the prefixed properities should
expand or none of them should. The reason for the current
behaviour needs to be investigated, but it is most likely
something to do with delaying setting the prefixed properties.

example property file that works with current ant:

interfaces.package=model
interfaces.prefix=
interfaces.suffix=BO
interfaces.format={1}.${interfaces.package}.${interfaces.prefix}{2}${interfaces.suffix}

factories.package=factory
factories.prefix=
factories.suffix=BOFactory
factories.format={1}.${factories.package}.${factories.prefix}{2}${factories.suffix}

foo={1}.${factories.package}.${factories.prefix}{2}${factories.suffix}


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40561] - property expansion with prefix troubles in property files

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40561>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40561





------- Additional Comments From asfBugzilla.stratic@spamgourmet.com  2006-09-21 13:44 -------
(In reply to comment #5)

Yes, I understand and I just want to mention that there is another bug (or
undocumented behaviour).

On my side, I have found a workaround immediately:

1) Never introduce dependencies inside the same property file.
2) Express dependent values in build files or separate property files.

The resulting constraint for property files users is: Never use properties
redefined locally. Instead, use their literal value (which is defined locally).

These rules should work for anybody without introducing huge constraints.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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