Can't copy into root folder


(Sebastian Peters) #1

After having downloaded a set of ZIP dependencies, I need to extract them to my root project folder. This is what I got:

configurations {
    zipFiles
}

dependencies {
    zipFiles(
        'a.b.c:d@zip',
        'e.f.g:h@zip'
    )
}

task extractZip(type: Copy) {
    configurations.zipFiles.each { File file ->
        from zipTree(file)
        into ''
        doLast {
           println "Extracting file '${file.getName()}' to '${extractFolder}'"
        }
    }
}
build.dependsOn(extractZip)

But this gets me this error:

* What went wrong:
Neither path nor baseDir may be null or empty string.

Indeed, this only happens when I choose the root dir as folder. May I ask why it is prohibited to copy files to that location?


(Lance Java) #2

Whilst you can certainly do this (using into '.') unzipping into the project directory sounds like a really bad idea to me. Someone will likely accidentally commit to source control. The normal approach is to use subdirectory(s) under $buildDir which will get cleaned via gradle clean

Perhaps explain a bit more about what you’re trying to achieve