Is it ok to use forward slashes instead of File.separator in my (Gradle) build files?

The forward slash (/) is a legal path separator on Windows, as well as Unix (including Linux and Mac OSX). So unless you need the build to run on other operating systems, it shouldn't be a problem.


Gradle for the most part just relies on java.io.File to do all path related operations, which in turn gracefully handles / on both Windows and Linux. So using / in Gradle API is unlikely to cause any problems.

I am using / in a fairly large project which runs on both Windows and Linux, and so far I hadn't a single problem. Hope this helps.

Tags:

Java

Gradle