Hmmm, I think I've found an answer to this. If I take out the declaration of the
project.name property in build1.build, it works fine. Presumably it's because the
inherited properties aren't read-only, as they would be had they been typed from the
command line - and as it looks like they once were:
http://www.geocrawler.com/archives/3/14603/2002/6/100/8862373/
I guess my scenario is one of the reasons that Ant had inherited properties read-only.
OK, so I guess what I need to do is to be able to know if a property exists, something
like this:
build1.build:
<project name="build1" default="build" basedir=".">
<property name="local.project.name" value="build1" />
<target name="build">
<[if project.name property exists]>
<property name="local.project.name" value="${project.name}" />
</[if]>
<echo message="Child project name ${local.project.name}" />
</target>
</project>
build2.build:
<project name="build2" default="build" basedir=".">
<property name="project.name" value="build2" />
<target name="build">
<echo message="Parent project name ${project.name}" />
<nant buildfile="build1.build" inheritall="true" />
</target>
</project>
Does such a function
<[if project.name property exists]>
exist?
Thanks
Kenton Price
-----Original Message-----
From: Kenton Price
Sent: Tue 08/07/2003 16:00
To: Ian MacLean
Cc: [EMAIL PROTECTED]
Subject: RE: [Nant-users] Passing attributes when calling <nant... >?
Thanks hugely for this Ian - that's exactly the functionality I was looking
for, so I guess it's not there yet. Unfortunately I seem to have misunderstood
inheritall too! What I'm trying to do is effectively have default parameters in a
build file that can be overridden when called from another build file. For example:
build1.build:
<project name="build1" default="build" basedir=".">
<property name="project.name" value="build1" />
<target name="build">
<echo message="Child project name ${project.name}" />
</target>
</project>
build2.build:
<project name="build2" default="build" basedir=".">
<property name="project.name" value="build2" />
<target name="build">
<echo message="Parent project name ${project.name}" />
<nant buildfile="build1.build" inheritall="true" />
</target>
</project>
When calling nant on build1.build, as expected it returns "Child project name
build1".
I would have hoped that when build2 calls nant on build1, it would return
"Child project name build2" - unfortunately when you run this, it's still "build1".
I'm using version 0.8.2.
Can you or anyone think of a way of doing what I'm trying to do?
Many thanks
Kenton Price
-----Original Message-----
From: Ian MacLean [mailto:[EMAIL PROTECTED]
Sent: Tue 08/07/2003 15:43
To: Kenton Price
Cc: [EMAIL PROTECTED]
Subject: Re: [Nant-users] Passing attributes when calling <nant... >?
Kenton,
right now you can use the inheritall attribute to get all of them.
There
is no way right now of passing selected properties. Maybe it would be
useful to have an optionset under the nant task so you could do:
<nant buildfile="[buildfile2]" target="build >
<properties>
<property name="attribute1" value="${attribute1}" />
</properties>
</nant>
Ian
>Hi
>
>Apologies if this has been answered before, but I'm trying to pass
selected specific attributes when calling <nant>. I don't want to inherit all
attributes, just some of them. I was hoping to be able to do something like this:
>
> <nant buildfile="[buildfile2]" target="build
-D:attribute1=${attribute1} -D:attribute3=${attribute3} />
>
>but it falls over. Is there a way of doing what I'm trying to do?
>
>Many thanks
>
>Kenton Price
>?????????????????????????????????????????ӆ+?^?隊[)?{([EMAIL
PROTECTED];"??"??nv)?
>?ZE?h????(?g?q?Ϣ?Z??ڝ?h??j?????i?^????'?????Zɩ?z{^??0?v?\???b??J?????????w???brO?_ܢo??lkM5?M4???ثy??j?ڲ???]???5?M????????????????????????????????????Z????왨??x%??Mj{??ǫ??b??????q?????a??l????l??.?ǟ???w??X?????b????????
>
>
�+zf���h��+y��������)m#�;"��"��nv)�
�ZE�h��r��z�>��j[��h��j�����i�^���
塧m�ֲjw^���"�����X���R��b����i����w�rX����r����鱭4�M4Ӧ�{�b��-j֬�N��M���55���ǫ�f��)��+-5���ǫ�X���(��~��zw���i����l���q���z���l�X��)ߣ�ڞ۬z�