ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r801808 - in /ant/sandbox/antlibs/compress/trunk/src: main/org/apache/ant/compress/ main/org/apache/ant/compress/resources/ tests/antunit/
Date Thu, 06 Aug 2009 20:14:48 GMT
Author: bodewig
Date: Thu Aug  6 20:14:47 2009
New Revision: 801808

URL: http://svn.apache.org/viewvc?rev=801808&view=rev
Log:
zipfileset

Added:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java
  (contents, props changed)
      - copied, changed from r801240, ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
  (contents, props changed)
      - copied, changed from r801240, ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml   (contents,
props changed)
      - copied, changed from r801240, ant/core/trunk/src/tests/antunit/types/zipfileset-test.xml
Modified:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ArScanner.java
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioScanner.java
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarScanner.java

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=801808&r1=801807&r2=801808&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 Thu Aug
 6 20:14:47 2009
@@ -62,4 +62,8 @@
     name="cpiofileset"
     classname="org.apache.ant.compress.resources.CpioFileSet"
     />
+  <typedef
+    name="zipfileset"
+    classname="org.apache.ant.compress.resources.ZipFileSet"
+    />
 </antlib>

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ArScanner.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ArScanner.java?rev=801808&r1=801807&r2=801808&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ArScanner.java
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ArScanner.java
Thu Aug  6 20:14:47 2009
@@ -32,7 +32,8 @@
  */
 public class ArScanner extends CommonsCompressArchiveScanner {
 
-    protected ArchiveInputStream getArchiveStream(InputStream is)
+    protected ArchiveInputStream getArchiveStream(InputStream is,
+                                                  String encoding)
         throws IOException {
         return new ArArchiveInputStream(is);
     }

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java?rev=801808&r1=801807&r2=801808&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
Thu Aug  6 20:14:47 2009
@@ -37,7 +37,8 @@
     /**
      * Provides an ArchiveInputStream to a given archive.
      */
-    protected abstract ArchiveInputStream getArchiveStream(InputStream is)
+    protected abstract ArchiveInputStream getArchiveStream(InputStream is,
+                                                           String encoding)
         throws IOException;
 
     /**
@@ -72,7 +73,7 @@
 
         try {
             try {
-                ai = getArchiveStream(src.getInputStream());
+                ai = getArchiveStream(src.getInputStream(), encoding);
             } catch (IOException ex) {
                 throw new BuildException("problem opening " + src, ex);
             }

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioScanner.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioScanner.java?rev=801808&r1=801807&r2=801808&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioScanner.java
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioScanner.java
Thu Aug  6 20:14:47 2009
@@ -32,7 +32,8 @@
  */
 public class CpioScanner extends CommonsCompressArchiveScanner {
 
-    protected ArchiveInputStream getArchiveStream(InputStream is)
+    protected ArchiveInputStream getArchiveStream(InputStream is,
+                                                  String encoding)
         throws IOException {
         return new CpioArchiveInputStream(is);
     }

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarScanner.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarScanner.java?rev=801808&r1=801807&r2=801808&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarScanner.java
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarScanner.java
Thu Aug  6 20:14:47 2009
@@ -32,7 +32,8 @@
  */
 public class TarScanner extends CommonsCompressArchiveScanner {
 
-    protected ArchiveInputStream getArchiveStream(InputStream is)
+    protected ArchiveInputStream getArchiveStream(InputStream is,
+                                                  String encoding)
         throws IOException {
         return new TarArchiveInputStream(is);
     }

Copied: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java
(from r801240, ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java)
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java?p2=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java&r1=801240&r2=801808&rev=801808&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java (original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java
Thu Aug  6 20:14:47 2009
@@ -15,10 +15,15 @@
  *  limitations under the License.
  *
  */
-package org.apache.tools.ant.types;
+package org.apache.ant.compress.resources;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.AbstractFileSet;
+import org.apache.tools.ant.types.ArchiveFileSet;
+import org.apache.tools.ant.types.ArchiveScanner;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Reference;
 
 /**
  * A ZipFileSet is a FileSet with extra attributes useful in the context of
@@ -28,8 +33,6 @@
  * entries of a Zip file for inclusion in another Zip file.  It also includes
  * a prefix attribute which is prepended to each entry in the output Zip file.
  *
- * Since ant 1.6 ZipFileSet can be defined with an id and referenced in packaging tasks
- *
  */
 public class ZipFileSet extends ArchiveFileSet {
 
@@ -60,7 +63,6 @@
     /**
      * Set the encoding used for this ZipFileSet.
      * @param enc encoding as String.
-     * @since Ant 1.7
      */
     public void setEncoding(String enc) {
         checkZipFileSetAttributesAllowed();
@@ -70,7 +72,6 @@
     /**
      * Get the encoding used for this ZipFileSet.
      * @return String encoding.
-     * @since Ant 1.7
      */
     public String getEncoding() {
         if (isReference()) {

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

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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

Copied: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
(from r801240, ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java)
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java?p2=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java&r1=801240&r2=801808&rev=801808&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java (original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
Thu Aug  6 20:14:47 2009
@@ -16,25 +16,39 @@
  *
  */
 
-package org.apache.tools.ant.types;
+package org.apache.ant.compress.resources;
 
 import java.io.File;
+import java.io.InputStream;
 import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Map;
 import java.util.zip.ZipException;
 
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipFile;
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.resources.FileResource;
-import org.apache.tools.ant.types.resources.ZipResource;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.resources.FileProvider;
-import org.apache.tools.zip.ZipEntry;
-import org.apache.tools.zip.ZipFile;
 
 /**
  * Scans zip archives for resources.
  */
-public class ZipScanner extends ArchiveScanner {
+public class ZipScanner extends CommonsCompressArchiveScanner {
+
+    protected ArchiveInputStream getArchiveStream(InputStream is,
+                                                  String encoding)
+        throws IOException {
+        return new ZipArchiveInputStream(is, encoding, true);
+    }
+
+    protected Resource getResource(Resource archive, String encoding,
+                                   ArchiveEntry entry) {
+        return new ZipResource(archive, encoding, (ZipArchiveEntry) entry);
+    }
 
     /**
      * Fills the file and directory maps with resources read from the
@@ -56,7 +70,7 @@
     protected void fillMapsFromArchive(Resource src, String encoding,
                                        Map fileEntries, Map matchFileEntries,
                                        Map dirEntries, Map matchDirEntries) {
-        ZipEntry entry = null;
+        ZipArchiveEntry entry = null;
         ZipFile zf = null;
 
         File srcFile = null;
@@ -64,7 +78,10 @@
         if (fp != null) {
             srcFile = fp.getFile();
         } else {
-            throw new BuildException("Only file provider resources are supported");
+            super.fillMapsFromArchive(src, encoding, fileEntries,
+                                      matchFileEntries, dirEntries,
+                                      matchDirEntries);
+            return;
         }
 
         try {
@@ -77,7 +94,7 @@
             }
             Enumeration e = zf.getEntries();
             while (e.hasMoreElements()) {
-                entry = (ZipEntry) e.nextElement();
+                entry = (ZipArchiveEntry) e.nextElement();
                 Resource r = new ZipResource(srcFile, encoding, entry);
                 String name = entry.getName();
                 if (entry.isDirectory()) {

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

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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

Copied: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml (from r801240,
ant/core/trunk/src/tests/antunit/types/zipfileset-test.xml)
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml?p2=ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml&p1=ant/core/trunk/src/tests/antunit/types/zipfileset-test.xml&r1=801240&r2=801808&rev=801808&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/types/zipfileset-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml Thu Aug  6 20:14:47
2009
@@ -15,21 +15,23 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">
-  <import file="../antunit-base.xml"/>
+<project default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit"
+         xmlns:cmp="antlib:org.apache.ant.compress">
+  <import file="antunit-base.xml"/>
 
   <target name="test-refid-modify">
     <fileset id="modify-refid-1"
              dir="${basedir}"
              includes="*.xml"
              />
-    <zipfileset id="modify-refid-2"
+    <cmp:zipfileset id="modify-refid-2"
                 refid="modify-refid-1"
                 prefix="WEB-INF/lib/"/>
     <delete quiet="yes" dir="${build.dir}"/>
     <mkdir dir="${output}"/>
     <jar jarfile="${output}/jar.jar">
-      <zipfileset refid="modify-refid-2"/>
+      <cmp:zipfileset refid="modify-refid-2"/>
     </jar>
     <unjar src="${output}/jar.jar"
            dest="${output}"/>
@@ -39,26 +41,26 @@
   </target>
 
   <target name="test-refid-check-prefix">
-    <zipfileset id="test-refid"
+    <cmp:zipfileset id="test-refid"
                 dir="${basedir}"/>
     <au:expectfailure>
-      <zipfileset id="ref2"
+      <cmp:zipfileset id="ref2"
                   refid="test-refid"
                   prefix="WEB-INF/lib/"/>
     </au:expectfailure>
     <au:expectfailure>
-      <zipfileset id="ref3"
+      <cmp:zipfileset id="ref3"
                   prefix="WEB-INF/lib/"
                   ReFiD="test-refid"/>
     </au:expectfailure>
   </target>
 
   <target name="test-refid-check-encoding">
-    <zipfileset id="test-refid2"
+    <cmp:zipfileset id="test-refid2"
                 encoding="utf-8"
                 dir="${basedir}"/>
     <au:expectfailure>
-      <zipfileset id="ref4"
+      <cmp:zipfileset id="ref4"
                   encoding="utf-8"
                   refid="test-refid2"/>
     </au:expectfailure>
@@ -68,7 +70,7 @@
     <mkdir dir="${output}"/>
     <au:expectfailure expectedMessage="The archive foo.zip doesn't exist">
       <copy todir="${output}">
-        <zipfileset src="foo.zip"/>
+        <cmp:zipfileset src="foo.zip"/>
       </copy>
     </au:expectfailure>
   </target>
@@ -76,7 +78,7 @@
   <target name="testMissingArchiveDoesntMatter">
     <mkdir dir="${output}"/>
     <copy todir="${output}">
-      <zipfileset src="foo.zip" errorOnMissingArchive="false"/>
+      <cmp:zipfileset src="foo.zip" errorOnMissingArchive="false"/>
     </copy>
   </target>
 

Propchange: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml
------------------------------------------------------------------------------
    svn:mergeinfo = 



Mime
View raw message