@@ -457,15 +457,7 @@ public class Checksum extends MatchingTask implements Condition {
File directory;
File directory;
if (todir != null) {
if (todir != null) {
// A separate directory was explicitly declared
// A separate directory was explicitly declared
String path = (String) relativeFilePaths.get(file);
if (path == null) {
//bug 37386. this should not occur, but it has, once.
throw new BuildException(
"Internal error: "
+ "relativeFilePaths could not match file"
+ file + "\n"
+ "please file a bug report on this");
}
String path = getRelativeFilePath(file);
directory = new File(todir, path).getParentFile();
directory = new File(todir, path).getParentFile();
// Create the directory, as it might not exist.
// Create the directory, as it might not exist.
directory.mkdirs();
directory.mkdirs();
@@ -559,8 +551,8 @@ public class Checksum extends MatchingTask implements Condition {
File f2 = (File) o2;
File f2 = (File) o2;
return f1 == null ? (f2 == null ? 0 : -1)
return f1 == null ? (f2 == null ? 0 : -1)
: (f2 == null ? 1
: (f2 == null ? 1
: f1.getName().compareTo(f2.getName() )
);
: getRelativeFilePath(f1 )
.compareTo(getRelativeFilePath(f2)) );
}
}
});
});
// Loop over the checksums and generate a total hash.
// Loop over the checksums and generate a total hash.
@@ -573,7 +565,7 @@ public class Checksum extends MatchingTask implements Condition {
messageDigest.update(digest);
messageDigest.update(digest);
// Add the file path
// Add the file path
String fileName = (String) relativeFilePaths.get (src);
String fileName = getRelativeFilePath (src);
messageDigest.update(fileName.getBytes());
messageDigest.update(fileName.getBytes());
}
}
String totalChecksum = createDigestString(messageDigest.digest());
String totalChecksum = createDigestString(messageDigest.digest());
@@ -654,6 +646,21 @@ public class Checksum extends MatchingTask implements Condition {
}
}
}
}
/**
* @since Ant 1.8.2
*/
private String getRelativeFilePath(File f) {
String path = (String) relativeFilePaths.get(f);
if (path == null) {
//bug 37386. this should not occur, but it has, once.
throw new BuildException("Internal error: "
+ "relativeFilePaths could not match file "
+ f + "\n"
+ "please file a bug report on this");
}
return path;
}
/**
/**
* Helper class for the format attribute.
* Helper class for the format attribute.
*
*