ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1195847 - in /ant/antlibs/compress/trunk: changes.xml src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java src/main/org/apache/ant/compress/taskdefs/Tar.java src/tests/antunit/tar-test.xml
Date Tue, 01 Nov 2011 06:55:21 GMT
Author: bodewig
Date: Tue Nov  1 06:55:20 2011
New Revision: 1195847

URL: http://svn.apache.org/viewvc?rev=1195847&view=rev
Log:
make preserveleadingslashes work for tar

Modified:
    ant/antlibs/compress/trunk/changes.xml
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java
    ant/antlibs/compress/trunk/src/tests/antunit/tar-test.xml

Modified: ant/antlibs/compress/trunk/changes.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/changes.xml?rev=1195847&r1=1195846&r2=1195847&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/changes.xml (original)
+++ ant/antlibs/compress/trunk/changes.xml Tue Nov  1 06:55:20 2011
@@ -79,5 +79,9 @@
         (like encrypted ZIP entries or sparse files in GNU tar
         archives).
       </action>
+      <action type="update">
+        The preserveLeadingSlashes attribute of the &lt;tar&gt; task
+        now works as expected.
+      </action>
     </release>
   </document>

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java?rev=1195847&r1=1195846&r2=1195847&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
(original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
Tue Nov  1 06:55:20 2011
@@ -238,6 +238,15 @@ public abstract class ArchiveBase extend
     }
 
     /**
+     * Flag to indicates whether leading `/'s should
+     * be preserved in the file names.
+     * @since Apache Compress Antlib 1.1
+     */
+    public boolean getPreserveLeadingSlashes() {
+        return preserveLeadingSlashes;
+    }
+
+    /**
      * Sets behavior for when a duplicate file is about to be added -
      * one of <code>add</code>, <code>preserve</code> or <code>fail</code>.
      * Possible values are: <code>add</code> (keep both

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java?rev=1195847&r1=1195846&r2=1195847&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java Tue Nov
 1 06:55:20 2011
@@ -55,10 +55,14 @@ public class Tar extends ArchiveBase {
               new ArchiveBase.EntryBuilder() {
                 public ArchiveEntry buildEntry(ArchiveBase.ResourceWithFlags r) {
                     boolean isDir = r.getResource().isDirectory();
+                    String name = r.getName();
+                    if (isDir && !name.endsWith("/")) {
+                        name += "/";
+                    } else if (!isDir && name.endsWith("/")) {
+                        name = name.substring(0, name.length() - 1);
+                    }
                     TarArchiveEntry ent =
-                        new TarArchiveEntry(r.getName(),
-                                            isDir ? TarConstants.LF_DIR
-                                            : TarConstants.LF_NORMAL);
+                        new TarArchiveEntry(name, getPreserveLeadingSlashes());
                     ent.setModTime(round(r.getResource().getLastModified(),
                                          1000));
                     ent.setSize(isDir ? 0 : r.getResource().getSize());

Modified: ant/antlibs/compress/trunk/src/tests/antunit/tar-test.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/tar-test.xml?rev=1195847&r1=1195846&r2=1195847&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/tar-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/tar-test.xml Tue Nov  1 06:55:20 2011
@@ -356,9 +356,7 @@
     </assertResourceDoesntExist>
   </target>
 
-  <!-- doesn't work because TarEntry strips leading slashes, will be
-       fixed for Apache Commons Compress 1.1 -->
-  <target name="fail-testPreserveLeadingSlashes" depends="setUp">
+  <target name="testPreserveLeadingSlashes" depends="setUp">
     <cmp:tar destfile="${dest}" preserveleadingslashes="true">
       <cmp:arfileset src="../resources/asf-logo.gif.ar"
                      fullpath="/logo.gif"



Mime
View raw message