kingspider.tools.ant.task.CopyWithReplace
by Kingspider
email: kingspider70s@hotmail.com
该程序为Ant的扩展任务,在拷贝文本格式的文件的同时替换文件中的Ant表达式,类似于 ${property.name},属性值来自于Ant脚本加载的属性文件,如果没有属性文件中没有定义相关属性,那么保留原来的表达式;
该扩展任务定义的属性有:file、tofile、dir、todir、includes、excludes、encoding;
file、tofile两个属性一起使用,dir、todir、includes、excludes四个属性一起使用,encoding属性的默认值是UTF-8;
程序依赖的jar包有:ant-1.9.1.jar和commons-lang-2.6.jar
Ant脚本示例 test-ant-task.xml:
<project name="test-ant-task" default="test" basedir=".">
<property environment="env" />
<property file="${basedir}/test/template/config-app.properties" />
<taskdef name="copy-with-replace" classpath="${basedir}/release/ant-task-ext.jar;${basedir}/lib/ant-1.9.1.jar;${basedir}/lib/commons-lang-2.6.jar"
classname="kingspider.tools.ant.task.CopyWithReplace" />
<target name="test">
<copy-with-replace file="${basedir}/test/template/application.xml"
tofile="${basedir}/test/replaced/application.xml" encoding="UTF-8"/>
</target>
</project>