Author: bodewig
Date: Fri Sep 27 20:31:44 2013
New Revision: 1527064
URL: http://svn.apache.org/r1527064
Log:
resources for 7z
Added:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZFileSet.java
- copied, changed from r1527026,
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java
- copied, changed from r1527026,
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipResource.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZScanner.java
- copied, changed from r1527026,
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
ant/antlibs/compress/trunk/src/tests/antunit/sevenzentry-test.xml
- copied, changed from r1527026,
ant/antlibs/compress/trunk/src/tests/antunit/zipentry-test.xml
ant/antlibs/compress/trunk/src/tests/antunit/sevenzfileset-test.xml
- copied, changed from r1527026,
ant/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml
Modified:
ant/antlibs/compress/trunk/changes.xml
ant/antlibs/compress/trunk/docs/compresource.html
ant/antlibs/compress/trunk/docs/entry.html
ant/antlibs/compress/trunk/docs/fileset.html
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/EntryHelper.java
Modified: ant/antlibs/compress/trunk/changes.xml
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/changes.xml?rev=1527064&r1=1527063&r2=1527064&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/changes.xml (original)
+++ ant/antlibs/compress/trunk/changes.xml Fri Sep 27 20:31:44 2013
@@ -56,6 +56,9 @@
Read-only support for LZMA standalone compression has been
added.
</action>
+ <action type="add">
+ Read-only support for file based 7z archives has been added.
+ </action>
</release>
<release version="1.2" date="2012-04-20">
Modified: ant/antlibs/compress/trunk/docs/compresource.html
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/compresource.html?rev=1527064&r1=1527063&r2=1527064&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/compresource.html (original)
+++ ant/antlibs/compress/trunk/docs/compresource.html Fri Sep 27 20:31:44 2013
@@ -89,6 +89,8 @@
<h2><a name="lzmaresource">lzmaresource</a></h2>
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
<p>This is a <a href="#compresource">compressed resource</a> using the
LZMA compression.</p>
Modified: ant/antlibs/compress/trunk/docs/entry.html
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/entry.html?rev=1527064&r1=1527063&r2=1527064&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/entry.html (original)
+++ ant/antlibs/compress/trunk/docs/entry.html Fri Sep 27 20:31:44 2013
@@ -76,7 +76,23 @@
</cmp:arentry>
</pre>
-<p>Represents the entry named some-file.txt in archive some-archive.ar.</p>
+<h2><a name="arjentry">arjentry</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
+<p>An <a href="#archiveentry">archive entry</a> representing an entry
+ in a ARJ archive.</p>
+
+<h4>Examples</h4>
+
+<pre>
+<cmp:arjentry xmlns:cmp="antlib:org.apache.ant.compress"
+ name="some-file.txt">
+ <file file="some-archive.arj"/>
+</cmp:arjentry>
+</pre>
+
+<p>Represents the entry named some-file.txt in archive some-archive.arj.</p>
<h2><a name="cpioentry">cpioentry</a></h2>
@@ -112,6 +128,24 @@
<p>Represents the entry named /some-file.txt in archive some-archive.dump.</p>
+<h2><a name="sevenzentry">sevenzentry</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
+<p>An <a href="#archiveentry">archive entry</a> representing an entry
+ in a 7z archive.</p>
+
+<h4>Examples</h4>
+
+<pre>
+<cmp:sevenzentry xmlns:cmp="antlib:org.apache.ant.compress"
+ name="some-file.txt">
+ <file file="some-archive.7z"/>
+</cmp:sevenzentry>
+</pre>
+
+<p>Represents the entry named some-file.txt in archive some-archive.7z.</p>
+
<h2><a name="tarentry">tarentry</a></h2>
<p>An <a href="#archiveentry">archive entry</a> representing an entry
Modified: ant/antlibs/compress/trunk/docs/fileset.html
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/fileset.html?rev=1527064&r1=1527063&r2=1527064&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/fileset.html (original)
+++ ant/antlibs/compress/trunk/docs/fileset.html Fri Sep 27 20:31:44 2013
@@ -341,6 +341,13 @@ resource collection</h4>
target directory, no files get overwritten unless they are
out-of-date.</p>
+<h2><a name="sevenzfileset">SevenZFileSet</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
+<p>A <code><sevenzfileset></code> is
+ an <a href="#archivefileset">archive fileset</a> for 7z archives.</p>
+
<h2><a name="tarfileset">TarFileSet</a></h2>
<p>A <code><tarfileset></code> is
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=1527064&r1=1527063&r2=1527064&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 Fri
Sep 27 20:31:44 2013
@@ -118,6 +118,10 @@
classname="org.apache.ant.compress.resources.DumpResource"
/>
<typedef
+ name="sevenzentry"
+ classname="org.apache.ant.compress.resources.SevenZResource"
+ />
+ <typedef
name="tarentry"
classname="org.apache.ant.compress.resources.TarResource"
/>
@@ -143,6 +147,10 @@
classname="org.apache.ant.compress.resources.DumpFileSet"
/>
<typedef
+ name="sevenzfileset"
+ classname="org.apache.ant.compress.resources.SevenZFileSet"
+ />
+ <typedef
name="tarfileset"
classname="org.apache.ant.compress.resources.TarFileSet"
/>
Copied:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZFileSet.java
(from r1527026,
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java)
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZFileSet.java?p2=ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZFileSet.java&p1=ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java&r1=1527026&r2=1527064&rev=1527064&view=diff
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipFileSet.java
(original)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZFileSet.java
Fri Sep 27 20:31:44 2013
@@ -21,18 +21,19 @@ import org.apache.tools.ant.types.Archiv
import org.apache.tools.ant.types.FileSet;
/**
- * A ZipFileSet is a FileSet with extra attributes useful in the context of
- * Zip/Jar tasks.
+ * A SevenZFileSet is a FileSet with extra attributes useful in the context of
+ * SevenZ tasks.
*
- * A ZipFileSet extends FileSets with the ability to extract a subset of the
- * entries of a Zip file for inclusion in another Zip file. It also includes
- * a prefix attribute which is prepended to each entry in the output Zip file.
+ * A SevenZFileSet extends FileSets with the ability to extract a subset of the
+ * entries of a SevenZ file for inclusion in another SevenZ file. It also
includes
+ * a prefix attribute which is prepended to each entry in the output SevenZ
file.
*
+ * @since Apache Compress Antlib 1.3
*/
-public class ZipFileSet extends CommonsCompressFileSet {
+public class SevenZFileSet extends CommonsCompressFileSet {
- /** Constructor for ZipFileSet */
- public ZipFileSet() {
+ /** Constructor for SevenZFileSet */
+ public SevenZFileSet() {
super();
}
@@ -40,15 +41,15 @@ public class ZipFileSet extends CommonsC
* Constructor using a fileset argument.
* @param fileset the fileset to use
*/
- protected ZipFileSet(FileSet fileset) {
+ protected SevenZFileSet(FileSet fileset) {
super(fileset);
}
/**
- * Constructor using a zipfileset argument.
- * @param fileset the zipfileset to use
+ * Constructor using a sevenzfileset argument.
+ * @param fileset the sevenzfileset to use
*/
- protected ZipFileSet(ZipFileSet fileset) {
+ protected SevenZFileSet(SevenZFileSet fileset) {
super(fileset);
}
@@ -56,28 +57,26 @@ public class ZipFileSet extends CommonsC
* Constructor using a CommonsCompressFileSet argument.
* @param fileset the fileset to use
*/
- protected ZipFileSet(CommonsCompressFileSet fileset) {
+ protected SevenZFileSet(CommonsCompressFileSet fileset) {
super(fileset);
}
/**
* Return a new archive scanner based on this one.
- * @return a new ZipScanner with the same encoding as this one.
+ * @return a new SevenZScanner with the same encoding as this one.
*/
protected ArchiveScanner newArchiveScanner() {
- ZipScanner zs = new ZipScanner(getSkipUnreadableEntries(),
getProject());
- zs.setEncoding(getEncoding());
- return zs;
+ return new SevenZScanner(getSkipUnreadableEntries(), getProject());
}
protected CommonsCompressFileSet newFileSet(FileSet fs) {
- if (fs instanceof ZipFileSet) {
- return new ZipFileSet((ZipFileSet) fs);
+ if (fs instanceof SevenZFileSet) {
+ return new SevenZFileSet((SevenZFileSet) fs);
}
if (fs instanceof CommonsCompressFileSet) {
- return new ZipFileSet((CommonsCompressFileSet) fs);
+ return new SevenZFileSet((CommonsCompressFileSet) fs);
}
- return new ZipFileSet(fs);
+ return new SevenZFileSet(fs);
}
}
Copied:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java
(from r1527026,
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipResource.java)
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java?p2=ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java&p1=ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipResource.java&r1=1527026&r2=1527064&rev=1527064&view=diff
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipResource.java
(original)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java
Fri Sep 27 20:31:44 2013
@@ -20,7 +20,6 @@ package org.apache.ant.compress.resource
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
-import java.io.FilterInputStream;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
@@ -28,75 +27,71 @@ import org.apache.tools.ant.types.Resour
import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.ant.util.FileUtils;
-import org.apache.ant.compress.util.ZipStreamFactory;
+import org.apache.ant.compress.util.SevenZStreamFactory;
import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipExtraField;
-import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZFile;
/**
- * A Resource representation of an entry in a zipfile.
+ * A Resource representation of an entry in a sevenzfile.
+ *
+ * @since Apache Compress Antlib 1.3
*/
-public final class ZipResource extends CommonsCompressArchiveResource {
-
- private ZipExtraField[] extras;
- private int method;
+public final class SevenZResource extends CommonsCompressArchiveResource {
/**
* Default constructor.
*/
- public ZipResource() {
- super(new ZipStreamFactory(), "zip");
+ public SevenZResource() {
+ super(new SevenZStreamFactory(), "7z");
}
/**
- * Construct a ZipResource representing the specified
- * entry in the specified zipfile.
- * @param z the zipfile as File.
- * @param enc the encoding used for filenames.
- * @param e the ZipEntry.
+ * Construct a SevenZResource representing the specified
+ * entry in the specified 7z file.
+ * @param z the 7z file as File.
+ * @param enc the encoding used for filenames - ignored.
+ * @param e the SevenZEntry.
*/
- public ZipResource(File z, String enc, ZipArchiveEntry e) {
- super(new ZipStreamFactory(), "zip", z, e);
- setEncoding(enc);
+ public SevenZResource(File z, String enc, SevenZArchiveEntry e) {
+ super(new SevenZStreamFactory(), "7z", z, e);
setEntry(e);
}
/**
- * Construct a ZipResource representing the specified
- * entry in the specified zip archive.
- * @param z the zipfile as File.
- * @param enc the encoding used for filenames.
- * @param e the ZipEntry.
- */
- public ZipResource(Resource z, String enc, ZipArchiveEntry e) {
- super(new ZipStreamFactory(), "zip", z, e);
- setEncoding(enc);
+ * Construct a SevenZResource representing the specified
+ * entry in the specified 7z archive.
+ * @param z the 7z archive
+ * @param enc the encoding used for filenames - ignored.
+ * @param e the SevenZEntry.
+ */
+ public SevenZResource(Resource z, String enc, SevenZArchiveEntry e) {
+ super(new SevenZStreamFactory(), "sevenz", z, e);
setEntry(e);
}
/**
- * Set the zipfile that holds this ZipResource.
- * @param z the zipfile as a File.
+ * Set the 7z that holds this SevenZResource.
+ * @param z the 7z file as a File.
*/
- public void setZipfile(File z) {
+ public void setSevenZFile(File z) {
setArchive(z);
}
/**
- * Set the zipfile that holds this ZipResource.
- * @param z the zipfile as a Resource.
+ * Set the 7z file that holds this SevenZResource.
+ * @param z the 7z as a Resource.
*/
- public void setZipResource(Resource z) {
+ public void setSevenZResource(Resource z) {
addConfigured(z);
}
/**
- * Get the zipfile that holds this ZipResource.
- * @return the zipfile as a File or null if it is not a file.
+ * Get the 7z file that holds this SevenZResource.
+ * @return the 7z file as a File or null if it is not a file.
*/
- public File getZipfile() {
+ public File getSevenZFile() {
FileProvider fp = (FileProvider) getArchive().as(FileProvider.class);
return fp != null ? fp.getFile() : null;
}
@@ -104,90 +99,76 @@ public final class ZipResource extends C
/**
* Return an InputStream for reading the contents of this Resource.
* @return an InputStream object.
- * @throws IOException if the zip file cannot be opened,
+ * @throws IOException if the sevenz file cannot be opened,
* or the entry cannot be read.
*/
public InputStream getInputStream() throws IOException {
if (isReference()) {
return ((Resource) getCheckedRef()).getInputStream();
}
- File f = getZipfile();
+ File f = getSevenZFile();
if (f == null) {
return super.getInputStream();
}
- final ZipFile z = new ZipFile(f, getEncoding());
- ZipArchiveEntry ze = z.getEntry(getName());
- if (ze == null) {
- z.close();
- throw new BuildException("no entry " + getName() + " in "
- + getArchive());
- }
- return new FilterInputStream(z.getInputStream(ze)) {
- public void close() throws IOException {
- FileUtils.close(in);
- z.close();
- }
- protected void finalize() throws Throwable {
- try {
- close();
- } finally {
- super.finalize();
- }
+ final SevenZFile z = new SevenZFile(f);
+ SevenZArchiveEntry ze = z.getNextEntry();
+ while (ze != null) {
+ if (ze.getName().equals(getName())) {
+ return new InputStream() {
+ public int read() throws IOException {
+ return z.read();
+ }
+ public int read(byte[] b) throws IOException {
+ return z.read(b);
+ }
+ public void close() throws IOException {
+ z.close();
+ }
+ protected void finalize() throws Throwable {
+ try {
+ close();
+ } finally {
+ super.finalize();
+ }
+ }
+ };
}
- };
- }
-
- /**
- * Retrieves extra fields.
- * @return an array of the extra fields
- */
- public ZipExtraField[] getExtraFields() {
- if (isReference()) {
- return ((ZipResource) getCheckedRef()).getExtraFields();
- }
- checkEntry();
- if (extras == null) {
- return new ZipExtraField[0];
+ ze = z.getNextEntry();
}
- return extras;
- }
-
- /**
- * The compression method that has been used.
- */
- public int getMethod() {
- return method;
+ z.close();
+ throw new BuildException("no entry " + getName() + " in "
+ + getArchive());
}
/**
* fetches information from the named entry inside the archive.
*/
protected void fetchEntry() {
- File f = getZipfile();
+ File f = getSevenZFile();
if (f == null) {
super.fetchEntry();
return;
}
- ZipFile z = null;
+ SevenZFile z = null;
try {
- z = new ZipFile(getZipfile(), getEncoding());
- setEntry(z.getEntry(getName()));
+ z = new SevenZFile(f);
+ SevenZArchiveEntry ze = z.getNextEntry();
+ while (ze != null) {
+ if (ze.getName().equals(getName())) {
+ setEntry(ze);
+ return;
+ }
+ ze = z.getNextEntry();
+ }
} catch (IOException e) {
log(e.getMessage(), Project.MSG_DEBUG);
throw new BuildException(e);
} finally {
- ZipFile.closeQuietly(z);
- }
- }
-
- protected void setEntry(ArchiveEntry e) {
- super.setEntry(e);
- if (e != null) {
- ZipArchiveEntry ze = (ZipArchiveEntry) e;
- extras = ze.getExtraFields(true);
- method = ze.getMethod();
+ if (z != null) {
+ z.close();
+ }
}
}
Copied:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZScanner.java
(from r1527026,
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java)
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZScanner.java?p2=ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZScanner.java&p1=ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java&r1=1527026&r2=1527064&rev=1527064&view=diff
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
(original)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZScanner.java
Fri Sep 27 20:31:44 2013
@@ -20,37 +20,37 @@ package org.apache.ant.compress.resource
import java.io.File;
import java.io.IOException;
-import java.util.Enumeration;
import java.util.Map;
-import java.util.zip.ZipException;
-import org.apache.ant.compress.util.ZipStreamFactory;
+import org.apache.ant.compress.util.SevenZStreamFactory;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.ant.compress.util.Messages;
-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZFile;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.resources.FileProvider;
/**
- * Scans zip archives for resources.
+ * Scans 7z archives for resources.
+ *
+ * @since Apache Compress Antlib 1.3
*/
-public class ZipScanner extends CommonsCompressArchiveScanner {
+public class SevenZScanner extends CommonsCompressArchiveScanner {
- public ZipScanner() {
+ public SevenZScanner() {
this(false, null);
}
- public ZipScanner(boolean skipUnreadable, Project project) {
- super(new ZipStreamFactory(),
+ public SevenZScanner(boolean skipUnreadable, Project project) {
+ super(new SevenZStreamFactory(),
new CommonsCompressArchiveScanner.ResourceBuilder() {
public Resource buildResource(Resource archive, String
encoding,
- ArchiveEntry entry) {
- return new ZipResource(archive, encoding,
- (ZipArchiveEntry) entry);
+ ArchiveEntry entry) {
+ return new SevenZResource(archive, encoding,
+ (SevenZArchiveEntry) entry);
}
}, skipUnreadable, project);
}
@@ -60,7 +60,8 @@ public class ZipScanner extends CommonsC
* archive.
*
* @param src the archive to scan.
- * @param encoding encoding used to encode file names inside the archive.
+ * @param encoding encoding used to encode file names inside the
+ * archive - ignored.
* @param fileEntries Map (name to resource) of non-directory
* resources found inside the archive.
* @param matchFileEntries Map (name to resource) of non-directory
@@ -85,41 +86,43 @@ public class ZipScanner extends CommonsC
}
File srcFile = fp.getFile();
- ZipArchiveEntry entry = null;
- ZipFile zf = null;
+ SevenZArchiveEntry entry = null;
+ SevenZFile zf = null;
try {
try {
- zf = new ZipFile(srcFile, encoding);
- } catch (ZipException ex) {
- throw new BuildException("Problem reading " + srcFile, ex);
- } catch (IOException ex) {
- throw new BuildException("Problem opening " + srcFile, ex);
- }
- Enumeration e = zf.getEntries();
- while (e.hasMoreElements()) {
- entry = (ZipArchiveEntry) e.nextElement();
- if (getSkipUnreadableEntries() && !zf.canReadEntryData(entry))
{
- log(Messages.skippedIsUnreadable(entry));
- continue;
- }
- Resource r = new ZipResource(srcFile, encoding, entry);
- String name = entry.getName();
- if (entry.isDirectory()) {
- name = trimSeparator(name);
- dirEntries.put(name, r);
- if (match(name)) {
- matchDirEntries.put(name, r);
+ zf = new SevenZFile(srcFile);
+ entry = zf.getNextEntry();
+ while (entry != null) {
+ /* TODO implement canReadEntryData in CC
+ if (getSkipUnreadableEntries() &&
!zf.canReadEntryData(entry)) {
+ log(Messages.skippedIsUnreadable(entry));
+ continue;
}
- } else {
- fileEntries.put(name, r);
- if (match(name)) {
- matchFileEntries.put(name, r);
+ */
+ Resource r = new SevenZResource(srcFile, encoding, entry);
+ String name = entry.getName();
+ if (entry.isDirectory()) {
+ name = trimSeparator(name);
+ dirEntries.put(name, r);
+ if (match(name)) {
+ matchDirEntries.put(name, r);
+ }
+ } else {
+ fileEntries.put(name, r);
+ if (match(name)) {
+ matchFileEntries.put(name, r);
+ }
}
+ entry = zf.getNextEntry();
}
+ } catch (IOException ex) {
+ throw new BuildException("Problem opening " + srcFile, ex);
}
} finally {
- ZipFile.closeQuietly(zf);
+ if (zf != null) {
+ zf.close();
+ }
}
}
-}
\ No newline at end of file
+}
Modified:
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/EntryHelper.java
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/EntryHelper.java?rev=1527064&r1=1527063&r2=1527064&view=diff
==============================================================================
---
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/EntryHelper.java
(original)
+++
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/EntryHelper.java
Fri Sep 27 20:31:44 2013
@@ -27,6 +27,7 @@ import org.apache.commons.compress.archi
import org.apache.commons.compress.archivers.arj.ArjArchiveEntry;
import org.apache.commons.compress.archivers.cpio.CpioArchiveEntry;
import org.apache.commons.compress.archivers.dump.DumpArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
@@ -55,6 +56,9 @@ public class EntryHelper {
if (entry instanceof CpioArchiveEntry) {
return (int) ((CpioArchiveEntry) entry).getMode();
}
+ if (entry instanceof SevenZArchiveEntry) {
+ return UNKNOWN_ID;
+ }
if (entry instanceof TarArchiveEntry) {
return ((TarArchiveEntry) entry).getMode();
}
@@ -87,6 +91,9 @@ public class EntryHelper {
if (entry instanceof CpioArchiveEntry) {
return (int) ((CpioArchiveEntry) entry).getUID();
}
+ if (entry instanceof SevenZArchiveEntry) {
+ return UNKNOWN_ID;
+ }
if (entry instanceof TarArchiveEntry) {
return ((TarArchiveEntry) entry).getUserId();
}
@@ -117,6 +124,9 @@ public class EntryHelper {
if (entry instanceof CpioArchiveEntry) {
return (int) ((CpioArchiveEntry) entry).getGID();
}
+ if (entry instanceof SevenZArchiveEntry) {
+ return UNKNOWN_ID;
+ }
if (entry instanceof TarArchiveEntry) {
return ((TarArchiveEntry) entry).getGroupId();
}
Copied: ant/antlibs/compress/trunk/src/tests/antunit/sevenzentry-test.xml (from
r1527026, ant/antlibs/compress/trunk/src/tests/antunit/zipentry-test.xml)
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/sevenzentry-test.xml?p2=ant/antlibs/compress/trunk/src/tests/antunit/sevenzentry-test.xml&p1=ant/antlibs/compress/trunk/src/tests/antunit/zipentry-test.xml&r1=1527026&r2=1527064&rev=1527064&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/zipentry-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/sevenzentry-test.xml Fri Sep
27 20:31:44 2013
@@ -27,27 +27,11 @@
<mkdir dir="${input}"/>
</target>
- <target name="testZipSource" depends="setUp">
+ <target name="testFileSource" depends="setUp">
<copy todir="${output}">
- <cmp:zipentry name="asf-logo.gif">
- <file file="../resources/asf-logo.gif.zip"/>
- </cmp:zipentry>
- </copy>
- <au:assertFilesMatch
- actual="${output}/asf-logo.gif"
- expected="../resources/asf-logo.gif"
- />
- </target>
-
- <target name="testUncompressSource" depends="setUp">
- <gzip destfile="${input}/asf-logo.gif.zip.gz"
- src="../resources/asf-logo.gif.zip"/>
- <copy todir="${output}">
- <cmp:zipentry name="asf-logo.gif">
- <gzipresource>
- <file file="${input}/asf-logo.gif.zip.gz"/>
- </gzipresource>
- </cmp:zipentry>
+ <cmp:sevenzentry name="asf-logo.gif">
+ <file file="../resources/asf-logo.gif.7z"/>
+ </cmp:sevenzentry>
</copy>
<au:assertFilesMatch
actual="${output}/asf-logo.gif"
@@ -57,19 +41,12 @@
<target name="testResourceProperties">
<au:assertTrue>
- <cond:islastmodified datetime="2001-11-19-15:34:20"
+ <cond:islastmodified datetime="2013-09-27-20:54:32"
pattern="yyyy-MM-dd-HH:mm:ss">
- <cmp:zipentry name="asf-logo.gif">
- <file file="../resources/asf-logo.gif.zip"/>
- </cmp:zipentry>
+ <cmp:sevenzentry name="asf-logo.gif">
+ <file file="../resources/asf-logo.gif.7z"/>
+ </cmp:sevenzentry>
</cond:islastmodified>
</au:assertTrue>
- <au:assertTrue>
- <cmp:hasmode mode="644">
- <cmp:zipentry name="asf-logo.gif">
- <file file="../resources/asf-logo.gif.zip"/>
- </cmp:zipentry>
- </cmp:hasmode>
- </au:assertTrue>
</target>
</project>
Copied: ant/antlibs/compress/trunk/src/tests/antunit/sevenzfileset-test.xml
(from r1527026,
ant/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml)
URL:
http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/sevenzfileset-test.xml?p2=ant/antlibs/compress/trunk/src/tests/antunit/sevenzfileset-test.xml&p1=ant/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml&r1=1527026&r2=1527064&rev=1527064&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/zipfileset-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/sevenzfileset-test.xml Fri Sep
27 20:31:44 2013
@@ -30,65 +30,65 @@
dir="${basedir}"
includes="*.xml"
/>
- <cmp:zipfileset id="modify-refid-2"
+ <cmp:sevenzfileset id="modify-refid-2"
refid="modify-refid-1"
prefix="WEB-INF/lib/"/>
<delete quiet="yes" dir="${build.dir}"/>
<mkdir dir="${output}"/>
<jar jarfile="${output}/jar.jar">
- <cmp:zipfileset refid="modify-refid-2"/>
+ <cmp:sevenzfileset refid="modify-refid-2"/>
</jar>
<unjar src="${output}/jar.jar"
dest="${output}"/>
<au:assertTrue>
- <available file="${output}/WEB-INF/lib/zipfileset-test.xml"/>
+ <available file="${output}/WEB-INF/lib/sevenzfileset-test.xml"/>
</au:assertTrue>
</target>
<target name="test-refid-check-prefix">
- <cmp:zipfileset id="test-refid"
- dir="${basedir}"/>
+ <cmp:sevenzfileset id="test-refid"
+ dir="${basedir}"/>
<au:expectfailure>
- <cmp:zipfileset id="ref2"
- refid="test-refid"
- prefix="WEB-INF/lib/"/>
+ <cmp:sevenzfileset id="ref2"
+ refid="test-refid"
+ prefix="WEB-INF/lib/"/>
</au:expectfailure>
<au:expectfailure>
- <cmp:zipfileset id="ref3"
- prefix="WEB-INF/lib/"
- ReFiD="test-refid"/>
+ <cmp:sevenzfileset id="ref3"
+ prefix="WEB-INF/lib/"
+ ReFiD="test-refid"/>
</au:expectfailure>
</target>
<target name="test-refid-check-encoding">
- <cmp:zipfileset id="test-refid2"
- encoding="utf-8"
- dir="${basedir}"/>
+ <cmp:sevenzfileset id="test-refid2"
+ encoding="utf-8"
+ dir="${basedir}"/>
<au:expectfailure>
- <cmp:zipfileset id="ref4"
- encoding="utf-8"
- refid="test-refid2"/>
+ <cmp:sevenzfileset id="ref4"
+ encoding="utf-8"
+ refid="test-refid2"/>
</au:expectfailure>
</target>
<target name="testMissingArchive" depends="setUp">
- <au:expectfailure expectedMessage="The archive foo.zip doesn't exist">
+ <au:expectfailure expectedMessage="The archive foo.7z doesn't exist">
<copy todir="${output}">
- <cmp:zipfileset src="foo.zip"/>
+ <cmp:sevenzfileset src="foo.7z"/>
</copy>
</au:expectfailure>
</target>
<target name="testMissingArchiveDoesntMatter" depends="setUp">
<copy todir="${output}">
- <cmp:zipfileset src="foo.zip" errorOnMissingArchive="false"/>
+ <cmp:sevenzfileset src="foo.7z" errorOnMissingArchive="false"/>
</copy>
</target>
- <target name="testZipSource" depends="setUp">
+ <target name="testSevenZSource" depends="setUp">
<copy todir="${output}">
- <cmp:zipfileset src="../resources/asf-logo.gif.zip"
- includes="*.gif"/>
+ <cmp:sevenzfileset src="../resources/asf-logo.gif.7z"
+ includes="*.gif"/>
</copy>
<au:assertFilesMatch
actual="${output}/asf-logo.gif"
@@ -96,35 +96,4 @@
/>
</target>
- <target name="testUncompressSource" depends="setUp">
- <gzip destfile="${input}/asf-logo.gif.zip.gz"
- src="../resources/asf-logo.gif.zip"/>
- <copy todir="${output}">
- <cmp:zipfileset includes="*.gif">
- <gzipresource>
- <file file="${input}/asf-logo.gif.zip.gz"/>
- </gzipresource>
- </cmp:zipfileset>
- </copy>
- <au:assertFilesMatch
- actual="${output}/asf-logo.gif"
- expected="../resources/asf-logo.gif"
- />
- </target>
-
- <target name="testFailsOnUnreadableEntries" depends="setUp">
- <au:expectfailure message="unsupported feature encryption">
- <copy todir="${output}">
- <cmp:zipfileset src="../resources/password-encrypted.zip"/>
- </copy>
- </au:expectfailure>
- </target>
-
- <target name="testSkipUnreadableEntries" depends="setUp">
- <copy todir="${output}">
- <cmp:zipfileset src="../resources/password-encrypted.zip"
- skipUnreadableEntries="true"/>
- </copy>
- <au:assertLogContains text="Commons Compress cannot read it"/>
- </target>
</project>