|
@@ -26,11 +26,11 @@ import org.apache.maven.shared.invoker.DefaultInvocationRequest;
|
|
|
import org.apache.maven.shared.invoker.DefaultInvoker;
|
|
|
import org.apache.maven.shared.invoker.InvocationRequest;
|
|
|
import org.apache.maven.shared.invoker.Invoker;
|
|
|
-import org.apache.maven.shared.invoker.MavenInvocationException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import picocli.CommandLine.Command;
|
|
|
+import picocli.CommandLine.Option;
|
|
|
|
|
|
/**
|
|
|
* Build command.
|
|
@@ -43,39 +43,52 @@ public class BuildCommand extends AbstractCommand {
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(BuildCommand.class);
|
|
|
|
|
|
+ @Option(names = {"--login-directory", "-lsdir"}, defaultValue = DEFAULT_LOGIN_SOURCE_DIR, description = "Login directory")
|
|
|
+ private String loginDirectory = DEFAULT_LOGIN_SOURCE_DIR;
|
|
|
+ @Option(names = {"--game-directory", "-gsdir"}, defaultValue = DEFAULT_GAME_SOURCE_DIR, description = "Game directory")
|
|
|
+ private String gameDirectory = DEFAULT_GAME_SOURCE_DIR;
|
|
|
+ @Option(names = {"--datapack-directory", "-dpdir"}, defaultValue = DEFAULT_DATAPACK_SOURCE_DIR, description = "DataPack directory")
|
|
|
+ private String datapackDirectory = DEFAULT_DATAPACK_SOURCE_DIR;
|
|
|
+
|
|
|
+ @Option(names = {"--skip-tests", "-st"}, defaultValue = "true", description = "Skip Tests")
|
|
|
+ private boolean skipTests = true;
|
|
|
+
|
|
|
@Override
|
|
|
public void run() {
|
|
|
try {
|
|
|
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
|
|
|
|
|
|
Properties properties = new Properties();
|
|
|
- properties.setProperty("skipTests", "true");
|
|
|
+ if (skipTests) {
|
|
|
+ properties.setProperty("skipTests", "true");
|
|
|
+ }
|
|
|
|
|
|
System.out.println("Building L2J Loginserver");
|
|
|
- executeMavenWrapper("install", DEFAULT_LOGIN_SOURCE_DIR, properties, isWindows);
|
|
|
+ executeMavenWrapper("install", loginDirectory, properties, isWindows);
|
|
|
|
|
|
System.out.println("Building L2J Gameserver");
|
|
|
- executeMavenWrapper("install", DEFAULT_GAME_SOURCE_DIR, properties, isWindows);
|
|
|
+ executeMavenWrapper("install", gameDirectory, properties, isWindows);
|
|
|
|
|
|
System.out.println("Building L2J DataPack");
|
|
|
- executeMavenWrapper("install", DEFAULT_DATAPACK_SOURCE_DIR, properties, isWindows);
|
|
|
+ executeMavenWrapper("install", datapackDirectory, properties, isWindows);
|
|
|
} catch (Exception e) {
|
|
|
LOG.error("Unable to build the code!", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private final void executeMavenWrapper(String goal, String sourceDir, Properties properties, boolean isWindows)
|
|
|
- throws MavenInvocationException {
|
|
|
- File mavenExecutable = new File("mvnw" + (isWindows ? ".cmd" : ""));
|
|
|
- mavenExecutable.setExecutable(true);
|
|
|
+ throws Exception {
|
|
|
+ String mavenExecutableName = "mvnw" + (isWindows ? ".cmd" : "");
|
|
|
+ File mavenExecutableFile = new File(sourceDir, mavenExecutableName).getAbsoluteFile();
|
|
|
+ mavenExecutableFile.setExecutable(true);
|
|
|
|
|
|
InvocationRequest request = new DefaultInvocationRequest();
|
|
|
- request.setPomFile(new File(sourceDir + "/pom.xml"));
|
|
|
+ request.setPomFile(new File(sourceDir, "pom.xml"));
|
|
|
request.setGoals(Collections.singletonList(goal));
|
|
|
request.setProperties(properties);
|
|
|
Invoker invoker = new DefaultInvoker();
|
|
|
invoker.setMavenHome(new File(sourceDir));
|
|
|
- invoker.setMavenExecutable(mavenExecutable);
|
|
|
+ invoker.setMavenExecutable(mavenExecutableFile);
|
|
|
invoker.execute(request);
|
|
|
}
|
|
|
}
|