|
@@ -392,10 +392,20 @@ |
392 |
392 |
|
*/ |
393 |
393 |
|
public String jar( String jarFile, Paths paths ) |
394 |
394 |
|
{ |
|
395 |
+ |
return innerJar( "", jarFile, paths ); |
|
396 |
+ |
} |
|
397 |
+ |
|
|
398 |
+ |
/** |
|
399 |
+ |
* Encodes the specified paths into a JAR file. |
|
400 |
+ |
* |
|
401 |
+ |
* @return The path to the JAR file. |
|
402 |
+ |
*/ |
|
403 |
+ |
protected String innerJar( String pTypePrefix, String jarFile, Paths paths ) |
|
404 |
+ |
{ |
395 |
405 |
|
Util.assertNotNull( "jarFile", jarFile ); |
396 |
406 |
|
Util.assertNotNull( "paths", paths ); |
397 |
407 |
|
|
398 |
|
- |
progress( "Creating JAR (" + paths.count() + " entries): " + jarFile ); |
|
408 |
+ |
progress( "Creating " + pTypePrefix + "JAR (" + paths.count() + " entries): " + jarFile ); |
399 |
409 |
|
|
400 |
410 |
|
int zZipped = paths.zip( jarFile, new ZipFactory() |
401 |
411 |
|
{ |
|
@@ -487,33 +497,19 @@ |
487 |
497 |
|
} |
488 |
498 |
|
progress( "One JAR: " + this ); |
489 |
499 |
|
|
490 |
|
- |
String onejarDir = mkdir( path( "$target$/onejar/" ) ); |
|
500 |
+ |
File zOnejarDir = mkdir( new File( path( "$target$/onejar/" ) ) ); |
491 |
501 |
|
|
492 |
502 |
|
List<String> zExcludeJARs = Arrays.asList( pExcludeJARs ); |
493 |
|
- |
for ( File jarFile : zClasspath.getFiles() ) |
|
503 |
+ |
for ( File jarFile : zClasspath.getFiles() ) // All our Class Path (dependant) JARS |
494 |
504 |
|
{ |
495 |
|
- |
if ( !zExcludeJARs.contains( jarFile ) ) |
|
505 |
+ |
if ( !zExcludeJARs.contains( jarFile.getName() ) ) |
496 |
506 |
|
{ |
497 |
|
- |
unzip( jarFile, onejarDir ); |
|
507 |
+ |
unzip( jarFile, zOnejarDir ); |
498 |
508 |
|
} |
499 |
509 |
|
} |
500 |
510 |
|
|
501 |
|
- |
|
502 |
|
- |
|
503 |
|
- |
ArrayList<String> processedJARs = new ArrayList(); |
504 |
|
- |
outer: |
505 |
|
- |
unzip( distDir + projectJarName, onejarDir ); |
506 |
|
- |
|
507 |
|
- |
String onejarFile; |
508 |
|
- |
if ( hasVersion() ) |
509 |
|
- |
{ |
510 |
|
- |
onejarFile = path( "$target$/dist/onejar/$name$-$version$-all.jar" ); |
511 |
|
- |
} |
512 |
|
- |
else |
513 |
|
- |
{ |
514 |
|
- |
onejarFile = path( "$target$/dist/onejar/$name$-all.jar" ); |
515 |
|
- |
} |
516 |
|
- |
return jar( onejarFile, new Paths( onejarDir ) ); |
|
511 |
+ |
unzip( zJarPath, zOnejarDir ); // Our Jar! - Our Manifest will be "the" Manifest |
|
512 |
+ |
return innerJar( "'ONE' ", zOneJarPath.getPath(), new Paths( zOnejarDir.getPath() ) ); |
517 |
513 |
|
} |
518 |
514 |
|
|
519 |
515 |
|
/** |
|
@@ -521,81 +517,54 @@ |
521 |
517 |
|
* |
522 |
518 |
|
* @return The path to the output directory. |
523 |
519 |
|
*/ |
524 |
|
- |
public String unzip( String zipFile, String outputDir ) |
|
520 |
+ |
protected void quiteUnzip( File zipFile, File outputDir ) |
525 |
521 |
|
{ |
526 |
|
- |
Util.assertNotNull( "zipFile", zipFile ); |
527 |
|
- |
Util.assertNotNull( "outputDir", outputDir ); |
528 |
|
- |
progress( "ZIP decoding: " + zipFile + " -> " + outputDir ); |
529 |
|
- |
|
530 |
|
- |
ZipInputStream input; |
|
522 |
+ |
ZipInputStream input = new ZipInputStream( createFileInputStream( zipFile ) ); |
531 |
523 |
|
try |
532 |
524 |
|
{ |
533 |
|
- |
input = new ZipInputStream( new FileInputStream( zipFile ) ); |
534 |
|
- |
} |
535 |
|
- |
catch ( FileNotFoundException e ) |
536 |
|
- |
{ |
537 |
|
- |
throw new WrappedIOException( e ); |
538 |
|
- |
} |
539 |
|
- |
try |
540 |
|
- |
{ |
541 |
|
- |
while ( true ) |
|
525 |
+ |
for ( ZipEntry entry; null != (entry = input.getNextEntry()); ) |
542 |
526 |
|
{ |
543 |
|
- |
ZipEntry entry; |
544 |
|
- |
try |
545 |
|
- |
{ |
546 |
|
- |
entry = input.getNextEntry(); |
547 |
|
- |
} |
548 |
|
- |
catch ( IOException e ) |
549 |
|
- |
{ |
550 |
|
- |
throw new WrappedIOException( e ); |
551 |
|
- |
} |
552 |
|
- |
if ( entry == null ) |
553 |
|
- |
{ |
554 |
|
- |
break; |
555 |
|
- |
} |
556 |
527 |
|
File file = new File( outputDir, entry.getName() ); |
557 |
528 |
|
if ( entry.isDirectory() ) |
558 |
529 |
|
{ |
559 |
530 |
|
mkdir( file.getPath() ); |
560 |
531 |
|
continue; |
561 |
532 |
|
} |
562 |
|
- |
mkdir( file.getParent() ); |
563 |
|
- |
FileOutputStream output; |
564 |
|
- |
try |
565 |
|
- |
{ |
566 |
|
- |
output = new FileOutputStream( file ); |
567 |
|
- |
} |
568 |
|
- |
catch ( FileNotFoundException e ) |
569 |
|
- |
{ |
570 |
|
- |
throw new WrappedIOException( e ); |
571 |
|
- |
} |
572 |
|
- |
try |
573 |
|
- |
{ |
574 |
|
- |
byte[] buffer = new byte[4096]; |
575 |
|
- |
while ( true ) |
576 |
|
- |
{ |
577 |
|
- |
int length = input.read( buffer ); |
578 |
|
- |
if ( length == -1 ) |
579 |
|
- |
{ |
580 |
|
- |
break; |
581 |
|
- |
} |
582 |
|
- |
output.write( buffer, 0, length ); |
583 |
|
- |
} |
584 |
|
- |
} |
585 |
|
- |
catch ( IOException e ) |
586 |
|
- |
{ |
587 |
|
- |
throw new WrappedIOException( e ); |
588 |
|
- |
} |
589 |
|
- |
finally |
590 |
|
- |
{ |
591 |
|
- |
dispose( output ); |
592 |
|
- |
} |
|
533 |
+ |
writeStream( input, createFileOutputStream( file ) ); |
593 |
534 |
|
} |
594 |
535 |
|
} |
|
536 |
+ |
catch ( IOException e ) |
|
537 |
+ |
{ |
|
538 |
+ |
throw new WrappedIOException( e ); |
|
539 |
+ |
} |
595 |
540 |
|
finally |
596 |
541 |
|
{ |
597 |
542 |
|
dispose( input ); |
598 |
543 |
|
} |
|
544 |
+ |
} |
|
545 |
+ |
|
|
546 |
+ |
/** |
|
547 |
+ |
* Decodes the specified ZIP file. |
|
548 |
+ |
*/ |
|
549 |
+ |
public void unzip( File zipFile, File outputDir ) |
|
550 |
+ |
{ |
|
551 |
+ |
Util.assertNotNull( "zipFile", zipFile ); |
|
552 |
+ |
Util.assertNotNull( "outputDir", outputDir ); |
|
553 |
+ |
progress( "ZIP decoding: " + zipFile.getPath() + " -> " + outputDir.getPath() ); |
|
554 |
+ |
quiteUnzip( zipFile, outputDir ); |
|
555 |
+ |
} |
|
556 |
+ |
|
|
557 |
+ |
/** |
|
558 |
+ |
* Decodes the specified ZIP file. |
|
559 |
+ |
* |
|
560 |
+ |
* @return The path to the output directory. |
|
561 |
+ |
*/ |
|
562 |
+ |
public String unzip( String zipFile, String outputDir ) |
|
563 |
+ |
{ |
|
564 |
+ |
zipFile = assertNotEmpty( "zipFile", zipFile ); |
|
565 |
+ |
outputDir = assertNotEmpty( "outputDir", outputDir ); |
|
566 |
+ |
progress( "ZIP decoding: " + zipFile + " -> " + outputDir ); |
|
567 |
+ |
quiteUnzip( new File( zipFile ), new File( outputDir ) ); |
599 |
568 |
|
return outputDir; |
600 |
569 |
|
} |
601 |
570 |
|
|