aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Nieder2012-12-03 12:55:02 (EST)
committerJonathan Nieder2012-12-03 13:49:06 (EST)
commit1547eaf7c57e93b3ff7fb9d2450fe3e87ba614ed (patch)
tree410d4438b4d0ae1270bd2a8c1349aee94bc2557a
parent55e8f2a433589a4c4969546493173a05ec4830dd (diff)
downloadjgit-1547eaf7c57e93b3ff7fb9d2450fe3e87ba614ed.zip
jgit-1547eaf7c57e93b3ff7fb9d2450fe3e87ba614ed.tar.gz
jgit-1547eaf7c57e93b3ff7fb9d2450fe3e87ba614ed.tar.bz2
[RFC] archive: Switch to commons-compress as ZIP archiverrefs/changes/07/9007/2
The Apache Commons Compress library provides a similar interface to java.util.zip with some features not found in java.util.zip, including support for inclusion of metadata (file mode and symlink targets) and support for multiple file formats (zip, .tar.xz, etc). Use it, in preparation for making use of these features. No functional change intended yet. A previous version of this patch used plexus-archiver. That is a heavier-weight dependency and offers a less convenient interface. Thanks to James Moger and Chris Aniszczyk for advice. Change-Id: Id01146950bb9c18dae0169311e3cde2c3bfa675e
-rw-r--r--org.eclipse.jgit.pgm/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.jgit.pgm/pom.xml5
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java11
-rw-r--r--pom.xml7
4 files changed, 20 insertions, 6 deletions
diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
index df026e0..57b59af 100644
--- a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
@@ -6,7 +6,8 @@ Bundle-Version: 2.2.0.qualifier
Bundle-Vendor: %provider_name
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.eclipse.jgit.api;version="[2.2.0,2.3.0)",
+Import-Package: org.apache.commons.compress.archivers.zip;version="[1.3,2.0)",
+ org.eclipse.jgit.api;version="[2.2.0,2.3.0)",
org.eclipse.jgit.api.errors;version="[2.2.0,2.3.0)",
org.eclipse.jgit.awtui;version="[2.2.0,2.3.0)",
org.eclipse.jgit.blame;version="[2.2.0,2.3.0)",
diff --git a/org.eclipse.jgit.pgm/pom.xml b/org.eclipse.jgit.pgm/pom.xml
index 02d3463..5cf1084 100644
--- a/org.eclipse.jgit.pgm/pom.xml
+++ b/org.eclipse.jgit.pgm/pom.xml
@@ -72,6 +72,11 @@
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>${project.version}</version>
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java
index 786524e..ec937a3 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java
@@ -46,9 +46,9 @@ package org.eclipse.jgit.pgm;
import java.lang.String;
import java.lang.System;
import java.text.MessageFormat;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
@@ -69,7 +69,7 @@ class Archive extends TextBuiltin {
final TreeWalk walk = new TreeWalk(db);
final ObjectReader reader = walk.getObjectReader();
final MutableObjectId idBuf = new MutableObjectId();
- final ZipOutputStream out = new ZipOutputStream(outs);
+ final ZipArchiveOutputStream out = new ZipArchiveOutputStream(outs);
if (tree == null)
throw die(CLIText.get().treeIsRequired);
@@ -87,11 +87,12 @@ class Archive extends TextBuiltin {
continue;
walk.getObjectId(idBuf, 0);
- final ZipEntry entry = new ZipEntry(name);
+ final ZipArchiveEntry entry = new ZipArchiveEntry(name);
final ObjectLoader loader = reader.open(idBuf);
entry.setSize(loader.getSize());
- out.putNextEntry(entry);
+ out.putArchiveEntry(entry);
loader.copyTo(out);
+ out.closeArchiveEntry();
if (mode != FileMode.REGULAR_FILE)
System.err.println(MessageFormat.format( //
diff --git a/pom.xml b/pom.xml
index 891a023..085e00f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,6 +173,7 @@
<jsch-version>0.1.44-1</jsch-version>
<junit-version>4.5</junit-version>
<args4j-version>2.0.12</args4j-version>
+ <commons-compress-version>1.3</commons-compress-version>
<servlet-api-version>2.5</servlet-api-version>
<jetty-version>7.6.0.v20120127</jetty-version>
<clirr-version>2.4</clirr-version>
@@ -416,6 +417,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>${commons-compress-version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty-version}</version>