public Status execute() throws MojoExecutionException, MojoFailureException {
Status resultStatus = Status.SUCCESS;
try {
final ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
final DeploymentPlanBuilder builder = manager.newDeploymentPlan();
final DeploymentPlan plan = createPlan(builder);
if (plan != null) {
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());