Author: bodewig
Date: Sun Aug 16 05:51:38 2009
New Revision: 804627

URL: http://svn.apache.org/viewvc?rev=804627&view=rev
Log:
zip task

Added:
    
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java
   (contents, props changed)
      - copied, changed from r804624, 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java
Modified:
    
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/unzip-test.xml

Modified: 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
URL: 
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=804627&r1=804626&r2=804627&view=diff
==============================================================================
--- 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml 
(original)
+++ 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml 
Sun Aug 16 05:51:38 2009
@@ -44,6 +44,10 @@
     name="tar"
     classname="org.apache.ant.compress.taskdefs.Tar"
     />
+  <taskdef
+    name="zip"
+    classname="org.apache.ant.compress.taskdefs.Zip"
+    />
 
   <typedef
     name="tarentry"

Copied: 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java
 (from r804624, 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java)
URL: 
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java?p2=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java&p1=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java&r1=804624&r2=804627&rev=804627&view=diff
==============================================================================
--- 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java
 (original)
+++ 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java
 Sun Aug 16 05:51:38 2009
@@ -18,59 +18,36 @@
 
 package org.apache.ant.compress.taskdefs;
 
-import org.apache.ant.compress.util.TarStreamFactory;
+import org.apache.ant.compress.util.ZipStreamFactory;
 import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarConstants;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 
 /**
- * Creates tar archives.
+ * Creates zip archives.
  */
-public class Tar extends ArchiveBase {
-    public Tar() {
-        super(new TarStreamFactory(),
+public class Zip extends ArchiveBase {
+    public Zip() {
+        super(new ZipStreamFactory(),
               new ArchiveBase.EntryBuilder() {
                 public ArchiveEntry buildEntry(ArchiveBase.ResourceWithFlags 
r) {
                     boolean isDir = r.getResource().isDirectory();
-                    TarArchiveEntry ent =
-                        new TarArchiveEntry(r.getName(),
-                                            isDir ? TarConstants.LF_DIR
-                                            : TarConstants.LF_NORMAL);
-                    ent.setModTime(r.getResource().getLastModified());
+                    ZipArchiveEntry ent = new ZipArchiveEntry(r.getName());
+                    ent.setTime(r.getResource().getLastModified());
                     ent.setSize(isDir ? 0 : r.getResource().getSize());
 
                     if (r.getResourceFlags().hasModeBeenSet()) {
-                        ent.setMode(r.getResourceFlags().getMode());
+                        ent.setUnixMode(r.getResourceFlags().getMode());
                     } else if (!isDir
                                && r.getCollectionFlags().hasModeBeenSet()) {
-                        ent.setMode(r.getCollectionFlags().getMode());
+                        ent.setUnixMode(r.getCollectionFlags().getMode());
                     } else if (isDir
                                && r.getCollectionFlags().hasDirModeBeenSet()) {
-                        ent.setMode(r.getCollectionFlags().getDirMode());
+                        ent.setUnixMode(r.getCollectionFlags().getDirMode());
                     }
 
-                    if (r.getResourceFlags().hasUserIdBeenSet()) {
-                        ent.setUserId(r.getResourceFlags().getUserId());
-                    } else if (r.getCollectionFlags().hasUserIdBeenSet()) {
-                        ent.setUserId(r.getCollectionFlags().getUserId());
-                    }
-
-                    if (r.getResourceFlags().hasGroupIdBeenSet()) {
-                        ent.setGroupId(r.getResourceFlags().getGroupId());
-                    } else if (r.getCollectionFlags().hasGroupIdBeenSet()) {
-                        ent.setGroupId(r.getCollectionFlags().getGroupId());
-                    }
- 
-                    if (r.getResourceFlags().hasUserNameBeenSet()) {
-                        ent.setUserName(r.getResourceFlags().getUserName());
-                    } else if (r.getCollectionFlags().hasUserNameBeenSet()) {
-                        ent.setUserName(r.getCollectionFlags().getUserName());
-                    }
-
-                    if (r.getResourceFlags().hasGroupNameBeenSet()) {
-                        ent.setGroupName(r.getResourceFlags().getGroupName());
-                    } else if (r.getCollectionFlags().hasGroupNameBeenSet()) {
-                        
ent.setGroupName(r.getCollectionFlags().getGroupName());
+                    if (r.getResourceFlags().getZipExtraFields() != null) {
+                        ent.setExtraFields(r.getResourceFlags()
+                                           .getZipExtraFields());
                     }
  
                     return ent;

Propchange: 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/unzip-test.xml
URL: 
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/unzip-test.xml?rev=804627&r1=804626&r2=804627&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/unzip-test.xml 
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/unzip-test.xml Sun Aug 
16 05:51:38 2009
@@ -38,7 +38,19 @@
        />
   </target>
 
-  <target name="testAgainstNativeTar" depends="setUp">
+  <target name="testAgainstAntlibZipTask" depends="setUp">
+    <cmp:zip destfile="${input}/test.zip">
+      <fileset dir="."/>
+    </cmp:zip>
+    <cmp:unzip src="${input}/test.zip" dest="${output}"/>
+    <au:assertFileExists file="${output}/untar-test.xml"/>
+    <au:assertFilesMatch
+       actual="${output}/untar-test.xml"
+       expected="untar-test.xml"
+       />
+  </target>
+
+  <target name="testAgainstNativeZip" depends="setUp">
     <cmp:unzip src="../resources/asf-logo.gif.zip" dest="${output}" />
     <au:assertFileExists file="${output}/asf-logo.gif"/>
     <au:assertFilesMatch


Reply via email to