Return-Path: bzip2resource
provides
the decompression of the archive.
Since Apache Compress Antlib 1.5.
+ +This is a compressed resource using the + DEFLATE compression.
+ +This resource supports the following additional attributes:
+ +Attribute | +Description | +Required | +
zlibheader | +Whether 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 |
+
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 @@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.
+Is a compressing task that uses the DEFLATE + compression algorithm.
+ +Since Compress Antlib 1.5 + +
This task supports the following additional attributes:
+ +Attribute | +Description | +Required | +
level | +Non-default level at which file compression + should be performed. Valid values range from 0 (no + compression/fastest) to 9 (maximum + compression/slowest). | +No | +
zlibheader | +Whether to write ZLIB headers. | +No, defaults to true |
+
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.
+Is an uncompressing task that uses the DEFLATE + compression algorithm.
+ +Since Compress Antlib 1.5 + +
This task supports the following additional attributes:
+ +Attribute | +Description | +Required | +
zlibheader | +Whether to expect ZLIB headers. Unfortunately + it is currently not possible to detect whether zlib headers have + been used. | +No, defaults to true |
+
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"
/>
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 @@ + + +