1 package org.apache.maven.plugin.idea;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.AbstractMojo;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.project.MavenProject;
26 import org.codehaus.plexus.util.FileUtils;
27
28 import java.io.File;
29
30
31
32
33
34
35
36 public class IdeaCleanMojo
37 extends AbstractMojo
38 {
39
40
41
42
43
44 private MavenProject project;
45
46 public void execute()
47 throws MojoExecutionException, MojoFailureException
48 {
49 File iprFile = getIdeaFile( ".ipr" );
50 deleteFile( iprFile );
51
52 File imlFile = getIdeaFile( ".iml" );
53 deleteFile( imlFile );
54
55 File iwsFile = getIdeaFile( ".iws" );
56 deleteFile( iwsFile );
57 }
58
59 private File getIdeaFile( String extension )
60 {
61 return new File( project.getBasedir(), project.getArtifactId() + extension );
62 }
63
64 private void deleteFile( File file )
65 {
66 if ( file.exists() )
67 {
68 if ( !file.isDirectory() )
69 {
70 FileUtils.fileDelete( file.getAbsolutePath() );
71 }
72 }
73 }
74 }