When I run the script on Linux, everything works fine. When I run the script on Windows, I get the error:
Could not resolve all dependencies for configuration ‘:MyProject:compile’. Could not normalize path for file ‘C:…’
The only way I could fix this issue was to check if the operating system is Windows, change all of the backslashes to forward slashes and ensure that every path contained a preceding forward slash i.e. /C:/path/to/dir;/C:/path/to/jar/myJar.jar;/C:/…etc.
I couldn’t find anything else online about this issue and it took me a while to find a solution, so I just thought I would post this in case anyone else runs into the same problem.
That’s still not correct. The ‘{’ after ‘compile’ needs to go, and ‘files’ needs to be passed a collection of file paths, not a class path. Something like:
I’ve edited my previous post to be in the correct format.
Splitting the classpath by path separator causes my build to hang. Having the classpath in its original format allows the build to compile successfully.
There may be other problems with your build script then. Your code effectively puts nothing on the compile class path, because there isn’t any single file or directory named ‘"/C:/path/to/dir;/C:/path/to/jar/myJar.jar;…"’. Unless ‘myClasspath’ isn’t a String, but a collection of Strings (but it doesn’t look like it).
Means that either none of the classes on the class path are used by the code to be compiled, or the class path is configured in some other way, or something else (e.g. an Ant task) is actually compiling the code. Impossible to say without knowing the details of your build.
The compiler is eventually passed a semicolon separated class path string. ‘files’, however, expects to be fed with a collection of individual file paths. Maybe it can be tricked in this way, but I wouldn’t put it to a test.