I think part of the answer to this question is another question - why do you
need to change the value of the property?

In Ant properties are immutable. The targets are rule based which implies
that all rules have an equal chance of firing based on the conditions at the
time of evaluation.

Can you design the solution to fit in these guidelines? If not, antcontrib
offers some help by providing some if-then-else like constructs that can be
used. This also includes a variable construct that can change the value at
run time.

HTH Bill 

-----Original Message-----
From: Taner Diler [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 25, 2005 3:51 AM
To: Ant Users List
Subject: how can I change value of property in runtime?

Hi,

I have a problem with properties that defined in xml. I'm  reading a
property (has "test-0" value) from properties file and I try to change its
value by using ' <property name="${LOGICAL_SON_ISLEM_DIZINI}"
value="test-1"/>'.

when I display value of the property by using echo, "test-0" is still being
displayed.  How can I change value of the property in runtime?

<?xml version="1.0" ?>
<project name="structured" default="READER_CALLER" >
    <property name="SEPARATOR" value=";"/>
    <property name="rtdir" value="D:\\riskturk"/>
    <property name="RTDIR" value="D:\\riskturk"/>
    <property name="credit_context.name" value="KREDIRISK"/>
    <property name="credit_importer.name" value="CREDIT_IMPORTER"/>
    <property name="credit_importer.path" 
value="${rtdir}\\${credit_importer.name}"/>
    <property name="tomcat.home"  value="C:\\TOMCAT"/>
    <property name="lib.home" 
value="${rtdir}\\${credit_context.name}\\WEB-INF\\lib"/>
    <property name="credit_importer.porperties.file" 
value="${rtdir}\\${credit_importer.name}\\conf\\configuration.properties"/>

    <path id="project.class.path">
        <pathelement
path="${rtdir}\\${credit_context.name}\\WEB-INF\\classes" />
        <fileset dir="${lib.home}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${tomcat.home}\\common\\lib">
            <include name="servlet.jar"/>
        </fileset>
    </path>
   
    <!-- ${credit_importer.porperties.file} has ${LOGICAL_SON_ISLEM_DIZINI}
property. -->
    <target name="READ_FROM_PROPERTY_FILE">
        <property file="${credit_importer.porperties.file}"/>
       
        <!-- read ${LOGICAL_SON_ISLEM_DIZINI} property from property file.
-->
        <!-- write ${LOGICAL_SON_ISLEM_DIZINI} property to screen as
"test-0"-->
        <echo message="${LOGICAL_SON_ISLEM_DIZINI}"/>
    </target>

    <target name="READER_CALLER" depends="READ_FROM_PROPERTY_FILE">
        <!-- change value of ${LOGICAL_SON_ISLEM_DIZINI} property to
"test-1"  in runtime -->
        <property name="${LOGICAL_SON_ISLEM_DIZINI}" value="test-1"/>
       
        <!-- but it is still writing "test-0" to screen -->
        <echo message="${LOGICAL_SON_ISLEM_DIZINI}"/>
    </target>
</project>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to