Search code examples
linuxwindowsgradlerelative-pathabsolute-path

Different behaviour of Gradles's zipTree on Unix and Windows?


I have SourceTask and I specify it's source property:

On Windows

source = zipTree("/src/main/resources/problems/problems.zip")

On Linux

source = zipTree(project.file(project.rootDir).path+"/src/main/resources/problems/problems.zip")

This code works but if On Linux I write the same as Windows Gradle says that the file do not exist.

Why on Windows Gradle takes the path as relative, but on Linux Gradle takes it as absolute


Solution

  • Probably because on Linux a leading slash means an absolute path. Did you try without the leading slash? E.g.:

    source = zipTree("src/main/resources/problems/problems.zip")