Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id ABF64200C6D for ; Sun, 7 May 2017 18:15:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A7A69160BB1; Sun, 7 May 2017 16:15:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2D423160B9A for ; Sun, 7 May 2017 18:15:29 +0200 (CEST) Received: (qmail 44975 invoked by uid 500); 7 May 2017 16:15:28 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 44954 invoked by uid 99); 7 May 2017 16:15:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 May 2017 16:15:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2FF28E02B4; Sun, 7 May 2017 16:15:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bodewig@apache.org To: notifications@ant.apache.org Date: Sun, 07 May 2017 16:15:28 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/5] ant-antlibs-compress git commit: support DEFLATE archived-at: Sun, 07 May 2017 16:15:30 -0000 Repository: ant-antlibs-compress Updated Branches: refs/heads/master 46b9c73b4 -> 3472e109d support DEFLATE 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/85a1f823 Tree: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/tree/85a1f823 Diff: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/diff/85a1f823 Branch: refs/heads/master Commit: 85a1f823bf6287fe3bc8616e394d24ecda803426 Parents: 46b9c73 Author: Stefan Bodewig Authored: Sun May 7 18:08:54 2017 +0200 Committer: Stefan Bodewig Committed: Sun May 7 18:08:54 2017 +0200 ---------------------------------------------------------------------- changes.xml | 8 +- docs/compresource.html | 24 ++++ docs/index.html | 9 +- docs/pack.html | 30 +++++ docs/unpack.html | 24 ++++ src/main/org/apache/ant/compress/antlib.xml | 12 ++ .../ant/compress/resources/DeflateResource.java | 78 +++++++++++++ .../apache/ant/compress/taskdefs/Deflate.java | 78 +++++++++++++ .../apache/ant/compress/taskdefs/Undeflate.java | 59 ++++++++++ .../ant/compress/util/DeflateStreamFactory.java | 53 +++++++++ src/tests/antunit/deflate-test.xml | 110 +++++++++++++++++++ src/tests/antunit/deflateresource-test.xml | 53 +++++++++ src/tests/antunit/undeflate-test.xml | 74 +++++++++++++ src/tests/resources/asf-logo.gif.dfl | Bin 0 -> 6965 bytes 14 files changed, 607 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/changes.xml ---------------------------------------------------------------------- diff --git a/changes.xml b/changes.xml index 75e20ec..0927c18 100644 --- a/changes.xml +++ b/changes.xml @@ -40,8 +40,9 @@ The Apache Compress Antlib now requires Apache Commons - Compress 1.13 or later for 7z and write support for LZMA, XZ - for Java 1.6 is required for write support for LZMA. + Compress 1.13 or later for 7z, DEFLATE and write support + for LZMA. + XZ for Java 1.6 is required for write support for LZMA. A new keepCompression flag can be used to keep the content @@ -59,6 +60,9 @@ Added write support for the LZMA format. + + Added support for the DEFLATE format with and without ZLIB headers. + http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/docs/compresource.html ---------------------------------------------------------------------- diff --git a/docs/compresource.html b/docs/compresource.html index 09d77b4..50dc979 100644 --- a/docs/compresource.html +++ b/docs/compresource.html @@ -63,6 +63,30 @@ some-archive.tar.bz2 where the bzip2resource provides the decompression of the archive.

+

deflateresource

+ +

Since Apache Compress Antlib 1.5.

+ +

This is a compressed resource using the + DEFLATE compression.

+ +

This resource supports the following additional attributes:

+ + + + + + + + + + + + +
AttributeDescriptionRequired
zlibheaderWhether to write or expect ZLIB headers. Unfortunately + it is currently not possible to detect whether zlib headers have + been used when reading.No, defaults to true
+

gzipresource

This is a compressed resource using the http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/docs/index.html ---------------------------------------------------------------------- diff --git a/docs/index.html b/docs/index.html index f32107f..4be8fc0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -28,8 +28,8 @@

This Antlib contains tasks and resources that provide compression/uncompression and archival/unarchival capabilities based on Apache - Commons Compress. Using Apache Commons Compress 1.6 this - Antlib supports gzip, bzip2, lzma standalone, xz, .Z, Snappy and + Commons Compress. Using Apache Commons Compress 1.13 this + Antlib supports gzip, bzip2, lzma standalone, xz, .Z, DEFLATE, Snappy and pack200 compression and ar, arj, cpio, 7z, Unix dump, tar and zip archives. Support for lzma, arj, .Z, Snappy and dump is read-only. 7z can only be used on filesystem resources.

@@ -49,6 +49,7 @@
  • bunzip2
  • bzip2
  • cpio
  • +
  • deflate
  • gunzip
  • gzip
  • pack200
  • @@ -59,6 +60,7 @@
  • unar
  • unarj
  • uncpio
  • +
  • undeflate
  • undump
  • unlzma
  • unpack200
  • @@ -82,6 +84,7 @@
  • bzip2resource
  • cpioentry
  • cpiofileset
  • +
  • deflateresource
  • dumpentry
  • dumpfileset
  • gzipresource
  • @@ -113,7 +116,7 @@

    Installing and Using

    This Antlib requires Apache Ant 1.8.0 or higher, Apache - Commons Compress 1.6 or higher and Java5 or higher.

    + Commons Compress 1.13 or higher and Java7 or higher.

    If you are building the Antlib from sources, run the antlib target and you'll get a http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/docs/pack.html ---------------------------------------------------------------------- diff --git a/docs/pack.html b/docs/pack.html index 89c3f52..67738e5 100644 --- a/docs/pack.html +++ b/docs/pack.html @@ -98,6 +98,36 @@

    Is a compressing task that uses the BZIP2 compression algorithm.

    +

    Deflate

    + +

    Is a compressing task that uses the DEFLATE + compression algorithm.

    + +

    Since Compress Antlib 1.5 + +

    This task supports the following additional attributes:

    + + + + + + + + + + + + + + + + + +
    AttributeDescriptionRequired
    levelNon-default level at which file compression + should be performed. Valid values range from 0 (no + compression/fastest) to 9 (maximum + compression/slowest).No
    zlibheaderWhether to write ZLIB headers.No, defaults to true
    +

    GZip

    Is a compressing task that uses the GZIP http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/docs/unpack.html ---------------------------------------------------------------------- diff --git a/docs/unpack.html b/docs/unpack.html index 1487a73..81d4f0f 100644 --- a/docs/unpack.html +++ b/docs/unpack.html @@ -93,6 +93,30 @@ resource collection the decompressConcatenated attribute.

    +

    Undeflate

    + +

    Is an uncompressing task that uses the DEFLATE + compression algorithm.

    + +

    Since Compress Antlib 1.5 + +

    This task supports the following additional attributes:

    + + + + + + + + + + + + +
    AttributeDescriptionRequired
    zlibheaderWhether to expect ZLIB headers. Unfortunately + it is currently not possible to detect whether zlib headers have + been used.No, defaults to true
    +

    UnLZMA

    Is an uncompressing task that uses the LZMA http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/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 57392e9..161c64c 100644 --- a/src/main/org/apache/ant/compress/antlib.xml +++ b/src/main/org/apache/ant/compress/antlib.xml @@ -33,6 +33,10 @@ classname="org.apache.ant.compress.taskdefs.Uncpio" /> + @@ -93,6 +97,10 @@ classname="org.apache.ant.compress.taskdefs.BZip2" /> + @@ -183,6 +191,10 @@ classname="org.apache.ant.compress.resources.BZip2Resource" /> + http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/main/org/apache/ant/compress/resources/DeflateResource.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/ant/compress/resources/DeflateResource.java b/src/main/org/apache/ant/compress/resources/DeflateResource.java new file mode 100644 index 0000000..a66f7fb --- /dev/null +++ b/src/main/org/apache/ant/compress/resources/DeflateResource.java @@ -0,0 +1,78 @@ +/* + * 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 java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.ant.compress.util.DeflateStreamFactory; +import org.apache.commons.compress.compressors.CompressorInputStream; +import org.apache.commons.compress.compressors.CompressorOutputStream; +import org.apache.commons.compress.compressors.deflate.DeflateCompressorInputStream; +import org.apache.commons.compress.compressors.deflate.DeflateCompressorOutputStream; +import org.apache.commons.compress.compressors.deflate.DeflateParameters; +import org.apache.tools.ant.types.ResourceCollection; + +/** + * A DEFLATE compressed resource. + * @since Apache Compress Antlib 1.5 + */ +public final class DeflateResource extends CommonsCompressCompressorResource { + private boolean zlibHeader = true; + private static final String NAME = "DEFLATE"; + + public DeflateResource() { + super(NAME); + setFactory(); + } + + public DeflateResource(ResourceCollection other) { + super(NAME, other); + setFactory(); + } + + /** + * Whether to expect or write a ZLIB header. + * + *

    Default is {@code true}.

    + * @param zlib whether to expect or write a ZLIB header + */ + public void setZlibHeader(boolean zlib) { + zlibHeader = zlib; + } + + private void setFactory() { + setFactory(new DeflateStreamFactory() { + @Override + public CompressorOutputStream getCompressorStream(OutputStream stream) + throws IOException { + DeflateParameters params = new DeflateParameters(); + params.setWithZlibHeader(zlibHeader); + return new DeflateCompressorOutputStream(stream, params); + } + @Override + public CompressorInputStream getCompressorStream(InputStream stream) + throws IOException { + DeflateParameters params = new DeflateParameters(); + params.setWithZlibHeader(zlibHeader); + return new DeflateCompressorInputStream(stream, params); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/main/org/apache/ant/compress/taskdefs/Deflate.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/ant/compress/taskdefs/Deflate.java b/src/main/org/apache/ant/compress/taskdefs/Deflate.java new file mode 100644 index 0000000..f2b3d5b --- /dev/null +++ b/src/main/org/apache/ant/compress/taskdefs/Deflate.java @@ -0,0 +1,78 @@ +/* + * 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.IOException; +import java.io.OutputStream; +import java.util.zip.Deflater; + +import org.apache.ant.compress.resources.CommonsCompressCompressorResource; +import org.apache.ant.compress.resources.DeflateResource; +import org.apache.ant.compress.util.DeflateStreamFactory; +import org.apache.commons.compress.compressors.CompressorOutputStream; +import org.apache.commons.compress.compressors.deflate.DeflateCompressorOutputStream; +import org.apache.commons.compress.compressors.deflate.DeflateParameters; +import org.apache.tools.ant.types.Resource; + +/** + * Compresses using deflate. + * @since Apache Compress Antlib 1.5 + */ +public final class Deflate extends PackBase { + private boolean zlibHeader = true; + private int level = Deflater.DEFAULT_COMPRESSION; + + public Deflate() { + super(new PackBase.ResourceWrapper() { + @Override + public CommonsCompressCompressorResource wrap(Resource dest) { + return new DeflateResource(dest); + } + }); + setFactory(new DeflateStreamFactory() { + @Override + public CompressorOutputStream getCompressorStream(OutputStream stream) + throws IOException { + DeflateParameters params = new DeflateParameters(); + params.setCompressionLevel(level); + params.setWithZlibHeader(zlibHeader); + return new DeflateCompressorOutputStream(stream, params); + } + }); + } + + /** + * Set the compression level to use. Default is + * Deflater.DEFAULT_COMPRESSION. + * @param level compression level. + */ + public void setLevel(int level) { + this.level = level; + } + + /** + * Whether to write a ZLIB header. + * + *

    Default is {@code true}.

    + * @param zlib whether to write a ZLIB header + */ + public void setZlibHeader(boolean zlib) { + zlibHeader = zlib; + } +} http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/main/org/apache/ant/compress/taskdefs/Undeflate.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/ant/compress/taskdefs/Undeflate.java b/src/main/org/apache/ant/compress/taskdefs/Undeflate.java new file mode 100644 index 0000000..1d1fdb4 --- /dev/null +++ b/src/main/org/apache/ant/compress/taskdefs/Undeflate.java @@ -0,0 +1,59 @@ +/* + * 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.DeflateStreamFactory; +import org.apache.commons.compress.compressors.CompressorInputStream; +import org.apache.commons.compress.compressors.deflate.DeflateCompressorInputStream; +import org.apache.commons.compress.compressors.deflate.DeflateParameters; + +/** + * Expands a DEFLATE archive. + * @since Apache Compress Antlib 1.5 + */ +public final class Undeflate extends UnpackBase { + + private boolean zlibHeader = true; + + public Undeflate() { + super(".dfl"); + setFactory(new DeflateStreamFactory() { + @Override + public CompressorInputStream getCompressorStream(InputStream stream) + throws IOException { + DeflateParameters params = new DeflateParameters(); + params.setWithZlibHeader(zlibHeader); + return new DeflateCompressorInputStream(stream, params); + } + }); + } + + /** + * Whether to expect a ZLIB header. + * + *

    Default is {@code true}.

    + * @param zlib whether to expect a ZLIB header + */ + public void setZlibHeader(boolean zlib) { + zlibHeader = zlib; + } +} http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/main/org/apache/ant/compress/util/DeflateStreamFactory.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/ant/compress/util/DeflateStreamFactory.java b/src/main/org/apache/ant/compress/util/DeflateStreamFactory.java new file mode 100644 index 0000000..a9ad766 --- /dev/null +++ b/src/main/org/apache/ant/compress/util/DeflateStreamFactory.java @@ -0,0 +1,53 @@ +/* + * 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.deflate.DeflateCompressorInputStream; +import org.apache.commons.compress.compressors.deflate.DeflateCompressorOutputStream; + +/** + * Creates streams for the standalone DEFLATE format. + * @since Apache Compress Antlib 1.5 + */ +public class DeflateStreamFactory implements CompressorStreamFactory { + + /** + * @param stream the stream to read from, should be buffered + */ + @Override + public CompressorInputStream getCompressorStream(InputStream stream) + throws IOException { + return new DeflateCompressorInputStream(stream); + } + + /** + * @param stream the stream to write to, should be buffered + */ + @Override + public CompressorOutputStream getCompressorStream(OutputStream stream) + throws IOException { + return new DeflateCompressorOutputStream(stream); + } +} http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/tests/antunit/deflate-test.xml ---------------------------------------------------------------------- diff --git a/src/tests/antunit/deflate-test.xml b/src/tests/antunit/deflate-test.xml new file mode 100644 index 0000000..090186f --- /dev/null +++ b/src/tests/antunit/deflate-test.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/tests/antunit/deflateresource-test.xml ---------------------------------------------------------------------- diff --git a/src/tests/antunit/deflateresource-test.xml b/src/tests/antunit/deflateresource-test.xml new file mode 100644 index 0000000..8b47e7e --- /dev/null +++ b/src/tests/antunit/deflateresource-test.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/tests/antunit/undeflate-test.xml ---------------------------------------------------------------------- diff --git a/src/tests/antunit/undeflate-test.xml b/src/tests/antunit/undeflate-test.xml new file mode 100644 index 0000000..02ffb0b --- /dev/null +++ b/src/tests/antunit/undeflate-test.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/85a1f823/src/tests/resources/asf-logo.gif.dfl ---------------------------------------------------------------------- diff --git a/src/tests/resources/asf-logo.gif.dfl b/src/tests/resources/asf-logo.gif.dfl new file mode 100644 index 0000000..d68eb6b Binary files /dev/null and b/src/tests/resources/asf-logo.gif.dfl differ