Author: bodewig
Date: Fri Aug 28 04:23:24 2009
New Revision: 808747
URL: http://svn.apache.org/viewvc?rev=808747&view=rev
Log:
archives resource
Added:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Archives.java
(contents, props changed)
- copied, changed from r808260,
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/archives-test.xml
(contents, props changed)
- copied, changed from r808745,
ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml
Modified:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
Modified:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=808747&r1=808746&r2=808747&view=diff
==============================================================================
---
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
(original)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
Fri Aug 28 04:23:24 2009
@@ -90,7 +90,10 @@
name="zipfileset"
classname="org.apache.ant.compress.resources.ZipFileSet"
/>
-
+ <typedef
+ name="archives"
+ classname="org.apache.ant.compress.resources.Archives"
+ />
<typedef
name="bzip2resource"
classname="org.apache.ant.compress.resources.BZip2Resource"
@@ -100,23 +103,23 @@
classname="org.apache.ant.compress.resources.GZipResource"
/>
- <typedef
+ <componentdef
name="hasusername"
classname="org.apache.ant.compress.conditions.HasUserName"
/>
- <typedef
+ <componentdef
name="hasgroupname"
classname="org.apache.ant.compress.conditions.HasGroupName"
/>
- <typedef
+ <componentdef
name="hasuserid"
classname="org.apache.ant.compress.conditions.HasUserId"
/>
- <typedef
+ <componentdef
name="hasgroupid"
classname="org.apache.ant.compress.conditions.HasGroupId"
/>
- <typedef
+ <componentdef
name="hasmode"
classname="org.apache.ant.compress.conditions.HasMode"
/>
Copied:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Archives.java
(from r808260,
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java)
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Archives.java?p2=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Archives.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java&r1=808260&r2=808747&rev=808747&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java
(original)
+++
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Archives.java
Fri Aug 28 04:23:24 2009
@@ -15,7 +15,7 @@
* limitations under the License.
*
*/
-package org.apache.tools.ant.types.resources;
+package org.apache.ant.compress.resources;
import java.util.Iterator;
import java.util.LinkedList;
@@ -28,21 +28,20 @@
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
-import org.apache.tools.ant.types.TarFileSet;
-import org.apache.tools.ant.types.ZipFileSet;
+import org.apache.tools.ant.types.resources.Union;
import org.apache.tools.ant.util.CollectionUtils;
/**
* A resource collection that treats all nested resources as archives
* and returns the contents of the archives as its content.
- *
- * @since Ant 1.8.0
*/
public class Archives extends DataType
implements ResourceCollection, Cloneable {
private Union zips = new Union();
private Union tars = new Union();
+ private Union ars = new Union();
+ private Union cpios = new Union();
/**
* Wrapper to identify nested resource collections as ZIP
@@ -69,6 +68,30 @@
}
/**
+ * Wrapper to identify nested resource collections as AR
+ * archives.
+ */
+ public Union createArs() {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ setChecked(false);
+ return ars;
+ }
+
+ /**
+ * Wrapper to identify nested resource collections as CPIO
+ * archives.
+ */
+ public Union createCpios() {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ setChecked(false);
+ return cpios;
+ }
+
+ /**
* Sums the sizes of nested archives.
*/
public int size() {
@@ -116,6 +139,8 @@
*/
public void setRefid(Reference r) {
if (zips.getResourceCollections().size() > 0
+ || ars.getResourceCollections().size() > 0
+ || cpios.getResourceCollections().size() > 0
|| tars.getResourceCollections().size() > 0) {
throw tooManyAttributes();
}
@@ -132,6 +157,8 @@
Archives a = (Archives) super.clone();
a.zips = (Union) zips.clone();
a.tars = (Union) tars.clone();
+ a.ars = (Union) ars.clone();
+ a.cpios = (Union) cpios.clone();
return a;
} catch (CloneNotSupportedException e) {
throw new BuildException(e);
@@ -154,6 +181,14 @@
l.add(configureArchive(new TarFileSet(),
(Resource) iter.next()));
}
+ for (Iterator iter = ars.iterator(); iter.hasNext(); ) {
+ l.add(configureArchive(new ArFileSet(),
+ (Resource) iter.next()));
+ }
+ for (Iterator iter = cpios.iterator(); iter.hasNext(); ) {
+ l.add(configureArchive(new CpioFileSet(),
+ (Resource) iter.next()));
+ }
return l.iterator();
}
@@ -185,6 +220,8 @@
} else {
pushAndInvokeCircularReferenceCheck(zips, stk, p);
pushAndInvokeCircularReferenceCheck(tars, stk, p);
+ pushAndInvokeCircularReferenceCheck(ars, stk, p);
+ pushAndInvokeCircularReferenceCheck(cpios, stk, p);
setChecked(true);
}
}
Propchange:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Archives.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Archives.java
------------------------------------------------------------------------------
svn:mergeinfo =
Copied: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/archives-test.xml
(from r808745,
ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml)
URL:
http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/archives-test.xml?p2=ant/sandbox/antlibs/compress/trunk/src/tests/antunit/archives-test.xml&p1=ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml&r1=808745&r2=808747&rev=808747&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/types/resources/archives-test.xml
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/archives-test.xml Fri
Aug 28 04:23:24 2009
@@ -15,19 +15,20 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"
+ xmlns:cmp="antlib:org.apache.ant.compress">
- <import file="../../antunit-base.xml"/>
+ <import file="antunit-base.xml"/>
<target name="testExtractJars">
<mkdir dir="${output}"/>
<copy todir="${output}">
- <archives>
+ <cmp:archives>
<zips>
- <fileset dir="../../../../../build/lib"
+ <fileset dir="${ant.home}/lib"
includes="ant-*.jar"/>
</zips>
- </archives>
+ </cmp:archives>
</copy>
<au:assertFileExists
file="${output}/org/apache/tools/ant/launch/Launcher.class"/>
@@ -35,15 +36,18 @@
file="${output}/org/apache/tools/ant/BuildFileTest.class"/>
</target>
- <target name="testMixingZipsAndTars">
+ <target name="testMixingFormats">
<mkdir dir="${output}"/>
<tar destfile="${output}/test.tar.gz" compression="gzip">
<fileset file="${ant.file}"/>
</tar>
+ <cmp:cpio destfile="${output}/test.cpio">
+ <cmp:arfileset file="${ant.file}" prefix="cpio/"/>
+ </cmp:cpio>
<copy todir="${output}">
- <archives>
+ <cmp:archives>
<zips>
- <fileset dir="../../../../../build/lib"
+ <fileset dir="${ant.home}/lib"
includes="ant-launcher.jar"/>
</zips>
<tars>
@@ -51,24 +55,35 @@
<file file="${output}/test.tar.gz"/>
</gzipresource>
</tars>
- </archives>
+ <ars>
+ <file file="../resources/asf-logo.gif.ar"/>
+ </ars>
+ <cpios>
+ <fileset file="${output}/test.cpio"/>
+ </cpios>
+ </cmp:archives>
</copy>
<au:assertFileExists
file="${output}/org/apache/tools/ant/launch/Launcher.class"/>
<basename property="filename" file="${ant.file}"/>
<au:assertFileExists file="${output}/${filename}"/>
+ <au:assertFilesMatch
+ actual="${output}/asf-logo.gif"
+ expected="../resources/asf-logo.gif"
+ />
+ <au:assertFileExists file="${output}/cpio/${filename}"/>
</target>
<target name="testReference">
<mkdir dir="${output}"/>
- <archives id="ref">
+ <cmp:archives id="ref">
<zips>
- <fileset dir="../../../../../build/lib"
+ <fileset dir="${ant.home}/lib"
includes="ant-launcher.jar"/>
</zips>
- </archives>
+ </cmp:archives>
<copy todir="${output}">
- <archives refid="ref"/>
+ <cmp:archives refid="ref"/>
</copy>
<au:assertFileExists
file="${output}/org/apache/tools/ant/launch/Launcher.class"/>
@@ -78,33 +93,33 @@
<au:expectfailure
message="This data type contains a circular reference.">
<copy todir="${output}">
- <archives id="ref">
+ <cmp:archives id="ref">
<zips>
- <archives refid="ref"/>
+ <cmp:archives refid="ref"/>
</zips>
- </archives>
+ </cmp:archives>
</copy>
</au:expectfailure>
<au:expectfailure
message="This data type contains a circular reference.">
<copy todir="${output}">
- <archives refid="ref"/>
+ <cmp:archives refid="ref"/>
</copy>
</au:expectfailure>
</target>
<!-- works but takes a veeeeeery long time -->
- <target name="XtestResourcesManualExample">
+ <target name="skip-testResourcesManualExample">
<mkdir dir="${output}"/>
<copy todir="${output}">
- <archives>
+ <cmp:archives>
<zips>
<restrict>
<path path="${java.class.path}"/>
<name name="*.jar"/>
</restrict>
</zips>
- </archives>
+ </cmp:archives>
</copy>
<au:assertFileExists
file="${output}/org/apache/tools/ant/launch/Launcher.class"/>
@@ -114,21 +129,21 @@
<mkdir dir="${output}/control"/>
<mkdir dir="${input}/htdocs/manual"/>
<touch file="${input}/htdocs/manual/foo.txt"/>
- <zip destfile="${input}/examples-a.zip">
+ <cmp:zip destfile="${input}/examples-a.zip">
<fileset dir="." includes="*.xml"/>
- </zip>
- <zip destfile="${output}/manual.zip">
+ </cmp:zip>
+ <cmp:zip destfile="${output}/manual.zip">
<mappedresources>
<fileset dir="${input}/htdocs/manual"/>
<globmapper from="*" to="docs/user-guide/*"/>
</mappedresources>
- <archives>
+ <cmp:archives>
<zips>
<fileset dir="${input}" includes="examples*.zip"/>
</zips>
- </archives>
- </zip>
- <unzip src="${output}/manual.zip" dest="${output}/control"/>
+ </cmp:archives>
+ </cmp:zip>
+ <cmp:unzip src="${output}/manual.zip" dest="${output}/control"/>
<au:assertFileExists file="${output}/control/archives-test.xml"/>
<au:assertFileExists file="${output}/control/docs/user-guide/foo.txt"/>
</target>
Propchange:
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/archives-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/archives-test.xml
------------------------------------------------------------------------------
svn:mergeinfo =