I have a "top-level"
build file in which I initialize several properties. It then calls a task
in another build file <nant .../> that reads a properties file, updating
properties previously initialized. I want to make sure that properties
updated from the property file don't get overwritten anywhere in the script, so
I tried teh following:
<foreach in="${build.file.properties}"
item="Line"
delim="="
property="property.name,property.value"
>
item="Line"
delim="="
property="property.name,property.value"
>
<!-- property.name must not
be empty -->
<if test="${property.name > ''}">
<if test="${property.name > ''}">
<!-- property.name
must not be a comment -->
<if test="${not string::starts-with(property.name, '#')}">
<if test="${not string::starts-with(property.name, '#')}">
<!--
property.value must not be empty
-->
<if test="${property::exists('property.value')}">
<if test="${property::exists('property.value')}">
<property
name="property.name" value="${string::trim(property.name)}"/>
<property name="property.value" value="${string::trim(property.value)}"/>
<property name="property.value" value="${string::trim(property.value)}"/>
<echo
message="Adding property =
value: ${property.name} =
${property.value}"/>
<property name="${property.name}" value="${property.value}" readonly="true" />
<property name="${property.name}" value="${property.value}" readonly="true" />
</if>
</if>
</if>
</foreach>
Everything weorks
fine, except the readonly attribute is bein ignored. I had one property in
the property file, build.number. But, right after the foreach, I was able
to set build.number to a different value with another property statement,
withouth an error or waraning.
If I set readonly on
the original property statement, any attempt to update the value results in the
warning message: Read-only property "build.number" cannot be
overwritten.
Why doesn't
readonly="true" work when I change the value of an existing
property?
Thanks,
Rod