Gradle脚本
copy {
from 'src/com/comcast/telescope/Telescope.java'
into 'dist/com/comcast/telescope'
include '**/*.java'
}
Ant脚本
<copy file="${src.dir}/com/comcast/telescope/Telescope.java" toFile="${dist.dir}/com/comcast/telescope/Telescope.java">
<filterset begintoken="Tel-" endtoken="-Tel">
<filter token="IntVer" value="${Interface-Version}" />
</filterset>
我得到了复制文件的顶部部分,但是在复制时我仍然坚持过滤文件。有人能帮助我吗?
答案 0 :(得分:1)
您需要在try
。{/ p>中添加对filter
的来电
基于原始Ant脚本,您需要:
CopySpec
使用ReplaceTokens将import org.apache.tools.ant.filters.ReplaceTokens
copy {
from 'src/com/comcast/telescope/Telescope.java'
into 'dist/com/comcast/telescope'
include '**/*.java'
filter(ReplaceTokens, beginToken:'Tel-', endToken:'-Tel', tokens: [IntVer: interfaceVersion])
}
中的文字Tel-IntVer-Tel
替换为Telescope.java
的值,因为它从interfaceVersion
复制到src/com/comcast/telescope
}
请注意,在我的示例中,您需要在某处设置dist/com/comcast/telescope
属性,例如在interfaceVersion
或ext
block.中。最后,我认为gradle.properties
是不必要的,因为只复制了一个文件,产生:
include