I copied maven-surefire-plugin code, and patched gradle. it worked well.
diff --git a/subprojects/base-services/src/main/java/org/gradle/internal/FileUtils.java b/subprojects/base-services/src/main/java/org/gradle/internal/FileUtils.java
index 1bb4cb7..570f477 100644
--- a/subprojects/base-services/src/main/java/org/gradle/internal/FileUtils.java
+++ b/subprojects/base-services/src/main/java/org/gradle/internal/FileUtils.java
@@ -27,27 +27,30 @@ import java.util.List;
public class FileUtils {
public static final int WINDOWS_PATH_LIMIT = 260;
+ private static String getOSSpecificIllegalChars()
+ {
+ if ( System.getProperty( "os.name" ).toLowerCase().startsWith( "win" ) )
+ {
+ return "\\/:*?\"<>|\0";
+ }
+ else
+ {
+ return "/\0";
+ }
+ }
+
/**
* Converts a string into a string that is safe to use as a file name. The result will only include ascii characters and numbers, and the "-","_", #, $ and "." characters.
*/
public static String toSafeFileName(String name) {
- int size = name.length();
- StringBuffer rc = new StringBuffer(size * 2);
- for (int i = 0; i < size; i++) {
- char c = name.charAt(i);
- boolean valid = c >= 'a' && c <= 'z';
- valid = valid || (c >= 'A' && c <= 'Z');
- valid = valid || (c >= '0' && c <= '9');
- valid = valid || (c == '_') || (c == '-') || (c == '.') || (c == '$');
- if (valid) {
- rc.append(c);
- } else {
- // Encode the character using hex notation
- rc.append('#');
- rc.append(Integer.toHexString(c));
- }
+ String result = name;
+ String illegalChars = getOSSpecificIllegalChars();
+ for ( int i = 0; i < illegalChars.length(); i++ )
+ {
+ result = result.replace( illegalChars.charAt( i ), '_' );
}
- return rc.toString();
+
+ return result;
}
public static File assertInWindowsPathLengthLimitation(File file) {