mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-03 23:11:57 +03:00
Small fix.
This commit is contained in:
parent
05a3b2ba1f
commit
a76a566a37
2 changed files with 23 additions and 24 deletions
|
@ -99,7 +99,8 @@ public ArrayList<String> getSuperClasses(String type) {
|
|||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
cp.stream().forEach(IOHelper::close);
|
||||
cp.stream().forEach(IOHelper::close);
|
||||
cp.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,13 +17,10 @@
|
|||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
public class StripLineNumbersTask implements LauncherBuildTask {
|
||||
|
||||
private final LaunchServer server;
|
||||
private final ClassMetadataReader reader;
|
||||
|
||||
public StripLineNumbersTask(LaunchServer server) {
|
||||
this.server = server;
|
||||
reader = new ClassMetadataReader();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,26 +31,27 @@ public String getName() {
|
|||
@Override
|
||||
public Path process(Path inputFile) throws IOException {
|
||||
Path out = server.dir.resolve(server.config.projectName + "-stripped.jar");
|
||||
reader.getCp().add(new JarFile(inputFile.toFile()));
|
||||
try (ZipInputStream input = IOHelper.newZipInput(inputFile);
|
||||
ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) {
|
||||
ZipEntry e = input.getNextEntry();
|
||||
while (e != null) {
|
||||
String filename = e.getName();
|
||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||
if (filename.endsWith(".class")) {
|
||||
byte[] bytes = null;
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) {
|
||||
IOHelper.transfer(input, outputStream);
|
||||
bytes = outputStream.toByteArray();
|
||||
}
|
||||
output.write(classFix(bytes, reader));
|
||||
} else
|
||||
IOHelper.transfer(input, output);
|
||||
e = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
try (ClassMetadataReader reader = new ClassMetadataReader()) {
|
||||
reader.getCp().add(new JarFile(inputFile.toFile()));
|
||||
try (ZipInputStream input = IOHelper.newZipInput(inputFile);
|
||||
ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) {
|
||||
ZipEntry e = input.getNextEntry();
|
||||
while (e != null) {
|
||||
String filename = e.getName();
|
||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||
if (filename.endsWith(".class")) {
|
||||
byte[] bytes = null;
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048)) {
|
||||
IOHelper.transfer(input, outputStream);
|
||||
bytes = outputStream.toByteArray();
|
||||
}
|
||||
output.write(classFix(bytes, reader));
|
||||
} else
|
||||
IOHelper.transfer(input, output);
|
||||
e = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue