}
if (this.deploymentUnits.size() != 1) {
throw new BuildException("The rhq:bundle task must contain exactly one rhq:deploymentUnit element.");
}
DeploymentUnitType deploymentUnit = this.deploymentUnits.values().iterator().next();
String deploymentPhaseName = (String) projectProps.get(DeployPropertyNames.DEPLOY_PHASE);
if (deploymentPhaseName == null) {
throw new BuildException("Required property [" + DeployPropertyNames.DEPLOY_PHASE + "] was not specified.");
}
DeploymentPhase deploymentPhase;
try {
deploymentPhase = DeploymentPhase.valueOf(deploymentPhaseName.toUpperCase());
} catch (IllegalArgumentException e) {
DeploymentPhase[] phases = DeploymentPhase.values();
List<String> validPhaseNames = new ArrayList<String>(phases.length);
for (DeploymentPhase phase : phases) {
validPhaseNames.add(phase.name().toLowerCase());
}
throw new BuildException("Value of property '" + DeployPropertyNames.DEPLOY_PHASE + "' ("
+ deploymentPhaseName + ") is not a valid deployment phase - the valid phases are " + validPhaseNames
+ ".");
}
getProject().setDeploymentPhase(deploymentPhase);
String dryRunString = (String) projectProps.get(DeployPropertyNames.DEPLOY_DRY_RUN);
boolean dryRun = Boolean.valueOf(dryRunString);
getProject().setDryRun(dryRun);
String revertString = (String) projectProps.get(DeployPropertyNames.DEPLOY_REVERT);
boolean revert = Boolean.valueOf(revertString);
String cleanString = (String) projectProps.get(DeployPropertyNames.DEPLOY_CLEAN);
boolean clean = Boolean.valueOf(cleanString);
log("Executing '" + deploymentPhase + "' phase for deployment with id [" + deploymentId + "] from bundle '"
+ this.name + "' version " + this.version + " using config "
+ getProject().getConfiguration().toString(true) + " [dryRun=" + dryRun + ", revert=" + revert + ", clean="
+ clean + "]...");
deploymentUnit.init();
switch (deploymentPhase) {
case INSTALL:
// TODO: Revert doesn't really make sense for an initial install.
deploymentUnit.install(revert, clean);
break;
case START:
deploymentUnit.start();
break;
case STOP:
deploymentUnit.stop();
break;
case UPGRADE:
deploymentUnit.upgrade(revert, clean);
break;
case UNINSTALL:
deploymentUnit.uninstall();
break;
}
}