Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle how to create an empty fileCollection?

def mergedCompileClasspath == null
project.sourceSets.each {
        if (mergedCompileClasspath == null)
            mergedCompileClasspath = it.compileClasspath
        else    
            mergedCompileClasspath .plus(it.compileClasspath)

}

The plus() method is not working. compileClassPath is immutable? How to create an empty fileCollection?

like image 221
eastwater Avatar asked Jul 27 '17 16:07

eastwater


1 Answers

You can call Project.files() with an empty collection.

def emptyFileCollection = project.files([])

Update:

As of Gradle 5.3 you can also use the ObjectFactory.fileCollection() method.

def emptyFileCollection = project.objects.fileCollection()
like image 62
Mark Vieira Avatar answered Sep 22 '22 06:09

Mark Vieira