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 2013/12/27 13:56:43 UTC
svn commit: r1553669 - in /ant/antlibs/compress/trunk: docs/
src/main/org/apache/ant/compress/resources/
src/main/org/apache/ant/compress/taskdefs/
src/main/org/apache/ant/compress/util/ src/tests/antunit/
src/tests/resources/
Author: bodewig
Date: Fri Dec 27 12:56:43 2013
New Revision: 1553669
URL: http://svn.apache.org/r1553669
Log:
add support for the raw snappy format
Added:
ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.snappy
- copied, changed from r1553665, ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.sz
Modified:
ant/antlibs/compress/trunk/docs/compresource.html
ant/antlibs/compress/trunk/docs/unpack.html
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SnappyResource.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnSnappy.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/SnappyStreamFactory.java
ant/antlibs/compress/trunk/src/tests/antunit/snappyresource-test.xml
ant/antlibs/compress/trunk/src/tests/antunit/unsnappy-test.xml
Modified: ant/antlibs/compress/trunk/docs/compresource.html
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/compresource.html?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/compresource.html (original)
+++ ant/antlibs/compress/trunk/docs/compresource.html Fri Dec 27 12:56:43 2013
@@ -138,6 +138,24 @@
<a href="http://code.google.com/p/snappy/">Snappy</a>
compression.</p>
+<h4>Parameters</h4>
+ <p>In addition to the attributes supported by all uncompressing resources
+ this resource also supports.</p>
+ <table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">framed</td>
+ <td valign="top">Whether the input is expected to use
+ the <a href="http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt">framing
+ format</a>.</td>
+ <td align="center" valign="top">No, defaults to true.</td>
+ </tr>
+ </table>
+
<h4>Examples</h4>
<pre>
Modified: ant/antlibs/compress/trunk/docs/unpack.html
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/unpack.html?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/unpack.html (original)
+++ ant/antlibs/compress/trunk/docs/unpack.html Fri Dec 27 12:56:43 2013
@@ -105,7 +105,7 @@ resource collection</h4>
compression algorithm.</p>
<p>This task does not work on defalted archives, you need to wrap
- defalted archives into <code>gunzipresource</code>s in order to use
+ deflated archives into <code>gunzipresource</code>s in order to use
them.
<h4>Parameters</h4>
@@ -160,6 +160,26 @@ resource collection</h4>
the <a href="http://code.google.com/p/snappy/">Snappy</a>
compression algorithm.</p>
+<p><em>Since Apache Compress Antlib 1.4</em>.</p>
+
+<h4>Parameters</h4>
+ <p>In addition to the attributes supported by all uncompressing task
+ this task also supports.</p>
+ <table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">framed</td>
+ <td valign="top">Whether the input is expected to use
+ the <a href="http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt">framing
+ format</a>.</td>
+ <td align="center" valign="top">No, defaults to true.</td>
+ </tr>
+ </table>
+
<h3><a name="unxz">UnXZ</a></h3>
<p>Is an <a href="#unpack">uncompressing task</a> that uses the XZ
@@ -174,6 +194,8 @@ resource collection</h4>
<p>Is an <a href="#unpack">uncompressing task</a> that uses the .Z
compression algorithm.</p>
+<p><em>Since Apache Compress Antlib 1.4</em>.</p>
+
<h3>Examples</h3>
<blockquote><pre>
<cmp:gunzip src="test.tar.gz" xmlns:cmp="antlib:org.apache.ant.compress"/>
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressCompressorResource.java Fri Dec 27 12:56:43 2013
@@ -39,14 +39,17 @@ public abstract class CommonsCompressCom
extends ContentTransformingResource {
private final String name;
- private final CompressorStreamFactory factory;
+ private CompressorStreamFactory factory;
private boolean decompressConcatenated = false;
- /** A no-arg constructor */
+ protected CommonsCompressCompressorResource(String name) {
+ this.name = name;
+ }
+
protected CommonsCompressCompressorResource(String name,
CompressorStreamFactory factory) {
- this.name = name;
- this.factory = factory;
+ this(name);
+ setFactory(factory);
}
/**
@@ -54,10 +57,26 @@ public abstract class CommonsCompressCom
* @param other the resource to wrap.
*/
protected CommonsCompressCompressorResource(String name,
- CompressorStreamFactory factory,
ResourceCollection other) {
super(other);
this.name = name;
+ }
+
+ /**
+ * Constructor with another resource to wrap.
+ * @param other the resource to wrap.
+ */
+ protected CommonsCompressCompressorResource(String name,
+ CompressorStreamFactory factory,
+ ResourceCollection other) {
+ this(name, other);
+ setFactory(factory);
+ }
+
+ /**
+ * @since Apache Compress Antlib 1.4
+ */
+ protected final void setFactory(CompressorStreamFactory factory) {
this.factory = factory;
}
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SnappyResource.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SnappyResource.java?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SnappyResource.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SnappyResource.java Fri Dec 27 12:56:43 2013
@@ -27,11 +27,24 @@ import org.apache.tools.ant.types.Resour
public final class SnappyResource extends CommonsCompressCompressorResource {
private static final String NAME = "Snappy";
+ private final SnappyStreamFactory factory;
+
public SnappyResource() {
- super(NAME, new SnappyStreamFactory());
+ super(NAME);
+ setFactory(factory = new SnappyStreamFactory());
}
public SnappyResource(ResourceCollection other) {
- super(NAME, new SnappyStreamFactory(), other);
+ super(NAME, other);
+ setFactory(factory = new SnappyStreamFactory());
+ }
+
+ /**
+ * Whether to use the "framing format".
+ *
+ * <p>Defaults to true.</p>
+ */
+ public void setFramed(boolean framed) {
+ factory.setFramed(framed);
}
}
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnSnappy.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnSnappy.java?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnSnappy.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnSnappy.java Fri Dec 27 12:56:43 2013
@@ -26,8 +26,20 @@ import org.apache.ant.compress.util.Snap
*/
public final class UnSnappy extends UnpackBase {
+ private final SnappyStreamFactory factory;
+
public UnSnappy() {
- super(".sz", new SnappyStreamFactory());
+ super(".sz");
+ setFactory(factory = new SnappyStreamFactory());
+ }
+
+ /**
+ * Whether to use the "framing format".
+ *
+ * <p>Defaults to true.</p>
+ */
+ public void setFramed(boolean framed) {
+ factory.setFramed(framed);
}
}
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/SnappyStreamFactory.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/SnappyStreamFactory.java?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/SnappyStreamFactory.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/SnappyStreamFactory.java Fri Dec 27 12:56:43 2013
@@ -25,6 +25,7 @@ import java.io.OutputStream;
import org.apache.commons.compress.compressors.CompressorInputStream;
import org.apache.commons.compress.compressors.CompressorOutputStream;
import org.apache.commons.compress.compressors.snappy.FramedSnappyCompressorInputStream;
+import org.apache.commons.compress.compressors.snappy.SnappyCompressorInputStream;
/**
* Creates streams for the standalone Snappy format.
@@ -33,12 +34,24 @@ import org.apache.commons.compress.compr
*/
public class SnappyStreamFactory implements CompressorStreamFactory {
+ private boolean framed = true;
+
+ /**
+ * Whether to use the "framing format".
+ *
+ * <p>Defaults to true.</p>
+ */
+ public void setFramed(boolean framed) {
+ this.framed = framed;
+ }
+
/**
* @param stream the stream to read from, should be buffered
*/
public CompressorInputStream getCompressorStream(InputStream stream)
throws IOException {
- return new FramedSnappyCompressorInputStream(stream);
+ return framed ? new FramedSnappyCompressorInputStream(stream)
+ : (CompressorInputStream) new SnappyCompressorInputStream(stream);
}
/**
Modified: ant/antlibs/compress/trunk/src/tests/antunit/snappyresource-test.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/snappyresource-test.xml?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/snappyresource-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/snappyresource-test.xml Fri Dec 27 12:56:43 2013
@@ -38,4 +38,15 @@
actual="${output}/asf-logo.gif"/>
</target>
+ <target name="testNativeSnappyUnframed" depends="setUp">
+ <copy todir="${output}">
+ <cmp:snappyresource framed="false">
+ <file file="../resources/asf-logo.gif.snappy"/>
+ </cmp:snappyresource>
+ <globmapper from="*.snappy" to="*"/>
+ </copy>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
</project>
Modified: ant/antlibs/compress/trunk/src/tests/antunit/unsnappy-test.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/unsnappy-test.xml?rev=1553669&r1=1553668&r2=1553669&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/unsnappy-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/unsnappy-test.xml Fri Dec 27 12:56:43 2013
@@ -54,5 +54,20 @@
actual="${output}/asf-logo.gif"/>
</target>
+ <target name="testNativeSnappyUnframed" depends="setUp">
+ <cmp:unsnappy src="../resources/asf-logo.gif.snappy"
+ dest="${output}/asf-logo.gif"
+ framed="false"/>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testWithResourceUnframed" depends="setUp">
+ <cmp:unsnappy dest="${output}/asf-logo.gif" framed="false">
+ <file file="../resources/asf-logo.gif.snappy"/>
+ </cmp:unsnappy>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
</project>
Copied: ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.snappy (from r1553665, ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.sz)
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.snappy?p2=ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.snappy&p1=ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.sz&r1=1553665&r2=1553669&rev=1553669&view=diff
==============================================================================
Binary files - no diff available.