1 package org.andromda.maven.plugin.andromdapp;
2
3 import java.io.File;
4 import org.apache.commons.io.FileUtils;
5 import org.apache.maven.plugin.MojoExecutionException;
6 import org.apache.maven.plugin.MojoFailureException;
7
8
9
10
11
12
13
14 public class UndeployMojo
15 extends AppManagementMojo
16 {
17
18
19
20 public void execute()
21 throws MojoExecutionException, MojoFailureException
22 {
23 if (this.deployLocation.exists() && this.deployLocation.isDirectory())
24 {
25 try
26 {
27 final File deployFile = this.getDeployFile();
28 this.getLog().info("Undeploying " + deployFile + " from " + this.deployLocation);
29 if (deployFile.isDirectory())
30 {
31 FileUtils.deleteDirectory(deployFile);
32 }
33 else
34 {
35 deployFile.delete();
36 }
37 }
38 catch (final Throwable throwable)
39 {
40 throw new MojoExecutionException("An error occurred while attempting to undeploy artifact", throwable);
41 }
42 }
43 else
44 {
45 this.getLog().warn(
46 "Undeploy did not occur because the specified deployLocation '" + deployLocation +
47 "' does not exist, or is not a directory");
48 }
49 }
50 }