1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.eclipse;
20
21 import org.apache.maven.plugin.AbstractMojo;
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugin.eclipse.writers.workspace.EclipseWorkspaceWriter;
24 import org.apache.maven.plugin.ide.IdeUtils;
25 import org.apache.maven.plugins.annotations.Mojo;
26 import org.apache.maven.plugins.annotations.Parameter;
27
28 import java.io.File;
29
30
31
32
33 @Mojo( name = "clean" )
34 public class EclipseCleanMojo
35 extends AbstractMojo
36 {
37
38
39
40
41 private static final String FILE_DOT_WTPMODULES = ".wtpmodules";
42
43
44
45
46 private static final String FILE_DOT_CLASSPATH = ".classpath";
47
48
49
50
51 private static final String FILE_DOT_PROJECT = ".project";
52
53
54
55
56 @Parameter( property = "project.packaging" )
57 private String packaging;
58
59
60
61
62 @Parameter( property = "basedir" )
63 private File basedir;
64
65
66
67
68 @Parameter( property = "eclipse.skip", defaultValue = "false" )
69 private boolean skip;
70
71
72
73
74 @Parameter
75 private EclipseConfigFile[] additionalConfig;
76
77
78
79
80 public void execute()
81 throws MojoExecutionException
82 {
83 if ( skip )
84 {
85 return;
86 }
87
88 if ( Constants.PROJECT_PACKAGING_POM.equals( this.packaging ) )
89 {
90 return;
91 }
92
93 delete( new File( basedir, FILE_DOT_PROJECT ) );
94 delete( new File( basedir, FILE_DOT_CLASSPATH ) );
95 delete( new File( basedir, FILE_DOT_WTPMODULES ) );
96
97 delete( new File( basedir, EclipseWorkspaceWriter.DIR_DOT_SETTINGS ) );
98
99 if ( additionalConfig != null )
100 {
101 for (EclipseConfigFile anAdditionalConfig : additionalConfig) {
102 delete(new File(basedir, anAdditionalConfig.getName()));
103 }
104 }
105
106 cleanExtras();
107 }
108
109 protected void cleanExtras()
110 throws MojoExecutionException
111 {
112
113 }
114
115
116
117
118
119
120
121 protected void delete( File f )
122 throws MojoExecutionException
123 {
124 IdeUtils.delete( f, getLog() );
125 }
126
127
128
129
130
131
132 public File getBasedir()
133 {
134 return this.basedir;
135 }
136
137
138
139
140
141
142 public void setBasedir( File basedir )
143 {
144 this.basedir = basedir;
145 }
146
147
148
149
150 public String getPackaging()
151 {
152 return this.packaging;
153 }
154
155
156
157
158 public void setPackaging( String packaging )
159 {
160 this.packaging = packaging;
161 }
162
163 }