1 package org.apache.maven.plugin.ant;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.apache.maven.plugin.AbstractMojo;
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.project.MavenProject;
27
28
29
30
31
32
33
34
35 public class AntCleanMojo
36 extends AbstractMojo
37 {
38
39
40
41
42
43
44 private MavenProject project;
45
46
47
48
49 public void execute()
50 throws MojoExecutionException
51 {
52 File buildXml = new File( project.getBasedir(), AntBuildWriter.DEFAULT_BUILD_FILENAME );
53 if ( buildXml.exists() && !buildXml.delete() )
54 {
55 throw new MojoExecutionException( "Cannot delete " + buildXml.getAbsolutePath() );
56 }
57
58 File mavenBuildXml = new File( project.getBasedir(), AntBuildWriter.DEFAULT_MAVEN_BUILD_FILENAME );
59 if ( mavenBuildXml.exists() && !mavenBuildXml.delete() )
60 {
61 throw new MojoExecutionException( "Cannot delete " + mavenBuildXml.getAbsolutePath() );
62 }
63
64 File mavenBuildProperties = new File( project.getBasedir(), AntBuildWriter.DEFAULT_MAVEN_PROPERTIES_FILENAME );
65 if ( mavenBuildProperties.exists() && !mavenBuildProperties.delete() )
66 {
67 throw new MojoExecutionException( "Cannot delete " + mavenBuildProperties.getAbsolutePath() );
68 }
69
70 getLog().info(
71 "Deleted Ant project for " + project.getArtifactId() + " in "
72 + project.getBasedir().getAbsolutePath() );
73 }
74 }