ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daisy Guo" <Daisy....@quest.com>
Subject How to replace a property defined string with multiple lines
Date Fri, 03 Dec 2004 19:23:45 GMT
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message