Author: bodewig
Date: Sun Sep 4 03:45:35 2011
New Revision: 1164959
URL: http://svn.apache.org/viewvc?rev=1164959&view=rev
Log:
pack200 tasks/resources
Added:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Pack200Resource.java
(with props)
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java
(with props)
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java
(with props)
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Pack200StreamFactory.java
(with props)
ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml (with props)
ant/antlibs/compress/trunk/src/tests/antunit/pack200resource-test.xml
(with props)
ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml (with
props)
ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.pack (with
props)
Modified:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareArchiveStreamFactory.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareCompressorStreamFactory.java
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=1164959&r1=1164958&r2=1164959&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
(original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml Sun
Sep 4 03:45:35 2011
@@ -53,20 +53,28 @@
classname="org.apache.ant.compress.taskdefs.Zip"
/>
<taskdef
+ name="bunzip2"
+ classname="org.apache.ant.compress.taskdefs.BUnzip2"
+ />
+ <taskdef
name="gunzip"
classname="org.apache.ant.compress.taskdefs.GUnzip"
/>
<taskdef
- name="bunzip2"
- classname="org.apache.ant.compress.taskdefs.BUnzip2"
+ name="unpack200"
+ classname="org.apache.ant.compress.taskdefs.UnPack200"
+ />
+ <taskdef
+ name="bzip2"
+ classname="org.apache.ant.compress.taskdefs.BZip2"
/>
<taskdef
name="gzip"
classname="org.apache.ant.compress.taskdefs.GZip"
/>
<taskdef
- name="bzip2"
- classname="org.apache.ant.compress.taskdefs.BZip2"
+ name="pack200"
+ classname="org.apache.ant.compress.taskdefs.Pack200"
/>
<typedef
@@ -122,6 +130,10 @@
name="gzipresource"
classname="org.apache.ant.compress.resources.GZipResource"
/>
+ <typedef
+ name="pack200resource"
+ classname="org.apache.ant.compress.resources.Pack200Resource"
+ />
<componentdef
name="hasusername"
Added:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Pack200Resource.java
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Pack200Resource.java?rev=1164959&view=auto
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Pack200Resource.java
(added)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Pack200Resource.java
Sun Sep 4 03:45:35 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ant.compress.resources;
+
+import org.apache.ant.compress.util.Pack200StreamFactory;
+import org.apache.tools.ant.types.ResourceCollection;
+
+/**
+ * A Pack200 compressed resource.
+ */
+public final class Pack200Resource extends CommonsCompressCompressorResource {
+ private static final String NAME = "Pack200";
+
+ public Pack200Resource() {
+ super(NAME, new Pack200StreamFactory());
+ }
+
+ public Pack200Resource(ResourceCollection other) {
+ super(NAME, new Pack200StreamFactory(), other);
+ }
+}
Propchange:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/Pack200Resource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
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=1164959&view=auto
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java
(added)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java
Sun Sep 4 03:45:35 2011
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.ant.compress.taskdefs;
+
+import org.apache.ant.compress.resources.CommonsCompressCompressorResource;
+import org.apache.ant.compress.resources.Pack200Resource;
+import org.apache.ant.compress.util.Pack200StreamFactory;
+import org.apache.tools.ant.types.Resource;
+
+/**
+ * Compresses using pack200.
+ */
+public final class Pack200 extends PackBase {
+
+ public Pack200() {
+ super(new Pack200StreamFactory(),
+ new PackBase.ResourceWrapper() {
+ public CommonsCompressCompressorResource wrap(Resource dest) {
+ return new Pack200Resource(dest);
+ }
+ });
+ }
+
+}
\ No newline at end of file
Propchange:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
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=1164959&view=auto
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java
(added)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java
Sun Sep 4 03:45:35 2011
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.ant.compress.taskdefs;
+
+import org.apache.ant.compress.util.Pack200StreamFactory;
+
+/**
+ * Expands a pack200 archive.
+ */
+public final class UnPack200 extends UnpackBase {
+
+ public UnPack200() {
+ super(".pack", new Pack200StreamFactory());
+ }
+
+}
\ No newline at end of file
Propchange:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/UnPack200.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareArchiveStreamFactory.java
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareArchiveStreamFactory.java?rev=1164959&r1=1164958&r2=1164959&view=diff
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareArchiveStreamFactory.java
(original)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareArchiveStreamFactory.java
Sun Sep 4 03:45:35 2011
@@ -36,8 +36,8 @@ public interface FileAwareArchiveStreamF
* @param encoding the encoding of the entry names, ignored by all
* formats except zip
*/
- public ArchiveInputStream getArchiveInputStream(File file,
- String encoding)
+ ArchiveInputStream getArchiveInputStream(File file,
+ String encoding)
throws IOException;
@@ -46,8 +46,8 @@ public interface FileAwareArchiveStreamF
* @param encoding the encoding of the entry names, ignored by all
* formats except zip
*/
- public ArchiveOutputStream getArchiveOutputStream(File file,
- String encoding)
+ ArchiveOutputStream getArchiveOutputStream(File file,
+ String encoding)
throws IOException;
}
\ No newline at end of file
Modified:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareCompressorStreamFactory.java
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareCompressorStreamFactory.java?rev=1164959&r1=1164958&r2=1164959&view=diff
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareCompressorStreamFactory.java
(original)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/FileAwareCompressorStreamFactory.java
Sun Sep 4 03:45:35 2011
@@ -30,19 +30,20 @@ import org.apache.commons.compress.compr
*
* @since Apache Compress Antlib 1.1
*/
-public interface FileAwareCompressorStreamFactory {
+public interface FileAwareCompressorStreamFactory
+ extends CompressorStreamFactory {
/**
* @param file the file to read from
*/
- public CompressorInputStream getCompressorInputStream(File file)
+ CompressorInputStream getCompressorInputStream(File file)
throws IOException;
/**
* @param file the file to write to
*/
- public CompressorOutputStream getCompressorOutputStream(File file)
+ CompressorOutputStream getCompressorOutputStream(File file)
throws IOException;
}
\ No newline at end of file
Added:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Pack200StreamFactory.java
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Pack200StreamFactory.java?rev=1164959&view=auto
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Pack200StreamFactory.java
(added)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Pack200StreamFactory.java
Sun Sep 4 03:45:35 2011
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.ant.compress.util;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.compress.compressors.CompressorInputStream;
+import org.apache.commons.compress.compressors.CompressorOutputStream;
+import
org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
+import
org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream;
+
+/**
+ * Creates streams for the supported compression formats.
+ */
+public class Pack200StreamFactory implements FileAwareCompressorStreamFactory {
+
+ /**
+ * @param stream the stream to read from, should be buffered
+ */
+ public CompressorInputStream getCompressorStream(InputStream stream)
+ throws IOException {
+ return new Pack200CompressorInputStream(stream);
+ }
+
+ /**
+ * @param stream the stream to write to, should be buffered
+ */
+ public CompressorOutputStream getCompressorStream(OutputStream stream)
+ throws IOException {
+ return new Pack200CompressorOutputStream(stream);
+ }
+
+ /**
+ * @param file the file to read from
+ */
+ public CompressorInputStream getCompressorInputStream(File file)
+ throws IOException {
+ return new Pack200CompressorInputStream(file);
+ }
+
+ /**
+ * @param file the file to write to
+ */
+ public CompressorOutputStream getCompressorOutputStream(File file)
+ throws IOException {
+ return
+ getCompressorStream(new BufferedOutputStream(new
FileOutputStream(file)));
+ }
+}
\ No newline at end of file
Propchange:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Pack200StreamFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=1164959&view=auto
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml (added)
+++ ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml Sun Sep 4
03:45:35 2011
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="antunit"
+ xmlns:au="antlib:org.apache.ant.antunit"
+ xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
+ xmlns:cmp="antlib:org.apache.ant.compress">
+
+ <import file="antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${output}" />
+ </target>
+
+ <target name="testRealTest" depends="setUp">
+ <cmp:pack200 src="../resources/asf-logo.gif.zip"
+ destfile="${output}/asf-logo.gif.pack" />
+ <au:assertLogContains text="Building: asf-logo.gif.pack"/>
+ <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
+ </target>
+
+ <target name="testRealTestWithResource" depends="setUp">
+ <cmp:pack200 destfile="${output}/asf-logo.gif.pack">
+ <file file="../resources/asf-logo.gif.zip"/>
+ </cmp:pack200>
+ <au:assertLogContains text="Building: asf-logo.gif.pack"/>
+ <au:assertFileExists file="${output}/asf-logo.gif.pack"/>
+ </target>
+
+ <target name="testDateCheck" depends="setUp">
+ <touch file="${output}/asf-logo.gif.pack"/>
+ <cmp:pack200 src="../resources/asf-logo.gif.zip"
+ destfile="${output}/asf-logo.gif.pack" />
+ <au:assertLogContains text="Nothing to do: asf-logo.gif.pack is up to
date."/>
+ </target>
+
+ <target name="testNestedTask" depends="setUp">
+ <cmp:pack200 destfile="${output}/asf-logo.zip.pack">
+ <cmp:zip>
+ <cmp:cpiofileset src="../resources/asf-logo.gif.bin.cpio"
+ includes="asf-logo.gif"/>
+ </cmp:zip>
+ </cmp:pack200>
+ <au:assertFileExists file="${output}/asf-logo.zip.pack"/>
+ <au:assertTrue>
+ <cond:islastmodified datetime="2009-07-31-20:11:14 +0200"
+ pattern="yyyy-MM-dd-HH:mm:ss Z">
+ <cmp:zipentry name="asf-logo.gif">
+ <cmp:pack200resource>
+ <file file="${output}/asf-logo.zip.pack"/>
+ </cmp:pack200resource>
+ </cmp:zipentry>
+ </cond:islastmodified>
+ </au:assertTrue>
+ </target>
+</project>
Propchange: ant/antlibs/compress/trunk/src/tests/antunit/pack200-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/antlibs/compress/trunk/src/tests/antunit/pack200resource-test.xml
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/pack200resource-test.xml?rev=1164959&view=auto
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/pack200resource-test.xml
(added)
+++ ant/antlibs/compress/trunk/src/tests/antunit/pack200resource-test.xml Sun
Sep 4 03:45:35 2011
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project default="antunit"
+ xmlns:au="antlib:org.apache.ant.antunit"
+ xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
+ xmlns:cmp="antlib:org.apache.ant.compress">
+
+ <import file="antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${output}"/>
+ </target>
+
+ <target name="testNativePack200" depends="setUp">
+ <copy todir="${output}">
+ <cmp:zipfileset>
+ <cmp:pack200resource>
+ <file file="../resources/asf-logo.gif.pack"/>
+ </cmp:pack200resource>
+ </cmp:zipfileset>
+ </copy>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+</project>
Propchange:
ant/antlibs/compress/trunk/src/tests/antunit/pack200resource-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=1164959&view=auto
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml (added)
+++ ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml Sun Sep 4
03:45:35 2011
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="antunit"
+ xmlns:au="antlib:org.apache.ant.antunit"
+ xmlns:cmp="antlib:org.apache.ant.compress">
+
+ <import file="antunit-base.xml" />
+
+ <target name="setUp">
+ <mkdir dir="${output}"/>
+ <mkdir dir="${input}"/>
+ </target>
+
+ <target name="testAgainstPack200Task" depends="setUp">
+ <cmp:pack200 destfile="${input}/test.pack">
+ <cmp:zip>
+ <fileset dir="."/>
+ </cmp:zip>
+ </cmp:pack200>
+ <cmp:unpack200 src="${input}/test.pack" dest="${input}/test.zip"/>
+ <cmp:unzip src="${input}/test.zip" dest="${output}"/>
+ <au:assertFileExists file="${output}/untar-test.xml"/>
+ <au:assertFilesMatch
+ actual="${output}/untar-test.xml"
+ expected="untar-test.xml"
+ />
+ </target>
+
+ <target name="testAgainstNativePack200" depends="setUp">
+ <cmp:unpack200 src="../resources/asf-logo.gif.pack"
+ dest="${input}/test.zip" />
+ <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>
Propchange: ant/antlibs/compress/trunk/src/tests/antunit/unpack200-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.pack
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.pack?rev=1164959&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ant/antlibs/compress/trunk/src/tests/resources/asf-logo.gif.pack
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream