35
35
public class ConcurrentJarCreator {
36
36
37
37
private final ScatterZipOutputStream directories ;
38
+ private final ScatterZipOutputStream metaInfDir ;
38
39
private final ScatterZipOutputStream manifest ;
39
40
40
41
private final ParallelScatterZipCreator parallelScatterZipCreator ;
@@ -59,6 +60,7 @@ public ConcurrentJarCreator(int nThreads) throws IOException {
59
60
60
61
directories = createDeferred (defaultSupplier );
61
62
manifest = createDeferred (defaultSupplier );
63
+ metaInfDir = createDeferred ( defaultSupplier );
62
64
63
65
parallelScatterZipCreator = new ParallelScatterZipCreator (Executors .newFixedThreadPool (nThreads ), defaultSupplier );
64
66
}
@@ -80,7 +82,13 @@ public void addArchiveEntry(final ZipArchiveEntry zipArchiveEntry, final InputSt
80
82
final ByteArrayInputStream payload = new ByteArrayInputStream (new byte []{});
81
83
directories .addArchiveEntry (createZipArchiveEntryRequest (zipArchiveEntry , createInputStreamSupplier (payload )));
82
84
payload .close ();
83
- } else if ("META-INF" .equals (zipArchiveEntry .getName ()) || "META-INF/MANIFEST.MF" .equals (zipArchiveEntry .getName ())) {
85
+ } else if ("META-INF" .equals (zipArchiveEntry .getName ())) {
86
+ InputStream payload = source .get ();
87
+ if (zipArchiveEntry .isDirectory ()) zipArchiveEntry .setMethod (ZipEntry .STORED );
88
+ metaInfDir .addArchiveEntry (
89
+ createZipArchiveEntryRequest ( zipArchiveEntry , createInputStreamSupplier ( payload ) ) );
90
+ payload .close ();
91
+ } else if ("META-INF/MANIFEST.MF" .equals (zipArchiveEntry .getName ())) {
84
92
InputStream payload = source .get ();
85
93
if (zipArchiveEntry .isDirectory ()) zipArchiveEntry .setMethod (ZipEntry .STORED );
86
94
manifest .addArchiveEntry (createZipArchiveEntryRequest (zipArchiveEntry , createInputStreamSupplier (payload )));
@@ -99,6 +107,7 @@ public InputStream get() {
99
107
}
100
108
101
109
public void writeTo (ZipArchiveOutputStream targetStream ) throws IOException , ExecutionException , InterruptedException {
110
+ metaInfDir .writeTo ( targetStream );
102
111
manifest .writeTo (targetStream );
103
112
directories .writeTo (targetStream );
104
113
parallelScatterZipCreator .writeTo ( targetStream );
0 commit comments