You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ep...@apache.org on 2006/04/06 08:46:25 UTC

svn commit: r391916 - /maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaCleanMojo.java

Author: epunzalan
Date: Wed Apr  5 23:46:25 2006
New Revision: 391916

URL: http://svn.apache.org/viewcvs?rev=391916&view=rev
Log:
Changed idea:clean to only delete idea files with the ${artifactId}.extension name format.

Modified:
    maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaCleanMojo.java

Modified: maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaCleanMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaCleanMojo.java?rev=391916&r1=391915&r2=391916&view=diff
==============================================================================
--- maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaCleanMojo.java (original)
+++ maven/plugins/trunk/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaCleanMojo.java Wed Apr  5 23:46:25 2006
@@ -43,17 +43,27 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        File files[] = project.getBasedir().listFiles();
+        File iprFile = getIdeaFile( ".ipr" );
+        deleteFile( iprFile );
 
-        for ( int idx = 0; idx < files.length; idx++ )
-        {
-            File file = files[ idx ];
+        File imlFile = getIdeaFile( ".iml" );
+        deleteFile( imlFile );
+
+        File iwsFile = getIdeaFile( ".iws" );
+        deleteFile( iwsFile );
+    }
 
-            if ( file.getName().endsWith( ".ipr" ) ||
-                 file.getName().endsWith( ".iml" ) ||
-                 file.getName().endsWith( ".iws" ) )
+    private File getIdeaFile( String extension )
+    {
+        return new File( project.getBasedir(), project.getArtifactId() + extension );
+    }
+
+    private void deleteFile( File file )
+    {
+        if ( file.exists() )
+        {
+            if ( !file.isDirectory() )
             {
-                getLog().debug( "Deleting " + file.getAbsolutePath() + "...");
                 FileUtils.fileDelete( file.getAbsolutePath() );
             }
         }