【问题标题】:How to combine multiple delete fileTree gradle tasks into single one如何将多个删除fileTree gradle任务组合成一个
【发布时间】:2021-03-16 12:38:12
【问题描述】:

我有以下 Gradle 任务来删除位于不同目录和不同模式的文件

task cleanNodeCertFiles(type: Delete) {
    delete fileTree("node_modules/sub_dir1").matching {
        include "**/*.key"
    }

    delete fileTree("node_modules/sub_dir1").matching {
        include "**/*.txt"
    }

    delete fileTree("node_modules/sub_dir2").matching {
        include "**/*.key"
    }

    delete fileTree("node_modules/sub_dir2").matching {
        include "**/*.txt"
    }

}

有没有办法将这 4 个删除 fileTree 命令优化为 2 个或 1 个?

【问题讨论】:

    标签: gradle build build.gradle


    【解决方案1】:

    不知道我是否正确,但您可以使用多个包含来做到这一点:

    task cleanNodeCertFiles(type: Delete) {
        delete fileTree("node_modules").matching {
            include "sub_dir1/**/*.key"
            include "sub_dir1/**/*.txt"
            include "sub_dir2/**/*.key"
            include "sub_dir2/**/*.txt"
        }
    }
    

    【讨论】:

    • 谢谢@bender316。我也在寻找同样的东西。
    猜你喜欢
    • 2021-01-30
    • 2013-10-23
    • 2010-12-25
    • 2014-08-05
    • 2015-12-02
    • 1970-01-01
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    相关资源
    最近更新 更多