Generally when you see ${some.property.name}, it's because the property isn't 
actually being set...  You might try adding an <echo> just after the spot where 
you think you're setting it, and see what you get.  

Kajsa Anderson

-----Original Message-----
From: Daisy Guo [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 03, 2004 2:24 PM
To: [EMAIL PROTECTED]
Subject: How to replace a property defined string with multiple lines

Hi,

I have a task which given a script and a insert point, it would create a
new script based on the old one and add a few lines at the insert point
(see attached).  It failed to find the insert point, because ant looks
for ${insert.token} instead of the property value.  

Is there a work around this?  I'm using Ant version 1.6.2

Thanks

Daisy

integrate_impl:
   [delete] Deleting: E:\common\test\mod_startWebLogic.cmd
     [copy] Copying 1 file to E:\common\test
     [copy] Copying E:\common\test\startWebLogic.cmd to
E:\common\test\mod_startWebLogic.cmd
  [replace] Replacing in E:\common\test\mod_startWebLogic.cmd:
${insert.token} -->
  [replace]
  [replace] @rem =====================
  [replace] @rem INTEGRATE START
  [replace] @rem =====================
  [replace]
  [replace] set PRODUCT_HOME=...
  [replace] call "%PRODUCT_HOME%\bin\...
  [replace] set OPTIONS=
  [replace]
  [replace] @rem =====================
  [replace] @rem INTEGRATE - END
  [replace] @rem =====================
  [replace]
  [replace] ${insert.token}
  [replace] Replaced 0 occurrences in 0 files.



<project name="test" basedir="." default="test" >
        
        <target name="integrate_impl" >
        <basename property="file.name" file="${start.script}"/>
        <dirname property="dir.name" file="${start.script}"/>
        <property name="start.script.integrated"
location="${dir.name}/mod_${file.name}" />
                <delete file="${start.script.integrated}" quiet="true"
/>
                <copy file="${start.script}"
tofile="${start.script.integrated}" />  

                <replace file="${start.script.integrated}"
summary="true" >
                        <replacetoken>${insert.token}</replacetoken>
                        <replacevalue>            

@rem =====================
@rem INTEGRATE START
@rem =====================

set PRODUCT_HOME=...
call "%PRODUCT_HOME%\bin\...
set OPTIONS=

@rem =====================
@rem INTEGRATE - END
@rem =====================

${insert.token}</replacevalue>
                </replace>
        </target>

        <target name="test" >
            <macrodef name="integrate">
                <attribute name="startscript" />
                <attribute name="inserttoken" />
                <sequential>
                                <antcall target="integrate_impl" >
                                        <param name="start.script"
value="@{startscript}" />
                                        <param name="insert.token"
value="@{inserttoken}" />
                                </antcall>
                        </sequential>
                </macrodef>
                
                <integrate startscript="startWebLogic.cmd"
inserttoken="java" />
                <integrate startscript="startJBoss.cmd" inserttoken="set
CLASSPATH=" />
        </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]


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

Reply via email to