mirror of
https://github.com/SKCraft/Launcher.git
synced 2025-01-23 21:51:26 +01:00
Added ServerCopyExport tool.
This commit is contained in:
parent
3c694d14ab
commit
73575a2325
@ -12,7 +12,7 @@ import lombok.Data;
|
||||
import java.io.File;
|
||||
|
||||
@Data
|
||||
public class PackageOptions {
|
||||
public class BuilderOptions {
|
||||
|
||||
// Configuration
|
||||
@Parameter(names = "--config")
|
@ -98,8 +98,8 @@ public class PackageBuilder {
|
||||
writer.writeValue(path, manifest);
|
||||
}
|
||||
|
||||
private static PackageOptions parseArgs(String[] args) {
|
||||
PackageOptions options = new PackageOptions();
|
||||
private static BuilderOptions parseArgs(String[] args) {
|
||||
BuilderOptions options = new BuilderOptions();
|
||||
new JCommander(options, args);
|
||||
return options;
|
||||
}
|
||||
@ -125,7 +125,7 @@ public class PackageBuilder {
|
||||
* @throws IOException thrown on I/O error
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
PackageOptions options = parseArgs(args);
|
||||
BuilderOptions options = parseArgs(args);
|
||||
|
||||
// Initialize
|
||||
SimpleLogFormatter.configureGlobalLogger();
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* SK's Minecraft Launcher
|
||||
* Copyright (C) 2010-2014 Albert Pham <http://www.sk89q.com> and contributors
|
||||
* Please see LICENSE.txt for license information.
|
||||
*/
|
||||
|
||||
package com.skcraft.launcher.builder;
|
||||
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.google.common.io.Files;
|
||||
import com.skcraft.launcher.util.SimpleLogFormatter;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.java.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@Log
|
||||
public class ServerCopyExport extends DirectoryWalker {
|
||||
|
||||
private final File destDir;
|
||||
|
||||
public ServerCopyExport(@NonNull File destDir) {
|
||||
this.destDir = destDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DirectoryBehavior getBehavior(String name) {
|
||||
if (name.equals("_SERVER")) {
|
||||
return DirectoryBehavior.IGNORE;
|
||||
} else if (name.equals("_CLIENT")) {
|
||||
return DirectoryBehavior.SKIP;
|
||||
} else {
|
||||
return DirectoryBehavior.CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFile(File file, String relPath) throws IOException {
|
||||
File dest = new File(destDir, relPath);
|
||||
|
||||
log.info("Copying " + file.getAbsolutePath() + " to " + dest.getAbsolutePath());
|
||||
dest.getParentFile().mkdirs();
|
||||
Files.copy(file, dest);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
SimpleLogFormatter.configureGlobalLogger();
|
||||
|
||||
ServerExportOptions options = new ServerExportOptions();
|
||||
new JCommander(options, args);
|
||||
|
||||
log.info("From: " + options.getSourceDir().getAbsolutePath());
|
||||
log.info("To: " + options.getDestDir().getAbsolutePath());
|
||||
ServerCopyExport task = new ServerCopyExport(options.getDestDir());
|
||||
task.walk(options.getSourceDir());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* SK's Minecraft Launcher
|
||||
* Copyright (C) 2010-2014 Albert Pham <http://www.sk89q.com> and contributors
|
||||
* Please see LICENSE.txt for license information.
|
||||
*/
|
||||
|
||||
package com.skcraft.launcher.builder;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Data
|
||||
public class ServerExportOptions {
|
||||
|
||||
@Parameter(names = "--source", required = true)
|
||||
private File sourceDir;
|
||||
@Parameter(names = "--dest", required = true)
|
||||
private File destDir;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user