mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FEATURE] CompressBuildTask сжатие JAR
This commit is contained in:
parent
65d5608efd
commit
9da5191738
3 changed files with 47 additions and 6 deletions
|
@ -275,6 +275,7 @@ public static class NettyUpdatesBind {
|
||||||
public class LauncherConf {
|
public class LauncherConf {
|
||||||
public String guardType;
|
public String guardType;
|
||||||
public boolean attachLibraryBeforeProGuard;
|
public boolean attachLibraryBeforeProGuard;
|
||||||
|
public boolean compress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NettyConfig {
|
public class NettyConfig {
|
||||||
|
@ -810,6 +811,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
|
||||||
|
|
||||||
newConfig.launcher = new LauncherConf();
|
newConfig.launcher = new LauncherConf();
|
||||||
newConfig.launcher.guardType = "no";
|
newConfig.launcher.guardType = "no";
|
||||||
|
newConfig.launcher.compress = true;
|
||||||
|
|
||||||
newConfig.genMappings = true;
|
newConfig.genMappings = true;
|
||||||
newConfig.enabledProGuard = true;
|
newConfig.enabledProGuard = true;
|
||||||
|
|
|
@ -9,12 +9,7 @@
|
||||||
|
|
||||||
import pro.gravit.launcher.Launcher;
|
import pro.gravit.launcher.Launcher;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.binary.tasks.AdditionalFixesApplyTask;
|
import pro.gravit.launchserver.binary.tasks.*;
|
||||||
import pro.gravit.launchserver.binary.tasks.AttachJarsTask;
|
|
||||||
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
|
||||||
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
|
|
||||||
import pro.gravit.launchserver.binary.tasks.PrepareBuildTask;
|
|
||||||
import pro.gravit.launchserver.binary.tasks.ProGuardBuildTask;
|
|
||||||
import pro.gravit.utils.helper.CommonHelper;
|
import pro.gravit.utils.helper.CommonHelper;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
@ -51,6 +46,7 @@ public void init() {
|
||||||
tasks.add(new ProGuardBuildTask(server));
|
tasks.add(new ProGuardBuildTask(server));
|
||||||
tasks.add(new AdditionalFixesApplyTask(server));
|
tasks.add(new AdditionalFixesApplyTask(server));
|
||||||
if (!server.config.launcher.attachLibraryBeforeProGuard) tasks.add(new AttachJarsTask(server));
|
if (!server.config.launcher.attachLibraryBeforeProGuard) tasks.add(new AttachJarsTask(server));
|
||||||
|
if(server.config.launcher.compress) tasks.add(new CompressBuildTask(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package pro.gravit.launchserver.binary.tasks;
|
||||||
|
|
||||||
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.zip.Deflater;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
public class CompressBuildTask implements LauncherBuildTask {
|
||||||
|
public transient final LaunchServer server;
|
||||||
|
|
||||||
|
public CompressBuildTask(LaunchServer server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "compress";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path process(Path inputFile) throws IOException {
|
||||||
|
Path output = server.launcherBinary.nextPath(this);
|
||||||
|
try(ZipOutputStream outputStream = new ZipOutputStream(IOHelper.newOutput(output)))
|
||||||
|
{
|
||||||
|
outputStream.setMethod(ZipOutputStream.DEFLATED);
|
||||||
|
outputStream.setLevel(Deflater.BEST_COMPRESSION);
|
||||||
|
try(ZipInputStream inputStream = IOHelper.newZipInput(inputFile))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean allowDelete() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue