Add seperate install and run goal
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package org.strassburger.mcrun;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.strassburger.mcrun.config.ServerRunStepConfig;
|
||||
import org.strassburger.mcrun.steps.ServerRunStep;
|
||||
import org.strassburger.mcrun.steps.Step;
|
||||
import org.strassburger.mcrun.steps.StepExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mojo(name = "run")
|
||||
public class RunServerMojo extends AbstractMojo {
|
||||
/**
|
||||
* Heap size passed to both {@code -Xmx} and {@code -Xms}.
|
||||
* Accepts standard JVM memory notation, e.g. <code>2G</code>, <code>512M</code>.
|
||||
* Defaults to <code>2G</code>.
|
||||
*/
|
||||
@Parameter(defaultValue = "2G")
|
||||
private String memory;
|
||||
|
||||
/**
|
||||
* Additional JVM arguments to pass to the server process.
|
||||
* These are inserted after -Xmx/-Xms and before -jar.
|
||||
*
|
||||
* <pre>{@code
|
||||
* <jvmArgs>
|
||||
* <arg>-XX:+UseG1GC</arg>
|
||||
* <arg>-XX:+ParallelRefProcEnabled</arg>
|
||||
* </jvmArgs>
|
||||
* }</pre>
|
||||
*/
|
||||
@Parameter
|
||||
private List<String> jvmArgs = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Whether to start the server with JDWP remote debugging enabled.
|
||||
* When set to <code>true</code>, the JVM is launched with:
|
||||
* <code>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:{debugPort}</code>.
|
||||
* Attach your IDE's remote debugger to the configured {@code debugPort} to use this feature.
|
||||
* Defaults to <code>false</code>.
|
||||
*/
|
||||
@Parameter(defaultValue = "false")
|
||||
private boolean remoteDebug;
|
||||
|
||||
/**
|
||||
* The port the JDWP remote debugger will listen on when {@code remoteDebug} is enabled.
|
||||
* Defaults to <code>5005</code>.
|
||||
*
|
||||
* <pre>{@code
|
||||
* <remoteDebug>true</remoteDebug>
|
||||
* <debugPort>5005</debugPort>
|
||||
* }</pre>
|
||||
*/
|
||||
@Parameter(defaultValue = "5005")
|
||||
private int debugPort;
|
||||
|
||||
/**
|
||||
* The port the Minecraft server will listen on. Passed to the server via --port.
|
||||
*/
|
||||
@Parameter
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* Directory where the test server will be created and run.
|
||||
* The server jar, plugins folder, and all generated files (eula.txt, world, logs, etc.)
|
||||
* will be placed here. Defaults to <code>${project.basedir}/server</code>.
|
||||
*/
|
||||
@Parameter(defaultValue = "${project.basedir}/server")
|
||||
private File serverDirectory;
|
||||
|
||||
/**
|
||||
* File name for the downloaded or provided server jar, relative to {@code serverDirectory}.
|
||||
* Defaults to <code>server.jar</code>.
|
||||
*/
|
||||
@Parameter(defaultValue = "server.jar")
|
||||
private String serverJarName;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
Step<?> step = new ServerRunStep(getLog(),
|
||||
new ServerRunStepConfig(memory, jvmArgs, remoteDebug, debugPort, port, serverDirectory, serverJarName)
|
||||
);
|
||||
try {
|
||||
step.run();
|
||||
} catch (StepExecutionException e) {
|
||||
throw new MojoExecutionException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user