I don't see any obvious problems, but I'm wondering if it's ok to use / rather than File.separator when I'm writing my build files. Using File.separator makes it very difficult to read some of the paths. Ex:
dependsDir = "${buildDir}${File.separator}depends"
vs
dependsDir = "${buildDir}/depends"
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.
in File Class
public static final String separator = "" + separatorChar;
where separatorChar is The system-dependent default name-separator character. This field is
initialized to contain the first character of the value of the system
property file.separator. On UNIX systems the value of this
field is '/'; on Microsoft Windows systems it is '\'.
and the separatorChar created from
static private FileSystem fs = FileSystem.getFileSystem();
public static final char separatorChar = fs.getSeparator();
For you based on your operating system the separator will be changed, while using File.separator.
by using / in your code, it won't support for other OS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With