ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1170590 - in /ant/antlibs/compress/trunk/src: main/org/apache/ant/compress/taskdefs/PackBase.java tests/antunit/pack200-test.xml
Date Wed, 14 Sep 2011 13:05:33 GMT
Author: bodewig
Date: Wed Sep 14 13:05:32 2011
New Revision: 1170590

URL: http://svn.apache.org/viewvc?rev=1170590&view=rev
Log:
since Compress' Pack200 stream don't compress it makes sense to allow pack tasks to be nested
into each other so you can gzip a pack200 archive

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

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/PackBase.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/PackBase.java?rev=1170590&r1=1170589&r2=1170590&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/PackBase.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/PackBase.java Wed
Sep 14 13:05:32 2011
@@ -49,7 +49,8 @@ public abstract class PackBase extends T
     private final ResourceWrapper wrapper;
 
     private Resource src;
-    private ArchiveBase srcTask;
+    private ArchiveBase srcArchiveTask;
+    private PackBase srcPackTask;
     private Resource dest;
 
     protected PackBase(CompressorStreamFactory factory,
@@ -112,7 +113,7 @@ public abstract class PackBase extends T
      * @param src resource to expand
      */
     public void setSrc(Resource src) {
-        if (this.src != null || srcTask != null) {
+        if (this.src != null || srcArchiveTask != null || srcPackTask != null) {
             throw new BuildException("Can only have one source.");
         }
         if (src.isDirectory()) {
@@ -132,10 +133,17 @@ public abstract class PackBase extends T
     }
 
     public void add(ArchiveBase task) {
-        if (src != null || srcTask != null) {
+        if (src != null || srcArchiveTask != null || srcPackTask != null) {
             throw new BuildException("Can only have one source.");
         }
-        srcTask = task;
+        srcArchiveTask = task;
+    }
+
+    public void add(PackBase task) {
+        if (src != null || srcArchiveTask != null || srcPackTask != null) {
+            throw new BuildException("Can only have one source.");
+        }
+        srcPackTask = task;
     }
 
     /**
@@ -143,7 +151,7 @@ public abstract class PackBase extends T
      * @throws BuildException if anything is invalid
      */
     private void validate() throws BuildException {
-        if (src == null && srcTask == null) {
+        if (src == null && srcArchiveTask == null && srcPackTask == null)
{
             throw new BuildException("source is required.",
                                      getLocation());
         }
@@ -179,10 +187,14 @@ public abstract class PackBase extends T
     public void execute() throws BuildException {
         validate();
 
-        if (srcTask != null) {
-            srcTask.setDest(wrapper.wrap(dest));
-            srcTask.setTaskName(getTaskName());
-            srcTask.execute();
+        if (srcArchiveTask != null) {
+            srcArchiveTask.setDest(wrapper.wrap(dest));
+            srcArchiveTask.setTaskName(getTaskName());
+            srcArchiveTask.execute();
+        } else if (srcPackTask != null) {
+            srcPackTask.setDest(wrapper.wrap(dest));
+            srcPackTask.setTaskName(getTaskName());
+            srcPackTask.execute();
         } else if (dest.isExists()
                    && dest.getLastModified() > src.getLastModified()) {
             log("Nothing to do: " + dest.getName() + " is up to date.");

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=1170590&r1=1170589&r2=1170590&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 13:05:32 2011
@@ -85,4 +85,12 @@
     <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
   </target>
 
+  <target name="testNestingOfPackTasks" depends="setUp">
+    <cmp:gzip destfile="${output}/asf-logo.gif.pack.gz">
+      <cmp:pack200 src="../resources/asf-logo.gif.zip"/>
+    </cmp:gzip>
+    <au:assertLogContains text="Building: asf-logo.gif.pack.gz"/>
+    <au:assertFileExists file="${output}/asf-logo.gif.pack.gz"/>
+  </target>
+
 </project>



Mime
View raw message