ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kev Jackson <kevin.jack...@it.fts-vn.com>
Subject Re: Quick question about properties
Date Thu, 13 Oct 2005 04:56:24 GMT
Stefan Bodewig wrote:

>On Thu, 13 Oct 2005, Kev Jackson <kevin.jackson@it.fts-vn.com> wrote:
>
>  
>
>>However if I try to run the project buildfile (./build.xml), none of
>>the properties are available (quick checks with echo just give me
>>variables instead of expanded properties).
>>    
>>
>
>This is not what I've seen in the past.  Properties declared in the
>imported build file just worked as expected.  Are you sure your
>property file is loaded at all?
>
>  
>
As promised here's a small example where a property from the 
common/build.properties is being referenced in the project.properties 
and it doesn't get expanded - inline and attached as Zip file for 
convenience

./common/build.xml

<?xml version="1.0" encoding="utf-8"?>
<project name="common" basedir="../">

    <property file="common/build.properties" />
   
    <target name="init">
        <echo message="${a} from common/build.properties" />
    </target>
</project>

common/build.properties

a="Hello"

./build.xml

<?xml version="1.0" encoding="utf-8"?>
<project name="test" basedir=".">
    <property file="project.properties" />
    <import file="common/build.xml"/>
   
    <target name="hello" depends="init">
        <echo message="${b} from project.properties" />
    </target>
</project>

./project.properties
b=${a}", Hello, Hello"

Output

Buildfile: build.xml

init:
     [echo] "Hello" from common/build.properties

hello:
     [echo] ${a}", Hello, Hello" from project.properties, "Hello" from 
common/build.properties

However (having just read an email about order of properties)

with

./build.xml

<?xml version="1.0" encoding="utf-8"?>
<project name="test" basedir=".">
   
    <import file="common/build.xml"/>
    <property file="project.properties" />
    <target name="hello" depends="init">
        <echo message="${b} from project.properties" />
    </target>
</project>

Everything works fine!

So (a little counter-intuitively I think).  The imported file seems to 
be placed in situ (with respect to properties), and I cannot reference a 
common property in a project properties file unless I import the file 
*before*.  I read all the documents, and there's this big thing about 
imported files being added to the end of the file - it's stressed in the 
manual IIRC, but if this is so, then I'd never be able to access the 
properties as they'd always come after my reference to them.

I think I just confused myself! ;)

It's behaving here as if it was inline - which is fine, just very unexpected

Kev

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


Mime
View raw message