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 2012/03/20 22:09:14 UTC
svn commit: r1303154 - in /ant/antlibs/compress/trunk: ./ docs/
src/main/org/apache/ant/compress/resources/
src/main/org/apache/ant/compress/taskdefs/
src/main/org/apache/ant/compress/util/ src/tests/antunit/
Author: bodewig
Date: Tue Mar 20 21:09:13 2012
New Revision: 1303154
URL: http://svn.apache.org/viewvc?rev=1303154&view=rev
Log:
add support for file name encoding in tar archives
Modified:
ant/antlibs/compress/trunk/changes.xml
ant/antlibs/compress/trunk/docs/archive.html
ant/antlibs/compress/trunk/docs/expand.html
ant/antlibs/compress/trunk/docs/fileset.html
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarFileSet.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Untar.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ArchiveStreamFactory.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/TarStreamFactory.java
ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ZipStreamFactory.java
ant/antlibs/compress/trunk/src/tests/antunit/tarfileset-test.xml
Modified: ant/antlibs/compress/trunk/changes.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/changes.xml?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/changes.xml (original)
+++ ant/antlibs/compress/trunk/changes.xml Tue Mar 20 21:09:13 2012
@@ -70,6 +70,13 @@
attribute to "star", "gnu" or "pax". See the tar task's
documentation of details.
</action>
+ <action type="add" breaks-bwc="true">
+ The tar and untar tasks as well as the tar related resources
+ now allow the encoding for file names to be specified. The
+ default is the platform's native encoding, it used to be
+ ISO-8859-1 in Commons Compress 1.3 and thus the Compress
+ Antlib 1.1.
+ </action>
</release>
<release version="1.1" date="2011-11-05">
Modified: ant/antlibs/compress/trunk/docs/archive.html
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/archive.html?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/archive.html (original)
+++ ant/antlibs/compress/trunk/docs/archive.html Tue Mar 20 21:09:13 2012
@@ -298,6 +298,17 @@
are "ustar", "oldgnu", "gnu", "star" and "pax".</td>
<td valign="top" align="center">No, default is "ustar"</td>
</tr>
+ <tr>
+ <td valign="top">encoding</td>
+ <td valign="top">
+ The character encoding to use for filenames inside the tar
+ file. For a list of possible values
+ see <a href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html">http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html</a>.<br>
+ Defaults <code>native-encoding</code> which is the magic value
+ for the platform's default character encoding.<br/>
+ <em>since Compress Antlib 1.2</em></td>
+ <td align="center" valign="top">No</td>
+ </tr>
</table>
<h4><a name="tarformat"></a>Tar format</h4>
Modified: ant/antlibs/compress/trunk/docs/expand.html
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/expand.html?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/expand.html (original)
+++ ant/antlibs/compress/trunk/docs/expand.html Tue Mar 20 21:09:13 2012
@@ -124,6 +124,28 @@ mapper</a>.</p>
<p>An <a href="#expand">unarchiving task</a> for TAR archives.</p>
+<p>In addition to the parameters above, the untar tasks supports the
+ following attributes:</p>
+
+<table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">encoding</td>
+ <td valign="top">
+ The character encoding that has been used for filenames
+ inside the tar file. For a list of possible values see <a
+ href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html">http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html</a>.<br>
+ Defaults <code>native-encoding</code> which is the magic value for
+ the platform's default character encoding.<br/>
+ <em>since Compress Antlib 1.2</em></td>
+ <td align="center" valign="top">No</td>
+ </tr>
+</table>
+
<h3><a name="unzip">UnZip</a></h3>
<p>An <a href="#expand">unarchiving task</a> for ZIP archives.</p>
Modified: ant/antlibs/compress/trunk/docs/fileset.html
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/docs/fileset.html?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/docs/fileset.html (original)
+++ ant/antlibs/compress/trunk/docs/fileset.html Tue Mar 20 21:09:13 2012
@@ -314,6 +314,17 @@ resource collection</h4>
</td>
<td align="center" valign="top">No</td>
</tr>
+ <tr>
+ <td valign="top">encoding</td>
+ <td valign="top">
+ The character encoding that has been used for filenames
+ inside the tar file. For a list of possible values see <a
+ href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html">http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html</a>.<br>
+ Defaults <code>native-encoding</code> which is the magic value for
+ the platform's default character encoding.<br/>
+ <em>since Compress Antlib 1.2</em></td>
+ <td align="center" valign="top">No</td>
+ </tr>
</tbody>
</table>
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarFileSet.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarFileSet.java?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarFileSet.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarFileSet.java Tue Mar 20 21:09:13 2012
@@ -52,6 +52,7 @@ public class TarFileSet extends ArchiveF
private int gid;
private boolean skipUnreadable = false;
+ private String encoding = null;
/** Constructor for TarFileSet */
public TarFileSet() {
@@ -72,6 +73,34 @@ public class TarFileSet extends ArchiveF
*/
protected TarFileSet(TarFileSet fileset) {
super(fileset);
+ encoding = fileset.encoding;
+ }
+
+ /**
+ * Set the encoding used for this ZipFileSet.
+ * @param enc encoding as String.
+ * @since Compress Antlib 1.2
+ */
+ public void setEncoding(String enc) {
+ checkTarFileSetAttributesAllowed();
+ this.encoding = enc;
+ }
+
+ /**
+ * Get the encoding used for this ZipFileSet.
+ * @return String encoding.
+ * @since Compress Antlib 1.2
+ */
+ public String getEncoding() {
+ if (isReference()) {
+ AbstractFileSet ref = getRef(getProject());
+ if (ref instanceof ZipFileSet) {
+ return ((ZipFileSet) ref).getEncoding();
+ } else {
+ return null;
+ }
+ }
+ return encoding;
}
/**
@@ -200,13 +229,17 @@ public class TarFileSet extends ArchiveF
* @return the created scanner.
*/
protected ArchiveScanner newArchiveScanner() {
- return new CommonsCompressArchiveScanner(new TarStreamFactory(),
+ CommonsCompressArchiveScanner cs =
+ new CommonsCompressArchiveScanner(new TarStreamFactory(),
new CommonsCompressArchiveScanner.ResourceBuilder() {
public Resource buildResource(Resource archive, String encoding,
ArchiveEntry entry) {
- return new TarResource(archive, (TarArchiveEntry) entry);
+ return new TarResource(archive, encoding,
+ (TarArchiveEntry) entry);
}
}, skipUnreadable, getProject());
+ cs.setEncoding(encoding);
+ return cs;
}
/**
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java Tue Mar 20 21:09:13 2012
@@ -62,6 +62,32 @@ public final class TarResource extends C
}
/**
+ * Construct a TarResource representing the specified
+ * entry in the specified archive.
+ * @param a the archive as File.
+ * @param enc the encoding used for filenames.
+ * @param e the TarEntry.
+ * @since Compress Antlib 1.2
+ */
+ public TarResource(File a, String enc, TarArchiveEntry e) {
+ this(a, e);
+ setEncoding(enc);
+ }
+
+ /**
+ * Construct a TarResource representing the specified
+ * entry in the specified archive.
+ * @param a the archive as Resource.
+ * @param enc the encoding used for filenames.
+ * @param e the TarEntry.
+ * @since Compress Antlib 1.2
+ */
+ public TarResource(Resource a, String enc, TarArchiveEntry e) {
+ this(a, e);
+ setEncoding(enc);
+ }
+
+ /**
* @return the user name for the tar entry
*/
public String getUserName() {
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Untar.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Untar.java?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Untar.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Untar.java Tue Mar 20 21:09:13 2012
@@ -27,4 +27,8 @@ public class Untar extends ExpandBase {
public Untar() {
super(new TarStreamFactory());
}
+
+ public void setEncoding(String encoding) {
+ internalSetEncoding(encoding);
+ }
}
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ArchiveStreamFactory.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ArchiveStreamFactory.java?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ArchiveStreamFactory.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ArchiveStreamFactory.java Tue Mar 20 21:09:13 2012
@@ -33,7 +33,7 @@ public interface ArchiveStreamFactory {
/**
* @param stream the stream to read from, should be buffered
* @param encoding the encoding of the entry names, ignored by all
- * formats except zip
+ * formats except tar and zip
*/
public ArchiveInputStream getArchiveStream(InputStream stream,
String encoding)
@@ -43,7 +43,7 @@ public interface ArchiveStreamFactory {
/**
* @param stream the stream to write to, should be buffered
* @param encoding the encoding of the entry names, ignored by all
- * formats except zip
+ * formats except tar and zip
*/
public ArchiveOutputStream getArchiveStream(OutputStream stream,
String encoding)
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/TarStreamFactory.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/TarStreamFactory.java?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/TarStreamFactory.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/TarStreamFactory.java Tue Mar 20 21:09:13 2012
@@ -31,21 +31,21 @@ public class TarStreamFactory implements
/**
* @param stream the stream to read from, should be buffered
- * @param encoding the encoding of the entry names, ignored
+ * @param encoding the encoding of the entry names
*/
public ArchiveInputStream getArchiveStream(InputStream stream,
String encoding)
throws IOException {
- return new TarArchiveInputStream(stream);
+ return new TarArchiveInputStream(stream, encoding);
}
/**
* @param stream the stream to write to, should be buffered
- * @param encoding the encoding of the entry names, ignored
+ * @param encoding the encoding of the entry names
*/
public ArchiveOutputStream getArchiveStream(OutputStream stream,
String encoding)
throws IOException {
- return new TarArchiveOutputStream(stream);
+ return new TarArchiveOutputStream(stream, encoding);
}
}
\ No newline at end of file
Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ZipStreamFactory.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ZipStreamFactory.java?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ZipStreamFactory.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/ZipStreamFactory.java Tue Mar 20 21:09:13 2012
@@ -56,8 +56,7 @@ public class ZipStreamFactory implements
/**
* @param file the file to read from
- * @param encoding the encoding of the entry names, ignored by all
- * formats except zip
+ * @param encoding the encoding of the entry names
*/
public ArchiveInputStream getArchiveInputStream(File file,
String encoding)
@@ -69,8 +68,7 @@ public class ZipStreamFactory implements
/**
* @param file the file to write to
- * @param encoding the encoding of the entry names, ignored by all
- * formats except zip
+ * @param encoding the encoding of the entry names
*/
public ArchiveOutputStream getArchiveOutputStream(File file,
String encoding)
Modified: ant/antlibs/compress/trunk/src/tests/antunit/tarfileset-test.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/tarfileset-test.xml?rev=1303154&r1=1303153&r2=1303154&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/tarfileset-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/tarfileset-test.xml Tue Mar 20 21:09:13 2012
@@ -25,6 +25,17 @@
<mkdir dir="${input}"/>
</target>
+ <target name="test-refid-check-encoding">
+ <cmp:tarfileset id="test-refid2"
+ encoding="utf-8"
+ dir="${basedir}"/>
+ <au:expectfailure>
+ <cmp:tarfileset id="ref4"
+ encoding="utf-8"
+ refid="test-refid2"/>
+ </au:expectfailure>
+ </target>
+
<target name="testMissingArchive">
<mkdir dir="${output}"/>
<au:expectfailure expectedMessage="The archive foo.tar doesn't exist">