01: package org.andromda.maven.plugin.andromdapp;
02:
03: import java.io.File;
04:
05: import org.apache.commons.io.FileUtils;
06: import org.apache.maven.plugin.MojoExecutionException;
07: import org.apache.maven.plugin.MojoFailureException;
08:
09: /**
10: * Provides the undeployment of applications from a given directory.
11: *
12: * @goal undeploy
13: * @author Chad Brandon
14: */
15: public class UndeployMojo extends AppManagementMojo {
16: /**
17: * @see org.apache.maven.plugin.AbstractMojo#execute()
18: */
19: public void execute() throws MojoExecutionException,
20: MojoFailureException {
21: final File deployDirectory = new File(this .deployLocation);
22: if (deployDirectory.exists() && deployDirectory.isDirectory()) {
23: try {
24: final File deployFile = this .getDeployFile();
25: this .getLog().info(
26: "Undeploying " + deployFile + " from "
27: + deployDirectory);
28: if (deployFile.isDirectory()) {
29: FileUtils.deleteDirectory(deployFile);
30: } else {
31: deployFile.delete();
32: }
33: } catch (final Throwable throwable) {
34: throw new MojoExecutionException(
35: "An error occurred while attempting to undeploy artifact",
36: throwable);
37: }
38: } else {
39: this
40: .getLog()
41: .warn(
42: "Undeploy did not occur because the specified deployLocation '"
43: + deployLocation
44: + "' does not exist, or is not a directory");
45: }
46: }
47: }
|