You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2018/02/06 11:07:57 UTC

[4/4] ant-antlibs-compress git commit: add read-only support for DEFLATE64

add read-only support for DEFLATE64


Project: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/commit/86bdc32f
Tree: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/tree/86bdc32f
Diff: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/diff/86bdc32f

Branch: refs/heads/master
Commit: 86bdc32f88652db4b3d710da343feb6fe8e69e3a
Parents: c3bdae5
Author: Stefan Bodewig <bo...@apache.org>
Authored: Tue Feb 6 12:07:15 2018 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Tue Feb 6 12:07:15 2018 +0100

----------------------------------------------------------------------
 changes.xml                                     |   9 ++++
 docs/compresource.html                          |   7 +++
 docs/index.html                                 |   6 ++-
 docs/unpack.html                                |   7 +++
 ivy.xml                                         |   4 +-
 src/main/org/apache/ant/compress/antlib.xml     |   8 +++
 .../compress/resources/Deflate64Resource.java   |  39 ++++++++++++++
 .../ant/compress/taskdefs/Undeflate64.java      |  39 ++++++++++++++
 .../compress/util/Deflate64StreamFactory.java   |  52 +++++++++++++++++++
 src/tests/antunit/un7z-test.xml                 |   9 ++++
 src/tests/antunit/undeflate64-test.xml          |  41 +++++++++++++++
 src/tests/resources/asf-logo.gif.deflate64.7z   | Bin 0 -> 7099 bytes
 12 files changed, 217 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/changes.xml
----------------------------------------------------------------------
diff --git a/changes.xml b/changes.xml
index 946954a..e1875b4 100644
--- a/changes.xml
+++ b/changes.xml
@@ -38,6 +38,15 @@
     </properties>
 
     <release version="1.6" date="unreleased">
+      <action type="update" breaks-bwc="true">
+        The Apache Compress Antlib now requires Apache Commons
+        Compress 1.16 or later for DEFLATE64 support.
+      </action>
+      <action type="add">
+        Added read-only support for the DEFLATE64 format. More
+        importantly we can now read zip and 7z entries using this
+        algorithm.
+      </action>
     </release>
     <release version="1.5" date="2017-06-13">
       <action type="update" breaks-bwc="true">

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/docs/compresource.html
----------------------------------------------------------------------
diff --git a/docs/compresource.html b/docs/compresource.html
index 714fece..57e85b3 100644
--- a/docs/compresource.html
+++ b/docs/compresource.html
@@ -109,6 +109,13 @@
     </tr>
   </table>
 
+<h2><a name="deflate64resource">deflate64resource</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.6</em>.</p>
+
+<p>This is a <a href="#compresource">compressed resource</a> using the
+  DEFLATE64 compression.</p>
+
 <h2><a name="gzipresource">gzipresource</a></h2>
 
 <p>This is a <a href="#compresource">compressed resource</a> using the

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/docs/index.html
----------------------------------------------------------------------
diff --git a/docs/index.html b/docs/index.html
index b16a16a..065030a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -29,10 +29,10 @@
       compression/uncompression and archival/unarchival capabilities
       based on <a href="http://commons.apache.org/compress/">Apache
       Commons Compress</a>.  Using Apache Commons Compress 1.14 this
-      Antlib supports gzip, bzip2, lzma standalone, xz, .Z, DEFLATE,
+      Antlib supports gzip, bzip2, lzma standalone, xz, .Z, DEFLATE, DEFLATE64,
       Snappy, LZ4, Brotli and pack200 compression and ar, arj, cpio,
       7z, Unix dump, tar and zip archives.  Support for arj, .Z,
-      Brotli and dump is read-only.  7z can only be used on filesystem
+      Brotli, DEFLATE64 and dump is read-only.  7z can only be used on filesystem
       resources.</p>
 
     <h3>Known Limitations</h3>
@@ -66,6 +66,7 @@
       <li><a href="unpack.html#unbrotli">unbrotli</a></li>
       <li><a href="expand.html#uncpio">uncpio</a></li>
       <li><a href="unpack.html#undeflate">undeflate</a></li>
+      <li><a href="unpack.html#undeflate64">undeflate64</a></li>
       <li><a href="expand.html#undump">undump</a></li>
       <li><a href="unpack.html#unlz4">unlz4</a></li>
       <li><a href="unpack.html#unlzma">unlzma</a></li>
@@ -92,6 +93,7 @@
       <li><a href="entry.html#cpioentry">cpioentry</a></li>
       <li><a href="fileset.html#cpiofileset">cpiofileset</a></li>
       <li><a href="compresource.html#deflateresource">deflateresource</a></li>
+      <li><a href="compresource.html#deflate64resource">deflate64resource</a></li>
       <li><a href="entry.html#dumpentry">dumpentry</a></li>
       <li><a href="fileset.html#dumpfileset">dumpfileset</a></li>
       <li><a href="compresource.html#gzipresource">gzipresource</a></li>

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/docs/unpack.html
----------------------------------------------------------------------
diff --git a/docs/unpack.html b/docs/unpack.html
index c47eae0..9167598 100644
--- a/docs/unpack.html
+++ b/docs/unpack.html
@@ -124,6 +124,13 @@ resource collection</h4>
     </tr>
   </table>
 
+<h3><a name="undeflate64">Undeflate64</a></h3>
+
+<p>Is an <a href="#unpack">uncompressing task</a> that uses the DEFLATE64
+  compression algorithm.</p>
+
+  <p><em>Since Compress Antlib 1.6</em>
+
 <h3><a name="unlz4">UnLZ4</a></h3>
 
 <p>Is an <a href="#unpack">uncompressing task</a> that uses the LZ4

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/ivy.xml
----------------------------------------------------------------------
diff --git a/ivy.xml b/ivy.xml
index c31ca03..9c3148d 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -29,8 +29,8 @@
     <description homepage="http://ant.apache.org/antlibs/compress/">
       Provides tasks and types that deal with AR, ARJ, CPIO, TAR,
       DUMP, 7Z and ZIP archives as well as BZIP2, PACK200, GZIP, LZMA,
-      Snappy, LZ4, Brotli and XZ compressed files based on Apache
-      Commons Compress.
+      Snappy, LZ4, Brotli, DEFLATE, DEFLATE64 and XZ compressed files
+      based on Apache Commons Compress.
     </description>
   </info>
   <configurations>

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/src/main/org/apache/ant/compress/antlib.xml
----------------------------------------------------------------------
diff --git a/src/main/org/apache/ant/compress/antlib.xml b/src/main/org/apache/ant/compress/antlib.xml
index e4c8354..027b28b 100644
--- a/src/main/org/apache/ant/compress/antlib.xml
+++ b/src/main/org/apache/ant/compress/antlib.xml
@@ -41,6 +41,10 @@
      classname="org.apache.ant.compress.taskdefs.Undeflate"
      />
   <taskdef
+     name="undeflate64"
+     classname="org.apache.ant.compress.taskdefs.Undeflate64"
+     />
+  <taskdef
      name="undump"
      classname="org.apache.ant.compress.taskdefs.Undump"
      />
@@ -215,6 +219,10 @@
      classname="org.apache.ant.compress.resources.DeflateResource"
      />
   <typedef
+     name="deflate64resource"
+     classname="org.apache.ant.compress.resources.Deflate64Resource"
+     />
+  <typedef
      name="gzipresource"
      classname="org.apache.ant.compress.resources.GZipResource"
      />

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/src/main/org/apache/ant/compress/resources/Deflate64Resource.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/ant/compress/resources/Deflate64Resource.java b/src/main/org/apache/ant/compress/resources/Deflate64Resource.java
new file mode 100644
index 0000000..e499e70
--- /dev/null
+++ b/src/main/org/apache/ant/compress/resources/Deflate64Resource.java
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.compress.resources;
+
+import org.apache.ant.compress.util.Deflate64StreamFactory;
+import org.apache.tools.ant.types.ResourceCollection;
+
+/**
+ * A DEFLATE64 compressed resource.
+ * @since Apache Compress Antlib 1.6
+ */
+public final class Deflate64Resource extends CommonsCompressCompressorResource {
+    private boolean zlibHeader = true;
+    private static final String NAME = "DEFLATE64";
+
+    public Deflate64Resource() {
+        super(NAME, new Deflate64StreamFactory());
+    }
+
+    public Deflate64Resource(ResourceCollection other) {
+        super(NAME, new Deflate64StreamFactory(), other);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/src/main/org/apache/ant/compress/taskdefs/Undeflate64.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/ant/compress/taskdefs/Undeflate64.java b/src/main/org/apache/ant/compress/taskdefs/Undeflate64.java
new file mode 100644
index 0000000..0b9a3f4
--- /dev/null
+++ b/src/main/org/apache/ant/compress/taskdefs/Undeflate64.java
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ant.compress.taskdefs;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import org.apache.ant.compress.util.Deflate64StreamFactory;
+import org.apache.commons.compress.compressors.CompressorInputStream;
+
+/**
+ * Expands a DEFLATE64 archive.
+ * @since Apache Compress Antlib 1.5
+ */
+public final class Undeflate64 extends UnpackBase {
+
+    private boolean zlibHeader = true;
+
+    public Undeflate64() {
+        super(".dfl64", new Deflate64StreamFactory());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/src/main/org/apache/ant/compress/util/Deflate64StreamFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/ant/compress/util/Deflate64StreamFactory.java b/src/main/org/apache/ant/compress/util/Deflate64StreamFactory.java
new file mode 100644
index 0000000..40a3701
--- /dev/null
+++ b/src/main/org/apache/ant/compress/util/Deflate64StreamFactory.java
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ant.compress.util;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.compress.compressors.CompressorInputStream;
+import org.apache.commons.compress.compressors.CompressorOutputStream;
+import org.apache.commons.compress.compressors.deflate64.Deflate64CompressorInputStream;
+
+/**
+ * Creates streams for the standalone DEFLATE64 format.
+ * @since Apache Compress Antlib 1.6
+ */
+public class Deflate64StreamFactory implements CompressorStreamFactory {
+
+    /**
+     * @param stream the stream to read from, should be buffered
+     */
+    @Override
+    public CompressorInputStream getCompressorStream(InputStream stream)
+        throws IOException {
+        return new Deflate64CompressorInputStream(stream);
+    }
+
+    /**
+     * @param stream the stream to write to, should be buffered
+     */
+    @Override
+    public CompressorOutputStream getCompressorStream(OutputStream stream)
+        throws IOException {
+        throw new UnsupportedOperationException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/src/tests/antunit/un7z-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/un7z-test.xml b/src/tests/antunit/un7z-test.xml
index 5e2fc13..2b2837f 100644
--- a/src/tests/antunit/un7z-test.xml
+++ b/src/tests/antunit/un7z-test.xml
@@ -108,4 +108,13 @@
        expected="../resources/asf-logo.gif"
        />
   </target>
+
+  <target name="testAgainstNative7zDeflate64" depends="setUp">
+    <cmp:un7z src="../resources/asf-logo.gif.deflate64.7z" dest="${output}" />
+    <au:assertFileExists file="${output}/asf-logo.gif"/>
+    <au:assertFilesMatch
+       actual="${output}/asf-logo.gif"
+       expected="../resources/asf-logo.gif"
+       />
+  </target>
 </project>

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/src/tests/antunit/undeflate64-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/undeflate64-test.xml b/src/tests/antunit/undeflate64-test.xml
new file mode 100644
index 0000000..1a5c336
--- /dev/null
+++ b/src/tests/antunit/undeflate64-test.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<project default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit"
+         xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
+         xmlns:cmp="antlib:org.apache.ant.compress">
+
+  <import file="antunit-base.xml" />
+
+  <target name="test1">
+    <au:expectfailure>
+      <cmp:undeflate64/>
+    </au:expectfailure>
+  </target>
+
+  <target name="test2">
+    <au:expectfailure>
+      <cmp:undeflate64 src=""/>
+    </au:expectfailure>
+  </target>
+
+  <!-- unfortunately I have no idea how to create a stand-alone
+       deflate64 file -->
+
+</project>

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/86bdc32f/src/tests/resources/asf-logo.gif.deflate64.7z
----------------------------------------------------------------------
diff --git a/src/tests/resources/asf-logo.gif.deflate64.7z b/src/tests/resources/asf-logo.gif.deflate64.7z
new file mode 100644
index 0000000..450fa0c
Binary files /dev/null and b/src/tests/resources/asf-logo.gif.deflate64.7z differ