I recently wrote a build.gradle script that does the following (using Gradle 1.7):
Build a classpath using a custom ant task. The resulting classpath would be in the form of C:\path\to\dir;C:\another\path\to\jar\myJar.jar;etc…
Assign the above classpath to a project property e.g. ext.myClasspath = ant.properties[‘ant.generated.classpath’]
In my dependecies I added the following:
<dependencies> <compile> files("$myClasspath") </compile> </dependencies>
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.