|
@@ -24,7 +24,6 @@ import org.eclipse.jgit.api.Git;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import com.l2jserver.cli.L2JServerCLI;
|
|
|
|
import com.l2jserver.cli.model.CloneType;
|
|
import com.l2jserver.cli.model.CloneType;
|
|
import com.l2jserver.cli.util.LoggerProgressMonitor;
|
|
import com.l2jserver.cli.util.LoggerProgressMonitor;
|
|
|
|
|
|
@@ -38,81 +37,77 @@ import picocli.CommandLine.Option;
|
|
*/
|
|
*/
|
|
@Command(name = "code", aliases = "c")
|
|
@Command(name = "code", aliases = "c")
|
|
public class CodeCommand extends AbstractCommand {
|
|
public class CodeCommand extends AbstractCommand {
|
|
-
|
|
|
|
|
|
+
|
|
private static final Logger LOG = LoggerFactory.getLogger(CodeCommand.class);
|
|
private static final Logger LOG = LoggerFactory.getLogger(CodeCommand.class);
|
|
-
|
|
|
|
|
|
+
|
|
private static final LoggerProgressMonitor LOGGER_PROGRESS_MONITOR = new LoggerProgressMonitor(LOG);
|
|
private static final LoggerProgressMonitor LOGGER_PROGRESS_MONITOR = new LoggerProgressMonitor(LOG);
|
|
-
|
|
|
|
- private static final String DEFAULT_LOGIN_REPO = "https://bitbucket.org/l2jserver/l2j-server-login.git";
|
|
|
|
- private static final String DEFAULT_GAME_REPO = "https://bitbucket.org/l2jserver/l2j-server-game.git";
|
|
|
|
- private static final String DEFAULT_DATAPACK_REPO = "https://bitbucket.org/l2jserver/l2j-server-datapack.git";
|
|
|
|
-
|
|
|
|
|
|
+
|
|
@Option(names = "--login-repository", defaultValue = DEFAULT_LOGIN_REPO, description = "Login repository")
|
|
@Option(names = "--login-repository", defaultValue = DEFAULT_LOGIN_REPO, description = "Login repository")
|
|
private String loginRepository = DEFAULT_LOGIN_REPO;
|
|
private String loginRepository = DEFAULT_LOGIN_REPO;
|
|
@Option(names = "--game-repository", defaultValue = DEFAULT_GAME_REPO, description = "Game repository")
|
|
@Option(names = "--game-repository", defaultValue = DEFAULT_GAME_REPO, description = "Game repository")
|
|
private String gameRepository = DEFAULT_GAME_REPO;
|
|
private String gameRepository = DEFAULT_GAME_REPO;
|
|
@Option(names = "--datapack-repository", defaultValue = DEFAULT_DATAPACK_REPO, description = "Datapack repository")
|
|
@Option(names = "--datapack-repository", defaultValue = DEFAULT_DATAPACK_REPO, description = "Datapack repository")
|
|
private String datapackRepository = DEFAULT_DATAPACK_REPO;
|
|
private String datapackRepository = DEFAULT_DATAPACK_REPO;
|
|
-
|
|
|
|
- @Option(names = "--login-directory", defaultValue = L2JServerCLI.DEFAULT_LOGIN_SOURCE_DIR, description = "Login directory")
|
|
|
|
- private File loginDirectory = new File(L2JServerCLI.DEFAULT_LOGIN_SOURCE_DIR);
|
|
|
|
- @Option(names = "--game-directory", defaultValue = L2JServerCLI.DEFAULT_GAME_SOURCE_DIR, description = "Game directory")
|
|
|
|
- private File gameDirectory = new File(L2JServerCLI.DEFAULT_GAME_SOURCE_DIR);
|
|
|
|
- @Option(names = "--datapack-directory", defaultValue = L2JServerCLI.DEFAULT_DATAPACK_SOURCE_DIR, description = "DataPack directory")
|
|
|
|
- private File datapackDirectory = new File(L2JServerCLI.DEFAULT_DATAPACK_SOURCE_DIR);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ @Option(names = "--login-directory", defaultValue = DEFAULT_LOGIN_SOURCE_DIR, description = "Login directory")
|
|
|
|
+ private File loginDirectory = new File(DEFAULT_LOGIN_SOURCE_DIR);
|
|
|
|
+ @Option(names = "--game-directory", defaultValue = DEFAULT_GAME_SOURCE_DIR, description = "Game directory")
|
|
|
|
+ private File gameDirectory = new File(DEFAULT_GAME_SOURCE_DIR);
|
|
|
|
+ @Option(names = "--datapack-directory", defaultValue = DEFAULT_DATAPACK_SOURCE_DIR, description = "DataPack directory")
|
|
|
|
+ private File datapackDirectory = new File(DEFAULT_DATAPACK_SOURCE_DIR);
|
|
|
|
+
|
|
@Option(names = "--clone", defaultValue = "ALL", description = "Clone ALL|LOGIN|GAME|DATAPACK")
|
|
@Option(names = "--clone", defaultValue = "ALL", description = "Clone ALL|LOGIN|GAME|DATAPACK")
|
|
private CloneType cloneType = CloneType.ALL;
|
|
private CloneType cloneType = CloneType.ALL;
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
try {
|
|
switch (cloneType) {
|
|
switch (cloneType) {
|
|
- case ALL: {
|
|
|
|
- LOG.info("Cloning L2J Loginserver");
|
|
|
|
- cloneRepository(loginRepository, loginDirectory);
|
|
|
|
|
|
+ case ALL: {
|
|
|
|
+ LOG.info("Cloning L2J Loginserver");
|
|
|
|
+ cloneRepository(loginRepository, loginDirectory);
|
|
|
|
|
|
- LOG.info("Cloning L2J Gameserver");
|
|
|
|
- cloneRepository(gameRepository, gameDirectory);
|
|
|
|
-
|
|
|
|
- LOG.info("Cloning L2J DataPack");
|
|
|
|
- cloneRepository(datapackRepository, datapackDirectory);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- case LOGIN: {
|
|
|
|
- LOG.info("Cloning L2J Loginserver");
|
|
|
|
- cloneRepository(loginRepository, loginDirectory);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- case GAME: {
|
|
|
|
- LOG.info("Cloning L2J Gameserver");
|
|
|
|
- cloneRepository(gameRepository, gameDirectory);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- case DATAPACK: {
|
|
|
|
- LOG.info("Cloning L2J DataPack");
|
|
|
|
- cloneRepository(datapackRepository, datapackDirectory);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ LOG.info("Cloning L2J Gameserver");
|
|
|
|
+ cloneRepository(gameRepository, gameDirectory);
|
|
|
|
+
|
|
|
|
+ LOG.info("Cloning L2J DataPack");
|
|
|
|
+ cloneRepository(datapackRepository, datapackDirectory);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ case LOGIN: {
|
|
|
|
+ LOG.info("Cloning L2J Loginserver");
|
|
|
|
+ cloneRepository(loginRepository, loginDirectory);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ case GAME: {
|
|
|
|
+ LOG.info("Cloning L2J Gameserver");
|
|
|
|
+ cloneRepository(gameRepository, gameDirectory);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ case DATAPACK: {
|
|
|
|
+ LOG.info("Cloning L2J DataPack");
|
|
|
|
+ cloneRepository(datapackRepository, datapackDirectory);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
LOG.error("Unable to get the code!", ex);
|
|
LOG.error("Unable to get the code!", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private void cloneRepository(String repository, File directory) {
|
|
private void cloneRepository(String repository, File directory) {
|
|
- try {
|
|
|
|
- if (directory.exists()) {
|
|
|
|
- Git.open(directory).pull();
|
|
|
|
- } else {
|
|
|
|
- Git.cloneRepository() //
|
|
|
|
- .setURI(repository) //
|
|
|
|
- .setDirectory(directory) //
|
|
|
|
- .setProgressMonitor(LOGGER_PROGRESS_MONITOR) //
|
|
|
|
- .call();
|
|
|
|
- }
|
|
|
|
|
|
+ try {
|
|
|
|
+ if (directory.exists()) {
|
|
|
|
+ Git.open(directory).pull();
|
|
|
|
+ } else {
|
|
|
|
+ Git.cloneRepository() //
|
|
|
|
+ .setURI(repository) //
|
|
|
|
+ .setDirectory(directory) //
|
|
|
|
+ .setProgressMonitor(LOGGER_PROGRESS_MONITOR) //
|
|
|
|
+ .call();
|
|
|
|
+ }
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
- LOG.error("Unable to get the code!", ex);
|
|
|
|
|
|
+ LOG.error("Unable to get the code!", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|