|
1 | 1 | package net.neoforged.nfrtgradle; |
2 | 2 |
|
3 | | -import org.gradle.api.DefaultTask; |
4 | | -import org.gradle.api.file.RegularFileProperty; |
5 | | -import org.gradle.api.tasks.InputFile; |
6 | | -import org.gradle.api.tasks.Optional; |
7 | | -import org.gradle.api.tasks.OutputFile; |
8 | | -import org.gradle.api.tasks.TaskAction; |
9 | | -import org.jetbrains.annotations.Nullable; |
10 | | - |
11 | | -import javax.inject.Inject; |
12 | 3 | import java.io.BufferedInputStream; |
13 | 4 | import java.io.BufferedOutputStream; |
14 | 5 | import java.io.IOException; |
|
17 | 8 | import java.util.jar.JarFile; |
18 | 9 | import java.util.zip.ZipInputStream; |
19 | 10 | import java.util.zip.ZipOutputStream; |
| 11 | +import javax.inject.Inject; |
| 12 | +import org.gradle.api.DefaultTask; |
| 13 | +import org.gradle.api.file.RegularFileProperty; |
| 14 | +import org.gradle.api.tasks.InputFile; |
| 15 | +import org.gradle.api.tasks.Optional; |
| 16 | +import org.gradle.api.tasks.OutputFile; |
| 17 | +import org.gradle.api.tasks.TaskAction; |
| 18 | +import org.jetbrains.annotations.Nullable; |
20 | 19 |
|
21 | 20 | public abstract class SplitMergedJar extends DefaultTask { |
22 | 21 | @Inject |
@@ -48,32 +47,27 @@ public void splitMergedJar() throws IOException { |
48 | 47 | var clientResources = new JarFile(getClientResourcesJar().get().getAsFile()); |
49 | 48 | var merged = new ZipInputStream(new BufferedInputStream(Files.newInputStream(getMergedJar().get().getAsFile().toPath()))); |
50 | 49 | var common = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(getCommonJar().get().getAsFile().toPath()))); |
51 | | - var client = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(getClientJar().get().getAsFile().toPath()))) |
52 | | - ) { |
| 50 | + var client = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(getClientJar().get().getAsFile().toPath())))) { |
53 | 51 |
|
54 | 52 | var manifest = clientResources.getManifest(); |
55 | 53 |
|
56 | 54 | if (getCommonSourcesJar().isPresent() && getClientSourcesJar().isPresent()) { |
57 | 55 | try ( |
58 | 56 | var commonSources = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(getCommonSourcesJar().get().getAsFile().toPath()))); |
59 | | - var clientSources = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(getClientSourcesJar().get().getAsFile().toPath()))) |
60 | | - ) { |
| 57 | + var clientSources = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(getClientSourcesJar().get().getAsFile().toPath())))) { |
61 | 58 | spiltHelper(manifest, merged, common, client, commonSources, clientSources); |
62 | 59 | } |
63 | 60 | } else { |
64 | 61 | spiltHelper(manifest, merged, common, client, null, null); |
65 | 62 | } |
66 | 63 |
|
67 | | - |
68 | 64 | } |
69 | | - |
70 | 65 | } |
71 | 66 |
|
72 | 67 | private static void spiltHelper( |
73 | 68 | java.util.jar.Manifest manifest, |
74 | 69 | ZipInputStream merged, ZipOutputStream common, ZipOutputStream client, |
75 | | - @Nullable ZipOutputStream commonSources, @Nullable ZipOutputStream clientSources |
76 | | - ) throws IOException { |
| 70 | + @Nullable ZipOutputStream commonSources, @Nullable ZipOutputStream clientSources) throws IOException { |
77 | 71 | var sourceDistName = new Attributes.Name("Minecraft-Dist"); |
78 | 72 | for (var entry = merged.getNextEntry(); entry != null; entry = merged.getNextEntry()) { |
79 | 73 | if (entry.isDirectory()) { |
@@ -112,5 +106,4 @@ private static void spiltHelper( |
112 | 106 | } |
113 | 107 | } |
114 | 108 | } |
115 | | - |
116 | 109 | } |
0 commit comments