You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2014/03/11 06:13:05 UTC
svn commit: r1576191 - in /ant/antlibs/compress/trunk: ./ docs/
src/main/org/apache/ant/compress/resources/
src/main/org/apache/ant/compress/taskdefs/
Author: bodewig
Date: Tue Mar 11 05:13:04 2014
New Revision: 1576191
URL: http://svn.apache.org/r1576191
Log:
add flag to keep the compression methods when updating 7z archives or adding files from sevenzfilesets
Modified:
ant/antlibs/compress/trunk/docs/archive.html
ant/antlibs/compress/trunk/project-template.ivy.xml
ant/antlibs/compress/trunk/project-template.pom
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/SevenZ.java
Modified: ant/antlibs/compress/trunk/docs/archive.html
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/archive.html?rev=1576191&r1=1576190&r2=1576191&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/archive.html (original)
+++ ant/antlibs/compress/trunk/docs/archive.html Tue Mar 11 05:13:04 2014
@@ -297,6 +297,15 @@
at all.</td>
<td valign="top" align="center">No, default is LZMA2.</td>
</tr>
+ <tr>
+ <td valign="top">keepcompression</td>
+ <td valign="top">For entries coming from existing archives (like
+ nested <em>sevenzfileset</em>s or while updating the archive), keep
+ the compression as it has been originally instead of using the
+ <em>contentCompression</em> attribute. Defaults to false.
+ <em>since 1.5</em></td>
+ <td align="center" valign="top">No</td>
+ </tr>
</table>
<h3><a name="tar">Tar</a></h3>
@@ -516,7 +525,7 @@ the executable files and include all oth
<td valign="top">For entries coming from existing archives (like
nested <em>zipfileset</em>s or while updating the archive), keep
the compression as it has been originally instead of using the
- <em>level</em> attribute. Defaults false.</td>
+ <em>level</em> attribute. Defaults to false.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
Modified: ant/antlibs/compress/trunk/project-template.ivy.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/project-template.ivy.xml?rev=1576191&r1=1576190&r2=1576191&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/project-template.ivy.xml (original)
+++ ant/antlibs/compress/trunk/project-template.ivy.xml Tue Mar 11 05:13:04 2014
@@ -52,7 +52,7 @@
</publications>
<dependencies>
<dependency org="org.apache.commons" name="commons-compress"
- rev="1.7"/>
- <dependency org="org.tukaani" name="xz" rev="1.4"/>
+ rev="1.8"/>
+ <dependency org="org.tukaani" name="xz" rev="1.5"/>
</dependencies>
</ivy-module>
Modified: ant/antlibs/compress/trunk/project-template.pom
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/project-template.pom?rev=1576191&r1=1576190&r2=1576191&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/project-template.pom (original)
+++ ant/antlibs/compress/trunk/project-template.pom Tue Mar 11 05:13:04 2014
@@ -50,12 +50,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
- <version>1.7</version>
+ <version>1.8</version>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
- <version>1.4</version>
+ <version>1.5</version>
</dependency>
</dependencies>
</project>
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java?rev=1576191&r1=1576190&r2=1576191&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/SevenZResource.java Tue Mar 11 05:13:04 2014
@@ -40,6 +40,8 @@ import org.apache.commons.compress.archi
*/
public final class SevenZResource extends CommonsCompressArchiveResource {
+ private Iterable/*<? extends SevenZMethodConfiguration>*/ contentMethods;
+
/**
* Default constructor.
*/
@@ -142,6 +144,15 @@ public final class SevenZResource extend
}
/**
+ * Gets the (compression) methods to used for entry's content.
+ *
+ * @since 1.5
+ */
+ public Iterable/*<? extends SevenZMethodConfiguration>*/ getContentMethods() {
+ return contentMethods;
+ }
+
+ /**
* fetches information from the named entry inside the archive.
*/
protected void fetchEntry() {
@@ -177,4 +188,12 @@ public final class SevenZResource extend
}
}
+ protected void setEntry(ArchiveEntry e) {
+ super.setEntry(e);
+ if (e != null) {
+ SevenZArchiveEntry ze = (SevenZArchiveEntry) e;
+ contentMethods = ze.getContentMethods();
+ }
+ }
+
}
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java?rev=1576191&r1=1576190&r2=1576191&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java Tue Mar 11 05:13:04 2014
@@ -913,6 +913,8 @@ public abstract class ArchiveBase extend
* Various flags a (archive) resource may hold in addition to
* being a plain resource.
*/
+ // FIXME this isn't really scaling if it wants to be a catch all
+ // for all relevant flags of all formats.
public class ResourceFlags {
private final int mode;
private final boolean modeSet;
@@ -922,6 +924,7 @@ public abstract class ArchiveBase extend
private final String userName;
private final String groupName;
private final int compressionMethod;
+ private Iterable/*<? extends SevenZMethodConfiguration>*/ contentMethods;
public ResourceFlags() {
this(-1);
@@ -935,22 +938,28 @@ public abstract class ArchiveBase extend
int compressionMethod) {
this(mode, extraFields, EntryHelper.UNKNOWN_ID,
EntryHelper.UNKNOWN_ID, null, null,
- compressionMethod);
+ compressionMethod, null);
}
public ResourceFlags(int mode, int uid, int gid) {
- this(mode, new ZipExtraField[0], uid, gid, null, null, -1);
+ this(mode, new ZipExtraField[0], uid, gid, null, null, -1, null);
}
public ResourceFlags(int mode, int uid, int gid, String userName,
String groupName) {
- this(mode, new ZipExtraField[0], uid, gid, userName, groupName, -1);
+ this(mode, new ZipExtraField[0], uid, gid, userName, groupName, -1, null);
+ }
+
+ public ResourceFlags(Iterable/*<? extends SevenZMethodConfiguration>*/ contentMethods) {
+ this(-1, new ZipExtraField[0], EntryHelper.UNKNOWN_ID,
+ EntryHelper.UNKNOWN_ID, null, null, -1, contentMethods);
}
private ResourceFlags(int mode, ZipExtraField[] extraFields,
int uid, int gid,
String userName, String groupName,
- int compressionMethod) {
+ int compressionMethod,
+ Iterable/*<? extends SevenZMethodConfiguration>*/ contentMethods) {
this.mode = mode;
this.extraFields = extraFields;
this.gid = gid;
@@ -960,6 +969,7 @@ public abstract class ArchiveBase extend
int m = mode & UnixStat.PERM_MASK;
modeSet = mode >= 0 && (m > 0 || (m == 0 && preserve0permissions));
this.compressionMethod = compressionMethod;
+ this.contentMethods = contentMethods;
}
public boolean hasModeBeenSet() { return modeSet; }
@@ -985,6 +995,11 @@ public abstract class ArchiveBase extend
public boolean hasCompressionMethod() { return compressionMethod >= 0; }
public int getCompressionMethod() { return compressionMethod; }
+
+ public boolean hasContentMethods() { return contentMethods != null; }
+ public Iterable/*<? extends SevenZMethodConfiguration>*/ getContentMethods() {
+ return contentMethods;
+ }
}
/**
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/SevenZ.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/SevenZ.java?rev=1576191&r1=1576190&r2=1576191&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/SevenZ.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/SevenZ.java Tue Mar 11 05:13:04 2014
@@ -38,6 +38,7 @@ import org.apache.tools.ant.types.Resour
*/
public class SevenZ extends ArchiveBase {
+ private boolean keepCompression = false;
private String contentCompression;
public SevenZ() {
@@ -66,6 +67,11 @@ public class SevenZ extends ArchiveBase
entry.setLastModifiedDate(new Date(r.getResource()
.getLastModified()));
entry.setSize(r.getResource().getSize());
+ if (keepCompression
+ && r.getResourceFlags().hasContentMethods()) {
+ entry.setContentMethods(r.getResourceFlags()
+ .getContentMethods());
+ }
return entry;
}
});
@@ -88,4 +94,15 @@ public class SevenZ extends ArchiveBase
public void setContentCompression(String method) {
this.contentCompression = method;
}
+
+ /**
+ * Whether the original compression of entries coming from a 7z
+ * archive should be kept (for example when updating an archive).
+ * Default is false.
+ * @param keep if true, keep the original compression
+ * @since 1.5
+ */
+ public void setKeepCompression(boolean keep) {
+ keepCompression = keep;
+ }
}