Add seperate install and run goal
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
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.ServerInstallConfig;
|
||||
import org.strassburger.mcrun.steps.ServerInstallStep;
|
||||
import org.strassburger.mcrun.steps.Step;
|
||||
import org.strassburger.mcrun.steps.StepExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Mojo(name = "install")
|
||||
public class InstallServerMojo extends AbstractMojo {
|
||||
/**
|
||||
* Path to the plugin jar to deploy. Defaults to the project's build output jar.
|
||||
* Override if your jar is assembled elsewhere or has a classifier.
|
||||
*/
|
||||
@Parameter(defaultValue = "${project.build.directory}/${project.build.finalName}.jar")
|
||||
private File pluginJar;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The server software to download. Defaults to <code>paper</code>.
|
||||
* Can be one <code>paper</code> or <code>spigot</code>.
|
||||
*/
|
||||
@Parameter(defaultValue = "paper")
|
||||
private String serverSoftware;
|
||||
|
||||
/**
|
||||
* When {@code true}, automatically creates {@code eula.txt} with {@code eula=true}
|
||||
* in the server directory if it does not already exist, bypassing the manual
|
||||
* acceptance step. Defaults to {@code false}.
|
||||
*
|
||||
* <p>By setting this to {@code true} you are indicating that you accept the
|
||||
* <a href="https://aka.ms/MinecraftEULA">Minecraft End User License Agreement</a>.</p>
|
||||
*/
|
||||
@Parameter(defaultValue = "false")
|
||||
private boolean acceptEula;
|
||||
|
||||
/**
|
||||
* The Minecraft version to run, e.g. <code>1.21.4</code>. Required.
|
||||
*/
|
||||
@Parameter(required = true)
|
||||
private String mcVersion;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
Step<?> step = new ServerInstallStep(getLog(),
|
||||
new ServerInstallConfig(serverDirectory, pluginJar, serverJarName, serverSoftware, mcVersion, acceptEula)
|
||||
);
|
||||
try {
|
||||
step.run();
|
||||
} catch (StepExecutionException e) {
|
||||
throw new MojoExecutionException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user