【问题标题】:Gradle how to create an empty fileCollection?Gradle如何创建一个空的fileCollection?
【发布时间】:2017-07-27 16:20:40
【问题描述】:
def mergedCompileClasspath == null
project.sourceSets.each {
        if (mergedCompileClasspath == null)
            mergedCompileClasspath = it.compileClasspath
        else    
            mergedCompileClasspath .plus(it.compileClasspath)

}

plus() 方法不起作用。 compileClassPath 是不可变的?如何创建一个空的fileCollection?

【问题讨论】:

    标签: file gradle collections classpath


    【解决方案1】:

    您可以使用空集合调用Project.files()

    def emptyFileCollection = project.files([])
    

    更新:

    从 Gradle 5.3 开始,您还可以使用 ObjectFactory.fileCollection() 方法。

    def emptyFileCollection = project.objects.fileCollection()
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-23
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 2020-04-30
    相关资源
    最近更新 更多