Skip to content

Commit f1cb37a

Browse files
committed
Upgrade to shaded c-compress 1.10-SNAPSHOT
Fixed tests
1 parent 4b766e4 commit f1cb37a

File tree

10 files changed

+1018
-78
lines changed

10 files changed

+1018
-78
lines changed

Diff for: pom.xml

+29-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>plexus-archiver</artifactId>
13-
<version>2.9.2-SNAPSHOT</version>
13+
<version>2.10-SNAPSHOT</version>
1414

1515
<name>Plexus Archiver Component</name>
1616

@@ -61,7 +61,7 @@
6161
<dependency>
6262
<groupId>org.apache.commons</groupId>
6363
<artifactId>commons-compress</artifactId>
64-
<version>1.9</version>
64+
<version>1.10-SNAPSHOT</version>
6565
</dependency>
6666
<dependency>
6767
<groupId>junit</groupId>
@@ -121,6 +121,33 @@
121121
</execution>
122122
</executions>
123123
</plugin>
124+
<plugin>
125+
<groupId>org.apache.maven.plugins</groupId>
126+
<artifactId>maven-shade-plugin</artifactId>
127+
<version>1.4</version>
128+
<executions>
129+
<execution>
130+
<phase>package</phase>
131+
<goals>
132+
<goal>shade</goal>
133+
</goals>
134+
<configuration>
135+
<minimizeJar>true</minimizeJar>
136+
<artifactSet>
137+
<includes>
138+
<include>org.apache.commons:commons-compress</include>
139+
</includes>
140+
</artifactSet>
141+
<relocations>
142+
<relocation>
143+
<pattern>org.apache.commons.compress</pattern>
144+
<shadedPattern>org.codehaus.plexus.archiver.commonscompress</shadedPattern>
145+
</relocation>
146+
</relocations>
147+
</configuration>
148+
</execution>
149+
</executions>
150+
</plugin>
124151
<plugin>
125152
<groupId>org.apache.maven.plugins</groupId>
126153
<artifactId>maven-enforcer-plugin</artifactId>

Diff for: src/main/java/org/codehaus/plexus/archiver/ear/EarArchiver.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
20+
import org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator;
2121
import org.codehaus.plexus.archiver.ArchiveEntry;
2222
import org.codehaus.plexus.archiver.ArchiverException;
2323
import org.codehaus.plexus.archiver.jar.JarArchiver;
@@ -79,7 +79,7 @@ public void addArchives( File directoryName, String[] includes, String[] exclude
7979
addDirectory( directoryName, "/", includes, excludes );
8080
}
8181

82-
protected void initZipOutputStream( ZipArchiveOutputStream zOut )
82+
protected void initZipOutputStream( ParallelScatterZipCreator zOut )
8383
throws ArchiverException, IOException
8484
{
8585
// If no webxml file is specified, it's an error.
@@ -94,7 +94,7 @@ protected void initZipOutputStream( ZipArchiveOutputStream zOut )
9494
/**
9595
* Overridden from ZipArchiver class to deal with application.xml
9696
*/
97-
protected void zipFile( ArchiveEntry entry, ZipArchiveOutputStream zOut, String vPath, int mode )
97+
protected void zipFile( ArchiveEntry entry, ParallelScatterZipCreator zOut, String vPath, int mode )
9898
throws IOException, ArchiverException
9999
{
100100
// If the file being added is META-INF/application.xml, we

Diff for: src/main/java/org/codehaus/plexus/archiver/jar/JarArchiver.java

+16-14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20+
import org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator;
2021
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
2122
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
2223
import org.codehaus.plexus.archiver.ArchiverException;
@@ -25,6 +26,7 @@
2526
import org.codehaus.plexus.logging.console.ConsoleLogger;
2627
import org.codehaus.plexus.util.IOUtil;
2728

29+
import javax.annotation.WillClose;
2830
import java.io.ByteArrayInputStream;
2931
import java.io.ByteArrayOutputStream;
3032
import java.io.File;
@@ -284,7 +286,7 @@ public void addConfiguredIndexJars( File indexJar )
284286
indexJars.add( indexJar.getAbsolutePath() );
285287
}
286288

287-
protected void initZipOutputStream( ZipArchiveOutputStream zOut )
289+
protected void initZipOutputStream( ParallelScatterZipCreator zOut )
288290
throws ArchiverException, IOException
289291
{
290292
if ( !skipWriting )
@@ -334,15 +336,15 @@ private Manifest createManifest()
334336
return finalManifest;
335337
}
336338

337-
private void writeManifest( ZipArchiveOutputStream zOut, Manifest manifest )
339+
private void writeManifest( ParallelScatterZipCreator zOut, Manifest manifest )
338340
throws IOException, ArchiverException
339341
{
340342
for ( Enumeration e = manifest.getWarnings(); e.hasMoreElements(); )
341343
{
342344
getLogger().warn( "Manifest warning: " + e.nextElement() );
343345
}
344346

345-
zipDir( null, zOut, "META-INF/", DEFAULT_DIR_MODE );
347+
zipDir( null, zOut, "META-INF/", DEFAULT_DIR_MODE, getEncoding());
346348
// time to write the manifest
347349
ByteArrayOutputStream baos = new ByteArrayOutputStream();
348350
manifest.write( baos );
@@ -352,7 +354,7 @@ private void writeManifest( ZipArchiveOutputStream zOut, Manifest manifest )
352354
super.initZipOutputStream( zOut );
353355
}
354356

355-
protected void finalizeZipOutputStream( ZipArchiveOutputStream zOut )
357+
protected void finalizeZipOutputStream( ParallelScatterZipCreator zOut )
356358
throws IOException, ArchiverException
357359
{
358360
if ( index )
@@ -373,7 +375,7 @@ protected void finalizeZipOutputStream( ZipArchiveOutputStream zOut )
373375
* @throws org.codehaus.plexus.archiver.ArchiverException
374376
* .
375377
*/
376-
private void createIndexList( ZipArchiveOutputStream zOut )
378+
private void createIndexList( ParallelScatterZipCreator zOut )
377379
throws IOException, ArchiverException
378380
{
379381
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -455,7 +457,7 @@ private void createIndexList( ZipArchiveOutputStream zOut )
455457
/**
456458
* Overridden from Zip class to deal with manifests and index lists.
457459
*/
458-
protected void zipFile( InputStream is, ZipArchiveOutputStream zOut, String vPath, long lastModified, File fromArchive,
460+
protected void zipFile( @WillClose InputStream is, ParallelScatterZipCreator zOut, String vPath, long lastModified, File fromArchive,
459461
int mode, String symlinkDestination )
460462
throws IOException, ArchiverException
461463
{
@@ -534,23 +536,23 @@ protected boolean createEmptyZip( File zipFile )
534536
return true;
535537
}
536538

537-
ZipArchiveOutputStream zOut = null;
538539
try
539540
{
540541
getLogger().debug( "Building MANIFEST-only jar: " + getDestFile().getAbsolutePath() );
541-
zOut = new ZipArchiveOutputStream( bufferedOutputStream( fileOutputStream( getDestFile(), "jar" ) ));
542+
zipArchiveOutputStream = new ZipArchiveOutputStream( bufferedOutputStream( fileOutputStream( getDestFile(), "jar" ) ));
542543

543-
zOut.setEncoding( getEncoding() );
544+
zipArchiveOutputStream.setEncoding(getEncoding());
544545
if ( isCompress() )
545546
{
546-
zOut.setMethod( ZipArchiveOutputStream.DEFLATED );
547+
zipArchiveOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED);
547548
}
548549
else
549550
{
550-
zOut.setMethod( ZipArchiveOutputStream.STORED );
551+
zipArchiveOutputStream.setMethod(ZipArchiveOutputStream.STORED);
551552
}
552-
initZipOutputStream( zOut );
553-
finalizeZipOutputStream( zOut );
553+
ParallelScatterZipCreator ps = new ParallelScatterZipCreator();
554+
initZipOutputStream( ps );
555+
finalizeZipOutputStream( ps );
554556
}
555557
catch ( IOException ioe )
556558
{
@@ -559,7 +561,7 @@ protected boolean createEmptyZip( File zipFile )
559561
finally
560562
{
561563
// Close the output stream.
562-
IOUtil.close( zOut );
564+
//IOUtil.close( zOut );
563565
createEmpty = false;
564566
}
565567
return true;

Diff for: src/main/java/org/codehaus/plexus/archiver/war/WarArchiver.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
20+
import org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator;
2121
import org.codehaus.plexus.archiver.ArchiveEntry;
2222
import org.codehaus.plexus.archiver.ArchiverException;
2323
import org.codehaus.plexus.archiver.jar.JarArchiver;
@@ -152,8 +152,9 @@ public void addWebinf( File directoryName, String[] includes, String[] excludes
152152
/**
153153
* override of parent; validates configuration
154154
* before initializing the output stream.
155+
* @param zOut
155156
*/
156-
protected void initZipOutputStream( ZipArchiveOutputStream zOut )
157+
protected void initZipOutputStream( ParallelScatterZipCreator zOut )
157158
throws ArchiverException, IOException
158159
{
159160
// If no webxml file is specified, it's an error.
@@ -167,7 +168,7 @@ protected void initZipOutputStream( ZipArchiveOutputStream zOut )
167168
/**
168169
* Overridden from ZipArchiver class to deal with web.xml
169170
*/
170-
protected void zipFile( ArchiveEntry entry, ZipArchiveOutputStream zOut, String vPath )
171+
protected void zipFile( ArchiveEntry entry, ParallelScatterZipCreator zOut, String vPath )
171172
throws IOException, ArchiverException
172173
{
173174
// If the file being added is WEB-INF/web.xml, we warn if it's

0 commit comments

Comments
 (0)