ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [12/12] ant-antlibs-compress git commit: make <archives> support all known archive formats
Date Sun, 14 May 2017 20:42:44 GMT
make <archives> support all known archive formats


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/9668aba3
Tree: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/tree/9668aba3
Diff: http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/diff/9668aba3

Branch: refs/heads/master
Commit: 9668aba32c20688813ca812f8162afe9428e0c76
Parents: 6780141
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Tue May 9 06:01:44 2017 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Tue May 9 06:01:44 2017 +0200

----------------------------------------------------------------------
 docs/archives.html                              | 14 +++--
 .../apache/ant/compress/resources/Archives.java | 63 ++++++++++++++++++++
 src/tests/antunit/archives-test.xml             | 45 ++++++++++++++
 3 files changed, 118 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/9668aba3/docs/archives.html
----------------------------------------------------------------------
diff --git a/docs/archives.html b/docs/archives.html
index 3ced66d..469a62b 100644
--- a/docs/archives.html
+++ b/docs/archives.html
@@ -36,16 +36,22 @@
 
 <h3>Parameters specified as nested elements</h3>
 
-  <p><code>&lt;archives&gt;</code> has four nested
-    elements <code>&lt;ars&gt;</code>, <code>&lt;cpios&gt;</code>,
-    <code>&lt;zips&gt;</code> and
-    <code>&lt;tars&gt;</code> that are <a href="http://ant.apache.org/manual/CoreTypes/resources.html#union">unions</a>
+  <p><code>&lt;archives&gt;</code> has seven nested
+    elements <code>&lt;ars&gt;</code>, <code>&lt;arjs&gt;</code>,
<code>&lt;cpios&gt;</code>,
+    <code>&lt;dumps&gt;</code>, <code>&lt;sevenzs&gt;</code>,
<code>&lt;zips&gt;</code>
+    and
+    <code>&lt;tars&gt;</code> that
+    are <a href="http://ant.apache.org/manual/CoreTypes/resources.html#union">unions</a>
     themselves, i.e. they accept arbitrary many resource(collection)s
     as nested elements.</p>
 
   <p>The nested resources of &lt;zips&gt; are treated as ZIP archives,
     the nested resources of &lt;tars&gt; as TAR archives and so on.</p>
 
+  <p>Support for nested <code>arjs</code>, <code>dumps</code>
+    and <code>sevenzs</code> has been added with the Compress Antlib
+    1.5.</p>
+
   <h4>Examples</h4>
 
   <p>Copies all files from all jars that are on the classpath

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/9668aba3/src/main/org/apache/ant/compress/resources/Archives.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/ant/compress/resources/Archives.java b/src/main/org/apache/ant/compress/resources/Archives.java
index 27b85cc..dffa815 100644
--- a/src/main/org/apache/ant/compress/resources/Archives.java
+++ b/src/main/org/apache/ant/compress/resources/Archives.java
@@ -42,6 +42,9 @@ public class Archives extends DataType
     private Union tars = new Union();
     private Union ars = new Union();
     private Union cpios = new Union();
+    private Union arjs = new Union();
+    private Union dumps = new Union();
+    private Union sevenzs = new Union();
 
     /**
      * Wrapper to identify nested resource collections as ZIP
@@ -80,6 +83,19 @@ public class Archives extends DataType
     }
 
     /**
+     * Wrapper to identify nested resource collections as ARJ
+     * archives.
+     * @since Apache Compress Antlib 1.5
+     */
+    public Union createArjs() {
+        if (isReference()) {
+            throw noChildrenAllowed();
+        }
+        setChecked(false);
+        return arjs;
+    }
+
+    /**
      * Wrapper to identify nested resource collections as CPIO
      * archives.
      */
@@ -92,6 +108,32 @@ public class Archives extends DataType
     }
 
     /**
+     * Wrapper to identify nested resource collections as Unix dump
+     * archives.
+     * @since Apache Compress Antlib 1.5
+     */
+    public Union createDumps() {
+        if (isReference()) {
+            throw noChildrenAllowed();
+        }
+        setChecked(false);
+        return dumps;
+    }
+
+    /**
+     * Wrapper to identify nested resource collections as 7z
+     * archives.
+     * @since Apache Compress Antlib 1.5
+     */
+    public Union createSevenzs() {
+        if (isReference()) {
+            throw noChildrenAllowed();
+        }
+        setChecked(false);
+        return sevenzs;
+    }
+
+    /**
      * Sums the sizes of nested archives.
      */
     @Override
@@ -145,6 +187,9 @@ public class Archives extends DataType
         if (zips.getResourceCollections().size() > 0
             || ars.getResourceCollections().size() > 0
             || cpios.getResourceCollections().size() > 0
+            || arjs.getResourceCollections().size() > 0
+            || dumps.getResourceCollections().size() > 0
+            || sevenzs.getResourceCollections().size() > 0
             || tars.getResourceCollections().size() > 0) {
             throw tooManyAttributes();
         }
@@ -164,6 +209,9 @@ public class Archives extends DataType
             a.tars = (Union) tars.clone();
             a.ars = (Union) ars.clone();
             a.cpios = (Union) cpios.clone();
+            a.arjs = (Union) arjs.clone();
+            a.dumps = (Union) dumps.clone();
+            a.sevenzs = (Union) sevenzs.clone();
             return a;
         } catch (CloneNotSupportedException e) {
             throw new BuildException(e);
@@ -194,6 +242,18 @@ public class Archives extends DataType
             l.add(configureArchive(new CpioFileSet(),
                                    (Resource) iter.next()));
         }
+        for (Iterator iter = arjs.iterator(); iter.hasNext(); ) {
+            l.add(configureArchive(new ArjFileSet(),
+                                   (Resource) iter.next()));
+        }
+        for (Iterator iter = dumps.iterator(); iter.hasNext(); ) {
+            l.add(configureArchive(new DumpFileSet(),
+                                   (Resource) iter.next()));
+        }
+        for (Iterator iter = sevenzs.iterator(); iter.hasNext(); ) {
+            l.add(configureArchive(new SevenZFileSet(),
+                                   (Resource) iter.next()));
+        }
         return l.iterator();
     }
 
@@ -228,6 +288,9 @@ public class Archives extends DataType
             pushAndInvokeCircularReferenceCheck(tars, stk, p);
             pushAndInvokeCircularReferenceCheck(ars, stk, p);
             pushAndInvokeCircularReferenceCheck(cpios, stk, p);
+            pushAndInvokeCircularReferenceCheck(arjs, stk, p);
+            pushAndInvokeCircularReferenceCheck(dumps, stk, p);
+            pushAndInvokeCircularReferenceCheck(sevenzs, stk, p);
             setChecked(true);
         }
     }

http://git-wip-us.apache.org/repos/asf/ant-antlibs-compress/blob/9668aba3/src/tests/antunit/archives-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/archives-test.xml b/src/tests/antunit/archives-test.xml
index 7fa8fde..2453cb4 100644
--- a/src/tests/antunit/archives-test.xml
+++ b/src/tests/antunit/archives-test.xml
@@ -90,6 +90,51 @@
     <au:assertFileExists file="${output}/cpio/${filename}"/>
   </target>
 
+  <target name="testArj">
+    <mkdir dir="${output}"/>
+    <copy todir="${output}">
+      <cmp:archives>
+        <arjs>
+          <file file="../resources/asf-logo.gif.arj"/>
+        </arjs>
+      </cmp:archives>
+    </copy>
+    <au:assertFilesMatch
+       actual="${output}/asf-logo.gif"
+       expected="../resources/asf-logo.gif"
+       />
+  </target>
+
+  <target name="testDump">
+    <mkdir dir="${output}"/>
+    <copy todir="${output}">
+      <cmp:archives>
+        <dumps>
+          <file file="../resources/asf-logo.gif.dump"/>
+        </dumps>
+      </cmp:archives>
+    </copy>
+    <au:assertFilesMatch
+       actual="${output}/asf-logo.gif"
+       expected="../resources/asf-logo.gif"
+       />
+  </target>
+
+  <target name="test7z">
+    <mkdir dir="${output}"/>
+    <copy todir="${output}">
+      <cmp:archives>
+        <sevenzs>
+          <file file="../resources/asf-logo.gif.7z"/>
+        </sevenzs>
+      </cmp:archives>
+    </copy>
+    <au:assertFilesMatch
+       actual="${output}/asf-logo.gif"
+       expected="../resources/asf-logo.gif"
+       />
+  </target>
+
   <target name="testReference" depends="-findAntHomeLib">
     <mkdir dir="${output}"/>
     <cmp:archives id="ref">


Mime
View raw message