diff --git a/WHATSNEW b/WHATSNEW index eb78fbff8..f3f61411f 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -232,6 +232,10 @@ Other changes: * now supports the GNU project's gcjh compiler. Bugzilla Report 50149. + * supports additional views of a file's path as elements + for a custom pattern. + Bugzilla Report 50114. + Changes from Ant 1.8.0 TO Ant 1.8.1 =================================== diff --git a/docs/manual/Tasks/checksum.html b/docs/manual/Tasks/checksum.html index d9e6e54e0..2ca9928cc 100644 --- a/docs/manual/Tasks/checksum.html +++ b/docs/manual/Tasks/checksum.html @@ -113,10 +113,16 @@ or set the fileext attribute. pattern Specifies the pattern to use as a pattern - suitable for MessageFormat + suitable + for MessageFormat where {0} is replaced with the checksum and - {1} with the file name. Since Ant 1.7.0 + {1} with the file name. Since Ant + 1.7.0
+ starting with Ant 1.8.2 {2} is replaced by + the path of the file relative to the checksum file being + written, {3} with tha path of the file relative to + the project's basedir and {4} with the absolute + path of the file. No - default is "{0}". diff --git a/src/main/org/apache/tools/ant/taskdefs/Checksum.java b/src/main/org/apache/tools/ant/taskdefs/Checksum.java index 5bc6aca68..523005a9c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Checksum.java +++ b/src/main/org/apache/tools/ant/taskdefs/Checksum.java @@ -61,6 +61,7 @@ import org.apache.tools.ant.util.StringUtils; */ public class Checksum extends MatchingTask implements Condition { + private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final int NIBBLE = 4; private static final int WORD = 16; private static final int BUFFER_SIZE = 8 * 1024; @@ -531,6 +532,15 @@ public class Checksum extends MatchingTask implements Condition { fos.write(format.format(new Object[] { checksum, src.getName(), + FILE_UTILS + .getRelativePath(dest + .getParentFile(), + src), + FILE_UTILS + .getRelativePath(getProject() + .getBaseDir(), + src), + src.getAbsolutePath() }).getBytes()); fos.write(StringUtils.LINE_SEP.getBytes()); fos.close(); diff --git a/src/tests/antunit/taskdefs/checksum-test.xml b/src/tests/antunit/taskdefs/checksum-test.xml index 022a6dbcf..8341f4253 100644 --- a/src/tests/antunit/taskdefs/checksum-test.xml +++ b/src/tests/antunit/taskdefs/checksum-test.xml @@ -45,4 +45,39 @@ value="f4d688789d32e6ca6bc93c504dbc6b46"/> + + + + abc + + + + + + + + + + + + + + + + + + + abc + + + + + +