ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1170548 - in /ant/antlibs/compress/trunk/src: main/org/apache/ant/compress/taskdefs/ tests/antunit/
Date Wed, 14 Sep 2011 11:48:22 GMT
Author: bodewig
Date: Wed Sep 14 11:48:22 2011
New Revision: 1170548

URL: http://svn.apache.org/viewvc?rev=1170548&view=rev
Log:
allow packer/unpacker properties to be set

Modified:
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java
    ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml
    ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java?rev=1170548&r1=1170547&r2=1170548&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java Wed
Sep 14 11:48:22 2011
@@ -32,14 +32,17 @@ import org.apache.commons.compress.compr
 import org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream;
 import org.apache.commons.compress.compressors.pack200.Pack200Strategy;
 import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.types.Environment;
 import org.apache.tools.ant.types.Resource;
 
 /**
  * Compresses using pack200.
+ * @since Apache Compress Antlib 1.1
  */
 public final class Pack200 extends PackBase {
 
     private Pack200StrategyEnum strategy = Pack200StrategyEnum.IN_MEMORY;
+    private final Map/*<String, String>*/ properties = new HashMap();
 
     public Pack200() {
         super(new PackBase.ResourceWrapper() {
@@ -53,7 +56,8 @@ public final class Pack200 extends PackB
                     throws IOException {
                     return new Pack200CompressorOutputStream(stream,
                                                              strategy
-                                                             .getStrategy());
+                                                             .getStrategy(),
+                                                             properties);
                 }
                 public CompressorInputStream
                     getCompressorStream(InputStream stream)
@@ -66,14 +70,20 @@ public final class Pack200 extends PackB
     /**
      * Whether to cache archive data in memory (the default) or a
      * temporary file.
-     *
-     * @since Commons Compress 1.1
      */
     public void setPack200Strategy(Pack200StrategyEnum s) {
         strategy = s;
     }
 
     /**
+     * Sets a property for the Pack200 packer.
+     */
+    public void addConfiguredProperty(Environment.Variable prop) {
+        prop.validate();
+        properties.put(prop.getKey(), prop.getValue());
+    }
+
+    /**
      * Pack200Strategy to use: cache in memory or use a temporary file.
      *
      * @since Commons Compress 1.1

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java?rev=1170548&r1=1170547&r2=1170548&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java Wed
Sep 14 11:48:22 2011
@@ -21,10 +21,13 @@ package org.apache.ant.compress.taskdefs
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.ant.compress.util.Pack200StreamFactory;
 import org.apache.commons.compress.compressors.CompressorInputStream;
 import org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
+import org.apache.tools.ant.types.Environment;
 
 /**
  * Expands a pack200 archive.
@@ -34,6 +37,7 @@ public final class UnPack200 extends Unp
 
     private Pack200.Pack200StrategyEnum strategy =
         Pack200.Pack200StrategyEnum.IN_MEMORY;
+    private final Map/*<String, String>*/ properties = new HashMap();
 
     public UnPack200() {
         super(".pack");
@@ -43,13 +47,15 @@ public final class UnPack200 extends Unp
                     throws IOException {
                     return new Pack200CompressorInputStream(stream,
                                                             strategy
-                                                            .getStrategy());
+                                                            .getStrategy(),
+                                                            properties);
                 }
                 public CompressorInputStream getCompressorInputStream(File file)
                     throws IOException {
                     return new Pack200CompressorInputStream(file,
                                                             strategy
-                                                            .getStrategy());
+                                                            .getStrategy(),
+                                                            properties);
                 }
             });
     }
@@ -57,11 +63,17 @@ public final class UnPack200 extends Unp
     /**
      * Whether to cache archive data in memory (the default) or a
      * temporary file.
-     *
-     * @since Commons Compress 1.1
      */
     public void setPack200Strategy(Pack200.Pack200StrategyEnum s) {
         strategy = s;
     }
 
+    /**
+     * Sets a property for the Pack200 unpacker.
+     */
+    public void addConfiguredProperty(Environment.Variable prop) {
+        prop.validate();
+        properties.put(prop.getKey(), prop.getValue());
+    }
+
 }
\ No newline at end of file

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java?rev=1170548&r1=1170547&r2=1170548&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Zip.java Wed Sep
14 11:48:22 2011
@@ -167,7 +167,7 @@ public class Zip extends ArchiveBase {
     /**
      * Whether to create Zip64 extended information.
      *
-     * @since Commons Compress 1.1
+     * @since Apache Compress Antlib 1.1
      */
     public void setZip64Mode(Zip64Enum mode) {
         zip64Mode = mode;
@@ -224,6 +224,7 @@ public class Zip extends ArchiveBase {
     /**
      * Policiy for creation of Zip64 extended information: never, always or
      * as-needed.
+     * @since Apache Compress Antlib 1.1
      */
     public static final class Zip64Enum extends EnumeratedAttribute {
         private static final Map POLICIES = new HashMap();

Modified: ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml?rev=1170548&r1=1170547&r2=1170548&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml Wed Sep 14 11:48:22 2011
@@ -76,4 +76,13 @@
     <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
   </target>
 
+  <target name="testProperties" depends="setUp">
+    <cmp:pack200 src="../resources/asf-logo.gif.zip"
+                 destfile="${output}/asf-logo.gif.pack">
+      <property key="pack.effort" value="9"/>
+    </cmp:pack200>
+    <au:assertLogContains text="Building: asf-logo.gif.pack"/>
+    <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
+  </target>
+
 </project>

Modified: ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml?rev=1170548&r1=1170547&r2=1170548&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml Wed Sep 14 11:48:22 2011
@@ -63,4 +63,18 @@
        expected="../resources/asf-logo.gif"
        />
   </target>
+
+  <target name="testProperties" depends="setUp">
+    <cmp:unpack200 src="../resources/asf-logo.gif.pack"
+                   dest="${input}/test.zip">
+      <property key="unpack.deflate.hint" value="keep"/>
+    </cmp:unpack200>
+    <cmp:unzip src="${input}/test.zip" dest="${output}" />
+    <au:assertFileExists file="${output}/asf-logo.gif"/>
+    <au:assertFilesMatch
+       actual="${output}/asf-logo.gif"
+       expected="../resources/asf-logo.gif"
+       />
+  </target>
+
 </project>



Mime
View raw message