We have a problem with several people using Windows and Maven, and I suspect the issue is with the ${path.separator}. They get an error that a directory "D:\basedir\target/dist" does not exist. We don't get this error on Mac, Linux, and Unix systems.
I'd like to change this to be ${project.build.directory}${path.separator}dist, but on a Mac, the value of ${path.separator} is : and not /. Now my build is failing on Macs because /Users/david/project/target:dist isn't a valid directory.
How can I set my default ${path.separator} on the Mac to be /?
The path separator is a character commonly used by the operating system to separate individual paths in a list of paths.
A file separator is a character that is used to separate directory names that make up a path to a particular location. This character is operating system specific. On Microsoft Windows, it is a back-slash character (), e.g. C:myprojectmyfilesome.
If you prefer to hard-code the directory separator character, you should use the forward slash ( / ) character. It is the only recognized directory separator character on Unix systems, as the output from the example shows, and is the AltDirectorySeparatorChar on Windows.
In Windows you can use either \ or / as a directory separator.
Just to close this out...
I wanted ${file.separator} and not ${path.separator}. ${path.separator} is what is used to separate directory names in paths. On Windows, it's ; and on Mac and Unix, it's :.
${file.separator} is the directory separator mark. On Windows, it's \ and on Unix and Macs it's `/'.
I got confused because on the older System X Macs, the file separator was :. I normally just use /, but in this one project, that didn't work.
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