Bug 58622

Summary: In-file property expansion does not work with prefix
Product: Ant Reporter: Oliver Maye <maye>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: major CC: justin.graham
Priority: P2    
Version: 1.9.6   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Oliver Maye 2015-11-18 08:26:14 UTC
The in-file property expansion does not work when the <property file ...> or <loadproperties ...> task is used with the preofix attribute as sketched in the following sample files.

build.properties
==================
prop1=Hello World
prop2=${general.message}
prop3=${prop1}

build.xml
===========
<project name="bugrepro">
  <target name="show">
    <property name="general.message" value="Hi, everybody!"/>
    <property file="build.properties" prefix="prfx" prefixValues="false"/>
    <echo message="prfx.prop1=${prfx.prop1}"/>
    <echo message="prfx.prop2=${prfx.prop2}"/>
    <echo message="prfx.prop3=${prfx.prop3}"/>
  </target>
</project>


The expected output, as given with Ant 1.8.4, is:
show:
     [echo] prfx.prop1=Hello World
     [echo] prfx.prop2=Hi, everybody!
     [echo] prfx.prop3=Hello World

The actual output of Ant 1.9.6 is:
show:
     [echo] prfx.prop1=Hello World
     [echo] prfx.prop2=Hi, everybody!
     [echo] prfx.prop3=${prop1}

When prefixValues is set to false, prop3 does not work, i.e., prop1 is not expanded locally in the properties file. Also, prop3=${prfx.prop1} does not help. Note that prop2 works fine.

When prefixValues is set to true, in-file expansion with prop3 works fine. However, prop2 does not work as the general.message property defined outside the properties file cannot be accessed, anymore.