17
17
* limitations under the License.
18
18
*/
19
19
20
+ import org .apache .commons .compress .archivers .zip .ParallelScatterZipCreator ;
20
21
import org .apache .commons .compress .archivers .zip .ZipArchiveEntry ;
21
22
import org .apache .commons .compress .archivers .zip .ZipArchiveOutputStream ;
22
23
import org .codehaus .plexus .archiver .ArchiverException ;
25
26
import org .codehaus .plexus .logging .console .ConsoleLogger ;
26
27
import org .codehaus .plexus .util .IOUtil ;
27
28
29
+ import javax .annotation .WillClose ;
28
30
import java .io .ByteArrayInputStream ;
29
31
import java .io .ByteArrayOutputStream ;
30
32
import java .io .File ;
@@ -284,7 +286,7 @@ public void addConfiguredIndexJars( File indexJar )
284
286
indexJars .add ( indexJar .getAbsolutePath () );
285
287
}
286
288
287
- protected void initZipOutputStream ( ZipArchiveOutputStream zOut )
289
+ protected void initZipOutputStream ( ParallelScatterZipCreator zOut )
288
290
throws ArchiverException , IOException
289
291
{
290
292
if ( !skipWriting )
@@ -334,15 +336,15 @@ private Manifest createManifest()
334
336
return finalManifest ;
335
337
}
336
338
337
- private void writeManifest ( ZipArchiveOutputStream zOut , Manifest manifest )
339
+ private void writeManifest ( ParallelScatterZipCreator zOut , Manifest manifest )
338
340
throws IOException , ArchiverException
339
341
{
340
342
for ( Enumeration e = manifest .getWarnings (); e .hasMoreElements (); )
341
343
{
342
344
getLogger ().warn ( "Manifest warning: " + e .nextElement () );
343
345
}
344
346
345
- zipDir ( null , zOut , "META-INF/" , DEFAULT_DIR_MODE );
347
+ zipDir ( null , zOut , "META-INF/" , DEFAULT_DIR_MODE , getEncoding () );
346
348
// time to write the manifest
347
349
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
348
350
manifest .write ( baos );
@@ -352,7 +354,7 @@ private void writeManifest( ZipArchiveOutputStream zOut, Manifest manifest )
352
354
super .initZipOutputStream ( zOut );
353
355
}
354
356
355
- protected void finalizeZipOutputStream ( ZipArchiveOutputStream zOut )
357
+ protected void finalizeZipOutputStream ( ParallelScatterZipCreator zOut )
356
358
throws IOException , ArchiverException
357
359
{
358
360
if ( index )
@@ -373,7 +375,7 @@ protected void finalizeZipOutputStream( ZipArchiveOutputStream zOut )
373
375
* @throws org.codehaus.plexus.archiver.ArchiverException
374
376
* .
375
377
*/
376
- private void createIndexList ( ZipArchiveOutputStream zOut )
378
+ private void createIndexList ( ParallelScatterZipCreator zOut )
377
379
throws IOException , ArchiverException
378
380
{
379
381
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
@@ -455,7 +457,7 @@ private void createIndexList( ZipArchiveOutputStream zOut )
455
457
/**
456
458
* Overridden from Zip class to deal with manifests and index lists.
457
459
*/
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 ,
459
461
int mode , String symlinkDestination )
460
462
throws IOException , ArchiverException
461
463
{
@@ -534,23 +536,23 @@ protected boolean createEmptyZip( File zipFile )
534
536
return true ;
535
537
}
536
538
537
- ZipArchiveOutputStream zOut = null ;
538
539
try
539
540
{
540
541
getLogger ().debug ( "Building MANIFEST-only jar: " + getDestFile ().getAbsolutePath () );
541
- zOut = new ZipArchiveOutputStream ( bufferedOutputStream ( fileOutputStream ( getDestFile (), "jar" ) ));
542
+ zipArchiveOutputStream = new ZipArchiveOutputStream ( bufferedOutputStream ( fileOutputStream ( getDestFile (), "jar" ) ));
542
543
543
- zOut .setEncoding ( getEncoding () );
544
+ zipArchiveOutputStream .setEncoding (getEncoding ());
544
545
if ( isCompress () )
545
546
{
546
- zOut .setMethod ( ZipArchiveOutputStream .DEFLATED );
547
+ zipArchiveOutputStream .setMethod (ZipArchiveOutputStream .DEFLATED );
547
548
}
548
549
else
549
550
{
550
- zOut .setMethod ( ZipArchiveOutputStream .STORED );
551
+ zipArchiveOutputStream .setMethod (ZipArchiveOutputStream .STORED );
551
552
}
552
- initZipOutputStream ( zOut );
553
- finalizeZipOutputStream ( zOut );
553
+ ParallelScatterZipCreator ps = new ParallelScatterZipCreator ();
554
+ initZipOutputStream ( ps );
555
+ finalizeZipOutputStream ( ps );
554
556
}
555
557
catch ( IOException ioe )
556
558
{
@@ -559,7 +561,7 @@ protected boolean createEmptyZip( File zipFile )
559
561
finally
560
562
{
561
563
// Close the output stream.
562
- IOUtil .close ( zOut );
564
+ // IOUtil.close( zOut );
563
565
createEmpty = false ;
564
566
}
565
567
return true ;
0 commit comments