@Parameter(alias = "startup-timeout", defaultValue = Defaults.TIMEOUT, property = PropertyNames.STARTUP_TIMEOUT)
private long startupTimeout;
@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
final Log log = getLog();
final File deploymentFile = file();
final String deploymentName = deploymentFile.getName();
final File targetDir = deploymentFile.getParentFile();
// The deployment must exist before we do anything
if (!deploymentFile.exists()) {
throw new MojoExecutionException(String.format("The deployment '%s' could not be found.", deploymentFile.getAbsolutePath()));
}
// Validate the environment
final File jbossHome = extractIfRequired(targetDir);
if (!jbossHome.isDirectory()) {
throw new MojoExecutionException(String.format("JBOSS_HOME '%s' is not a valid directory.", jbossHome));
}
// JVM arguments should be space delimited
final String[] jvmArgs = (this.jvmArgs == null ? null : this.jvmArgs.split("\\s+"));
final String javaHome;
if (this.javaHome == null) {
javaHome = SecurityActions.getEnvironmentVariable("JAVA_HOME");
} else {
javaHome = this.javaHome;
}
final List<String> invalidPaths = modulesPath.validate();
if (!invalidPaths.isEmpty()) {
throw new MojoExecutionException("Invalid module path(s). " + invalidPaths);
}
final ServerInfo serverInfo = ServerInfo.of(this, javaHome, jbossHome, modulesPath.get(), bundlesPath, jvmArgs, serverConfig, propertiesFile, startupTimeout);
// Print some server information
log.info(String.format("JAVA_HOME=%s", javaHome));
log.info(String.format("JBOSS_HOME=%s%n", jbossHome));
try {
// Create the server
final Server server = new StandaloneServer(serverInfo);
// Add the shutdown hook
SecurityActions.registerShutdown(server);
// Start the server
log.info("Server is starting up. Press CTRL + C to stop the server.");
server.start();
// Deploy the application
server.checkServerState();
if (server.isRunning()) {
log.info(String.format("Deploying application '%s'%n", deploymentFile.getName()));
final ModelControllerClient client = server.getClient();
final Deployment deployment = StandaloneDeployment.create(client, deploymentFile, deploymentName, getType(), null, null);
switch (executeDeployment(client, deployment)) {
case REQUIRES_RESTART: {
client.execute(ServerOperations.createOperation(ServerOperations.RELOAD));