213 lines
8.8 KiB
Diff
213 lines
8.8 KiB
Diff
From 3765880e1128d16f9e9f82bfc2892b5303fc1db2 Mon Sep 17 00:00:00 2001
|
|
From: Kristian Rosenvold <krosenvold@apache.org>
|
|
Date: Thu, 16 Apr 2015 21:45:12 +0200
|
|
Subject: [PATCH] Added overload with encoding
|
|
|
|
---
|
|
.../codehaus/plexus/archiver/AbstractArchiver.java | 17 +++++++++++++++--
|
|
.../java/org/codehaus/plexus/archiver/Archiver.java | 20 ++++++++++++++++++++
|
|
.../plexus/archiver/diags/DelgatingArchiver.java | 7 +++++++
|
|
.../plexus/archiver/diags/DryRunArchiver.java | 8 ++++++++
|
|
.../codehaus/plexus/archiver/diags/NoOpArchiver.java | 7 +++++++
|
|
.../plexus/archiver/diags/TrackingArchiver.java | 7 +++++++
|
|
6 files changed, 64 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java b/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java
|
|
index d25b95e..a67ba90 100755
|
|
--- a/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java
|
|
+++ b/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java
|
|
@@ -23,6 +23,7 @@
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.lang.reflect.UndeclaredThrowableException;
|
|
+import java.nio.charset.Charset;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
@@ -44,6 +45,7 @@
|
|
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
|
|
import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier;
|
|
import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollection;
|
|
+import org.codehaus.plexus.components.io.resources.EncodingSupported;
|
|
import org.codehaus.plexus.components.io.resources.PlexusIoArchivedResourceCollection;
|
|
import org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection;
|
|
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
|
|
@@ -661,7 +663,7 @@ public Map getDirs()
|
|
}
|
|
}
|
|
|
|
- protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet fileSet )
|
|
+ protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet fileSet, Charset charset )
|
|
throws ArchiverException
|
|
{
|
|
final File archiveFile = fileSet.getArchive();
|
|
@@ -677,6 +679,10 @@ protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet
|
|
"Error adding archived file-set. PlexusIoResourceCollection not found for: " + archiveFile, e );
|
|
}
|
|
|
|
+ if (resources instanceof EncodingSupported ) {
|
|
+ ((EncodingSupported)resources).setEncoding( charset );
|
|
+
|
|
+ }
|
|
if ( resources instanceof PlexusIoArchivedResourceCollection )
|
|
{
|
|
( (PlexusIoArchivedResourceCollection) resources ).setFile( fileSet.getArchive() );
|
|
@@ -731,7 +737,14 @@ private void doAddResource(Object item){
|
|
public void addArchivedFileSet( final ArchivedFileSet fileSet )
|
|
throws ArchiverException
|
|
{
|
|
- final PlexusIoResourceCollection resourceCollection = asResourceCollection( fileSet );
|
|
+ final PlexusIoResourceCollection resourceCollection = asResourceCollection( fileSet, null );
|
|
+ addResources( resourceCollection );
|
|
+ }
|
|
+
|
|
+ public void addArchivedFileSet( final ArchivedFileSet fileSet, Charset charset )
|
|
+ throws ArchiverException
|
|
+ {
|
|
+ final PlexusIoResourceCollection resourceCollection = asResourceCollection( fileSet, charset );
|
|
addResources( resourceCollection );
|
|
}
|
|
|
|
diff --git a/src/main/java/org/codehaus/plexus/archiver/Archiver.java b/src/main/java/org/codehaus/plexus/archiver/Archiver.java
|
|
index 35cc201..aac9d87 100644
|
|
--- a/src/main/java/org/codehaus/plexus/archiver/Archiver.java
|
|
+++ b/src/main/java/org/codehaus/plexus/archiver/Archiver.java
|
|
@@ -22,6 +22,7 @@
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
+import java.nio.charset.Charset;
|
|
import java.util.HashSet;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
@@ -177,6 +178,25 @@ void addArchivedFileSet( @Nonnull File archiveFile, String prefix, String[] incl
|
|
void addArchivedFileSet( ArchivedFileSet fileSet )
|
|
throws ArchiverException;
|
|
|
|
+
|
|
+ /**
|
|
+ * Adds the given archive file set to the archive. This method is basically obsoleting
|
|
+ * {@link #addArchivedFileSet(File)}, {@link #addArchivedFileSet(File, String[], String[])}, and
|
|
+ * {@link #addArchivedFileSet(File, String, String[], String[])}. However, as these methods are in widespread use,
|
|
+ * they cannot easily be made deprecated.
|
|
+ *
|
|
+ * @param charset the encoding to use, particularly useful to specific non-standard filename encodings
|
|
+ * for some kinds of archives (for instance zip files)
|
|
+ *
|
|
+ * Stream transformers are supported on this method
|
|
+ *
|
|
+ * @param fileSet the fileSet to add
|
|
+ * @param charset
|
|
+ * @since 1.0-alpha-9
|
|
+ */
|
|
+ void addArchivedFileSet( ArchivedFileSet fileSet, Charset charset )
|
|
+ throws ArchiverException;
|
|
+
|
|
/**
|
|
* Adds the given resource collection to the archive.
|
|
*
|
|
diff --git a/src/main/java/org/codehaus/plexus/archiver/diags/DelgatingArchiver.java b/src/main/java/org/codehaus/plexus/archiver/diags/DelgatingArchiver.java
|
|
index 81a18ad..186ba08 100644
|
|
--- a/src/main/java/org/codehaus/plexus/archiver/diags/DelgatingArchiver.java
|
|
+++ b/src/main/java/org/codehaus/plexus/archiver/diags/DelgatingArchiver.java
|
|
@@ -28,6 +28,7 @@
|
|
import javax.annotation.Nonnull;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
+import java.nio.charset.Charset;
|
|
import java.util.Map;
|
|
|
|
@SuppressWarnings( { "UnusedDeclaration", "deprecation" } )
|
|
@@ -134,6 +135,12 @@ public void addArchivedFileSet( ArchivedFileSet fileSet )
|
|
target.addArchivedFileSet( fileSet );
|
|
}
|
|
|
|
+ public void addArchivedFileSet( ArchivedFileSet fileSet, Charset charset )
|
|
+ throws ArchiverException
|
|
+ {
|
|
+ target.addArchivedFileSet( fileSet, charset );
|
|
+ }
|
|
+
|
|
public void addResource( PlexusIoResource resource, String destFileName, int permissions )
|
|
throws ArchiverException
|
|
{
|
|
diff --git a/src/main/java/org/codehaus/plexus/archiver/diags/DryRunArchiver.java b/src/main/java/org/codehaus/plexus/archiver/diags/DryRunArchiver.java
|
|
index d11d64a..6396731 100644
|
|
--- a/src/main/java/org/codehaus/plexus/archiver/diags/DryRunArchiver.java
|
|
+++ b/src/main/java/org/codehaus/plexus/archiver/diags/DryRunArchiver.java
|
|
@@ -30,6 +30,7 @@
|
|
import javax.annotation.Nonnull;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
+import java.nio.charset.Charset;
|
|
|
|
/**
|
|
* A dry run archiver that does nothing. Some methods fall through to the underlying
|
|
@@ -197,6 +198,13 @@ public void addArchivedFileSet( final ArchivedFileSet fileSet )
|
|
debug( "DRY RUN: Skipping delegated call to: " + getMethodName() );
|
|
}
|
|
|
|
+ @Override
|
|
+ public void addArchivedFileSet( ArchivedFileSet fileSet, Charset charset )
|
|
+ throws ArchiverException
|
|
+ {
|
|
+ debug( "DRY RUN: Skipping delegated call to: " + getMethodName() );
|
|
+ }
|
|
+
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
diff --git a/src/main/java/org/codehaus/plexus/archiver/diags/NoOpArchiver.java b/src/main/java/org/codehaus/plexus/archiver/diags/NoOpArchiver.java
|
|
index d277144..8dc5fd3 100644
|
|
--- a/src/main/java/org/codehaus/plexus/archiver/diags/NoOpArchiver.java
|
|
+++ b/src/main/java/org/codehaus/plexus/archiver/diags/NoOpArchiver.java
|
|
@@ -28,6 +28,7 @@
|
|
import javax.annotation.Nonnull;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
+import java.nio.charset.Charset;
|
|
import java.util.Collections;
|
|
import java.util.Map;
|
|
|
|
@@ -130,6 +131,12 @@ public void addArchivedFileSet( ArchivedFileSet fileSet )
|
|
|
|
}
|
|
|
|
+ public void addArchivedFileSet( ArchivedFileSet fileSet, Charset charset )
|
|
+ throws ArchiverException
|
|
+ {
|
|
+
|
|
+ }
|
|
+
|
|
public void addResource( PlexusIoResource resource, String destFileName, int permissions )
|
|
throws ArchiverException
|
|
{
|
|
diff --git a/src/main/java/org/codehaus/plexus/archiver/diags/TrackingArchiver.java b/src/main/java/org/codehaus/plexus/archiver/diags/TrackingArchiver.java
|
|
index 9c2149e..8e45d00 100644
|
|
--- a/src/main/java/org/codehaus/plexus/archiver/diags/TrackingArchiver.java
|
|
+++ b/src/main/java/org/codehaus/plexus/archiver/diags/TrackingArchiver.java
|
|
@@ -27,6 +27,7 @@
|
|
import javax.annotation.Nonnull;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
+import java.nio.charset.Charset;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
@@ -138,6 +139,12 @@ public void addArchivedFileSet( final ArchivedFileSet fileSet )
|
|
added.add( new Addition( fileSet, null, null, null, -1 ) );
|
|
}
|
|
|
|
+ public void addArchivedFileSet( final ArchivedFileSet fileSet, Charset charset )
|
|
+ throws ArchiverException
|
|
+ {
|
|
+ added.add( new Addition( fileSet, null, null, null, -1 ) );
|
|
+ }
|
|
+
|
|
public void addResource( final PlexusIoResource resource, final String destFileName, final int permissions )
|
|
throws ArchiverException
|
|
{
|
|
--
|
|
2.1.0
|
|
|