getLog().info(String.format("Executing goal %s on server %s (%s) port %s.", goal(), host.getHostName(), host.getHostAddress(), port()));
final ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client());
final DeploymentPlanBuilder builder = manager.newDeploymentPlan();
final DeploymentPlan plan = createPlan(builder);
if (plan.getDeploymentActions().size() > 0) {
final ServerDeploymentPlanResult planResult = manager.execute(plan).get();
// Check the results
for (DeploymentAction action : plan.getDeploymentActions()) {
final ServerDeploymentActionResult actionResult = planResult.getDeploymentActionResult(action.getId());
final ServerUpdateActionResult.Result result = actionResult.getResult();
switch (result) {
case FAILED:
throw new MojoExecutionException("Deployment failed.", actionResult.getDeploymentException());
case NOT_EXECUTED:
throw new MojoExecutionException("Deployment not executed.", actionResult.getDeploymentException());
case ROLLED_BACK:
throw new MojoExecutionException("Deployment failed and was rolled back.", actionResult.getDeploymentException());
case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
getLog().warn("Action was executed, but the server requires a restart.");
break;
default:
break;
}
getLog().debug(String.format("Deployment Plan Id : %s", planResult.getDeploymentPlanId()));
}
} else {
getLog().warn(String.format("Goal %s failed on file %s. No deployment actions exist. Plan: %s", goal(), file().getName(), plan));
}
}