|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * Copyright © 2019 L2J Server
|
|
|
|
|
|
+ * Copyright © 2019-2022 L2J Server
|
|
*
|
|
*
|
|
* This file is part of L2J Server.
|
|
* This file is part of L2J Server.
|
|
*
|
|
*
|
|
@@ -18,8 +18,15 @@
|
|
*/
|
|
*/
|
|
package com.l2jserver.cli.command;
|
|
package com.l2jserver.cli.command;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.Properties;
|
|
|
|
|
|
|
|
+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.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -34,22 +41,39 @@ import picocli.CommandLine.Command;
|
|
*/
|
|
*/
|
|
@Command(name = "build", aliases = "b")
|
|
@Command(name = "build", aliases = "b")
|
|
public class BuildCommand extends AbstractCommand {
|
|
public class BuildCommand extends AbstractCommand {
|
|
-
|
|
|
|
|
|
+
|
|
private static final Logger LOG = LoggerFactory.getLogger(BuildCommand.class);
|
|
private static final Logger LOG = LoggerFactory.getLogger(BuildCommand.class);
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
try {
|
|
|
|
+ boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
|
|
|
|
+
|
|
|
|
+ Properties properties = new Properties();
|
|
|
|
+ properties.setProperty("skipTests", "true");
|
|
|
|
+
|
|
System.out.println("Building L2J Loginserver");
|
|
System.out.println("Building L2J Loginserver");
|
|
- Runtime.getRuntime().exec(L2JServerCLI.DEFAULT_LOGIN_SOURCE_DIR + "/mvnw install -DskipTests");
|
|
|
|
|
|
+ executeMavenWrapper("install", L2JServerCLI.DEFAULT_LOGIN_SOURCE_DIR, properties, isWindows);
|
|
|
|
|
|
System.out.println("Building L2J Gameserver");
|
|
System.out.println("Building L2J Gameserver");
|
|
- Runtime.getRuntime().exec(L2JServerCLI.DEFAULT_LOGIN_SOURCE_DIR + "/mvnw install -DskipTests");
|
|
|
|
|
|
+ executeMavenWrapper("install", L2JServerCLI.DEFAULT_GAME_SOURCE_DIR, properties, isWindows);
|
|
|
|
|
|
System.out.println("Building L2J DataPack");
|
|
System.out.println("Building L2J DataPack");
|
|
- Runtime.getRuntime().exec(L2JServerCLI.DEFAULT_DATAPACK_SOURCE_DIR + "/mvnw compile -DskipTests");
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
|
+ executeMavenWrapper("compile", L2JServerCLI.DEFAULT_DATAPACK_SOURCE_DIR, properties, isWindows);
|
|
|
|
+ } catch (Exception e) {
|
|
LOG.error("Unable to build the code!", e);
|
|
LOG.error("Unable to build the code!", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private final void executeMavenWrapper(String goal, String sourceDir, Properties properties, boolean isWindows)
|
|
|
|
+ throws MavenInvocationException {
|
|
|
|
+ InvocationRequest request = new DefaultInvocationRequest();
|
|
|
|
+ request.setPomFile(new File(sourceDir + "/pom.xml"));
|
|
|
|
+ request.setGoals(Collections.singletonList("install"));
|
|
|
|
+ request.setProperties(properties);
|
|
|
|
+ Invoker invoker = new DefaultInvoker();
|
|
|
|
+ invoker.setMavenHome(new File(sourceDir));
|
|
|
|
+ invoker.setMavenExecutable(new File("mvnw" + (isWindows ? ".cmd" : "")));
|
|
|
|
+ invoker.execute(request);
|
|
|
|
+ }
|
|
}
|
|
}
|