You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Kev Jackson <ke...@it.fts-vn.com> on 2005/10/13 05:45:09 UTC
Quick question about properties
Hi all,
I'm trying to refactor a build file we have here into a commonly used
set of targets and then project specifc targets. Here's my directory setup
./common/build.xml
./common/build.properties
./build.xml (shown below)
Now in the common/build.xml I use the property file tag to read in
build.properties, and running this file locally, (within common) works fine
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 doesn't seem right. The targets
from the common file are available, but the properties are not?
At first I thought it was because I was declaring a project specific
properties file too that was causing a problem, but commenting it out
did not resolce it (ie the project specifc properties were overwriting
the common properties - reasonable behaviour *if the variables have the
same name*)
So I'm currently resorting to this...
<?xml version="1.0" encoding="utf-8"?>
<project name="${project}" basedir=".">
<property file="common/build.properties" /> <-- this line is already
in common/build.xml
<property file="local.properties" />
<import file="common/build.xml" />
</project>
to get my project to work - I'm not sure if this is a bug or expected
behaviour, certainly I've never come across this before
Any help much appreciated, and I understand if you guys have 0 time to
answer
Kev
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 13 Oct 2005, Kev Jackson <ke...@it.fts-vn.com> wrote:
> Yes the properties file is being loaded (just rechecked now). It
> seems to be a problem if I reference a property from the common
> properties file within the project specific file.
Hmm, may it just be the order in which files are loaded?
ISTR that <import> adds everything at the bottom of the current build
file, not at the point where the task is defined. So you'd load your
project specific file before the common one - if both are outside of
targets, that is.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Kev Jackson <ke...@it.fts-vn.com>.
Stefan Bodewig wrote:
>On Thu, 13 Oct 2005, Kev Jackson <ke...@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?
>
>
Yes the properties file is being loaded (just rechecked now). It seems
to be a problem if I reference a property from the common properties
file within the project specific file. Eg
./common/build.properties
...
lib.dir=lib
...
./project.properties
...
ant-contrib.version=1.0b1
ant-contrib.jar=${lib.dir}/commons-and-misc/ant-contrib-${ant-contrib.version}.jar
...
With the same build.xml files
./common/build.xml
...
<!-- global project properties -->
<property file="common/build.properties" />
...
./build.xml
...
<property file="local.properties" />
<import file="common/build.xml" />
...
The output from ./build.xml...
init:
[echo] ${lib.dir}/commons-and-misc/ant-contrib-1.0b1.jar
[echo] com.ftsvn
[taskdef] Could not load definitions from resource
net/sf/antcontrib/antcontri
b.properties. It could not be found.
I'll try to build a simple couple of test build files to demonstrate the
behaviour in an independent way
Again sorry to bother anyone
Kev
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Steve Loughran <st...@apache.org>.
Peter Reilly wrote:
> At one stage, the import task behaved as if
> it was added at the end of the build file. This was an
> unexpected consequence (bug!) of the initial implementation.
> This was changed (I think) in 1.6.1 or 1.6.2, so that the import behaved
> as if it was inline. I have just checked the manual for the
> <import> task and can see no reference to imported files
> being added to the end of the file. Can you point out where
> you have seen this reference so that it can be modified.
> Thanks,
> Peter
>
Heh, I thought things went to the end too. Is it inline now? Excellent.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Dominique Devienne <dd...@gmail.com>.
On 10/13/05, Peter Reilly <pe...@gmail.com> wrote:
> At one stage, the import task behaved as if
> it was added at the end of the build file. This was an
> unexpected consequence (bug!) of the initial implementation.
> This was changed (I think) in 1.6.1 or 1.6.2, so that the import behaved
> as if it was inline.
I'm glad this was fixed. I missed the fact that it was appended at one
point, which would have been against my assumptions, possibly creating
troubleshooting headaches. This would also have violated in my mind
the principle of "least possible surprise". --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Steve Loughran <st...@apache.org>.
Kev Jackson wrote:
>
>>
>> OK. they were tail first, and I have stated that fact both in the
>> draft and in the big projects chapter of the second edition of Java
>> development with Ant. Which means that I have bit of editing to do on
>> the CVS-managed copies of that chapter. I've been trying to finish
>> that chapter since august, and was just getting to the end of the
>> maven2 libraries bit, and now I have to go back to and review it. sigh.
>>
> Sorry to be the one to put a downer on things there.
>
no, no, its much better to find out errors now than later.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Kev Jackson <ke...@it.fts-vn.com>.
>
> OK. they were tail first, and I have stated that fact both in the
> draft and in the big projects chapter of the second edition of Java
> development with Ant. Which means that I have bit of editing to do on
> the CVS-managed copies of that chapter. I've been trying to finish
> that chapter since august, and was just getting to the end of the
> maven2 libraries bit, and now I have to go back to and review it. sigh.
>
Sorry to be the one to put a downer on things there.
Kev
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Steve Loughran <st...@apache.org>.
Kev Jackson wrote:
> Peter Reilly wrote:
>
>> At one stage, the import task behaved as if
>> it was added at the end of the build file. This was an
>> unexpected consequence (bug!) of the initial implementation.
>> This was changed (I think) in 1.6.1 or 1.6.2, so that the import behaved
>> as if it was inline. I have just checked the manual for the
>> <import> task and can see no reference to imported files
>> being added to the end of the file. Can you point out where
>> you have seen this reference so that it can be modified.
>> Thanks,
>> Peter
>>
>>
>>
> Yeah, I'm sure I read it on the FAQ - but it was a while ago, and I
> should really have noticed this...
>
> <quote>
>
> "With this path, the imported buildfile can keep resources and be able
> to reference them <em>relative to its position.</em>"
>
> </quote>
>
> Having said that...
>
> 1."Import files are effectively appended to the tail of the build file
> (it’s a depth-first import, BTW)"
>
> From Steve Loughran's slides :)
OK. they were tail first, and I have stated that fact both in the draft
and in the big projects chapter of the second edition of Java
development with Ant. Which means that I have bit of editing to do on
the CVS-managed copies of that chapter. I've been trying to finish that
chapter since august, and was just getting to the end of the maven2
libraries bit, and now I have to go back to and review it. sigh.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Kev Jackson <ke...@it.fts-vn.com>.
Peter Reilly wrote:
>At one stage, the import task behaved as if
>it was added at the end of the build file. This was an
>unexpected consequence (bug!) of the initial implementation.
>This was changed (I think) in 1.6.1 or 1.6.2, so that the import behaved
>as if it was inline. I have just checked the manual for the
><import> task and can see no reference to imported files
>being added to the end of the file. Can you point out where
>you have seen this reference so that it can be modified.
>Thanks,
>Peter
>
>
>
Yeah, I'm sure I read it on the FAQ - but it was a while ago, and I
should really have noticed this...
<quote>
"With this path, the imported buildfile can keep resources and be able
to reference them <em>relative to its position.</em>"
</quote>
Having said that...
1."Import files are effectively appended to the tail of the build file
(it’s a depth-first import, BTW)"
From Steve Loughran's slides :)
Kev
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Steve Loughran <st...@apache.org>.
Stefan Bodewig wrote:
> On Thu, 13 Oct 2005, Peter Reilly <pe...@gmail.com> wrote:
>
>
>>Can you point out where you have seen this reference so that it can
>>be modified.
>
>
> I trusted Steve's writing 8-)
>
I trusted Stefan's reviewing of my writing :)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 13 Oct 2005, Peter Reilly <pe...@gmail.com> wrote:
> Can you point out where you have seen this reference so that it can
> be modified.
I trusted Steve's writing 8-)
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Quick question about properties
Posted by Peter Reilly <pe...@gmail.com>.
At one stage, the import task behaved as if
it was added at the end of the build file. This was an
unexpected consequence (bug!) of the initial implementation.
This was changed (I think) in 1.6.1 or 1.6.2, so that the import behaved
as if it was inline. I have just checked the manual for the
<import> task and can see no reference to imported files
being added to the end of the file. Can you point out where
you have seen this reference so that it can be modified.
Thanks,
Peter
Re: Quick question about properties
Posted by Kev Jackson <ke...@it.fts-vn.com>.
Stefan Bodewig wrote:
>On Thu, 13 Oct 2005, Kev Jackson <ke...@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
Re: Quick question about properties
Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 13 Oct 2005, Kev Jackson <ke...@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?
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org