复制文件时如何过滤渐变?如果令牌以“0”开头;电话-“;并以“-电话“;将令牌替换为V2



渐变脚本

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>

我得到了复制文件的顶部,但在复制时我一直在过滤文件。有人能帮我吗?

您需要在CopySpec中添加对filter的调用。

基于原始Ant脚本,您需要:

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])
 }

这使用ReplaceTokens将Telescope.java中的文字文本Tel-IntVer-Tel替换为interfaceVersion的值,因为它是从src/com/comcast/telescope复制到dist/com/comcast/telescope

请注意,在我的示例中,您需要将interfaceVersion属性设置在某个位置,如gradle.propertiesext块中。最后,我认为include是不必要的,因为只有一个文件被复制,产生:

import org.apache.tools.ant.filters.ReplaceTokens
copy {
    from 'src/com/comcast/telescope/Telescope.java'
    into 'dist/com/comcast/telescope'
    filter(ReplaceTokens, beginToken:'Tel-', endToken:'-Tel', tokens: [IntVer: interfaceVersion])
 }

相关内容

  • 没有找到相关文章

最新更新