Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 63888 invoked from network); 11 Mar 2002 21:48:31 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 11 Mar 2002 21:48:31 -0000 Received: (qmail 9552 invoked by uid 97); 11 Mar 2002 21:48:33 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 9531 invoked by uid 97); 11 Mar 2002 21:48:31 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 9520 invoked from network); 11 Mar 2002 21:48:31 -0000 Message-ID: <3C8D1F96.A4F4E383@sorpen.demon.co.uk> Date: Mon, 11 Mar 2002 21:20:22 +0000 From: Rod Mackenzie Reply-To: Ant Developers List X-Mailer: Mozilla 4.61 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: ant-dev@jakarta.apache.org Subject: [PATCH] Tar task should use tarfileset dir attribute for update checks Content-Type: multipart/mixed; boundary="------------9BD5940049617B4128843AD2" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --------------9BD5940049617B4128843AD2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit The Tar task doesn't use the dir attribute for tarfilesets when determining if the tar file is up to date, so updated files or new files never get added. Attached is a fix and test case. Rod --------------9BD5940049617B4128843AD2 Content-Type: text/plain; charset=us-ascii; name="tar.xml.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tar.xml.diff" Index: tar.xml =================================================================== RCS file: /home/cvspublic/jakarta-ant/src/etc/testcases/taskdefs/tar.xml,v retrieving revision 1.9 diff -u -r1.9 tar.xml --- tar.xml 4 Feb 2002 20:44:16 -0000 1.9 +++ tar.xml 11 Mar 2002 20:53:26 -0000 @@ -53,7 +53,24 @@ - + + + + + + + + + + + + + + + + + + @@ -63,6 +80,10 @@ + + + + --------------9BD5940049617B4128843AD2 Content-Type: text/plain; charset=us-ascii; name="Tar.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Tar.diff" Index: Tar.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tar.java,v retrieving revision 1.26 diff -u -r1.26 Tar.java --- Tar.java 3 Mar 2002 01:46:20 -0000 1.26 +++ Tar.java 11 Mar 2002 21:00:17 -0000 @@ -227,8 +227,9 @@ for (Enumeration e = filesets.elements(); e.hasMoreElements();) { TarFileSet fs = (TarFileSet)e.nextElement(); String[] files = fs.getFiles(project); + File dir = (baseDir == null) ? fs.getDir(project) : baseDir; - if (!archiveIsUpToDate(files)) { + if (!archiveIsUpToDate(dir, files)) { upToDate = false; } @@ -305,11 +306,11 @@ if (vPath.length() <= 0) { return; } - + if (file.isDirectory() && !vPath.endsWith("/")) { vPath += "/"; } - + String prefix = tarFileSet.getPrefix(); // '/' is appended for compatibility with the zip task. if (prefix.length() > 0 && !prefix.endsWith("/")) { @@ -323,7 +324,7 @@ if (l <= 1) { // we would end up adding "" to the archive return; - } + } vPath = vPath.substring(1, l); } @@ -377,11 +378,11 @@ } } - protected boolean archiveIsUpToDate(String[] files) { + protected boolean archiveIsUpToDate(File dir, String[] files) { SourceFileScanner sfs = new SourceFileScanner(this); MergingMapper mm = new MergingMapper(); mm.setTo(tarFile.getAbsolutePath()); - return sfs.restrict(files, baseDir, null, mm).length == 0; + return sfs.restrict(files, dir, null, mm).length == 0; } public static class TarFileSet extends FileSet { @@ -394,7 +395,7 @@ private String prefix = ""; private String fullpath = ""; private boolean preserveLeadingSlashes = false; - + public TarFileSet(FileSet fileset) { super(fileset); } --------------9BD5940049617B4128843AD2 Content-Type: text/plain; charset=us-ascii; name="TarTest.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TarTest.diff" Index: TarTest.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/TarTest.java,v retrieving revision 1.9 diff -u -r1.9 TarTest.java --- TarTest.java 4 Feb 2002 20:44:16 -0000 1.9 +++ TarTest.java 11 Mar 2002 20:52:13 -0000 @@ -124,6 +124,15 @@ } } + public void test9() { + executeTarget("test9"); + java.io.File f1 + = new java.io.File("src/etc/testcases/taskdefs/test9dir/test9b.txt"); + if (!f1.exists()) { + fail("Updating a tar file failed"); + } + } + public void tearDown() { executeTarget("cleanup"); } --------------9BD5940049617B4128843AD2 Content-Type: text/plain; charset=us-ascii -- To unsubscribe, e-mail: For additional commands, e-mail: --------------9BD5940049617B4128843AD2--