You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/11/27 00:12:59 UTC

svn commit: r1413919 - /maven/shared/trunk/maven-shared-incremental/src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java

Author: olamy
Date: Mon Nov 26 23:12:58 2012
New Revision: 1413919

URL: http://svn.apache.org/viewvc?rev=1413919&view=rev
Log:
[MSHARED-264] afterRebuildExecution must create createdFiles.lst file if not exists

Modified:
    maven/shared/trunk/maven-shared-incremental/src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java

Modified: maven/shared/trunk/maven-shared-incremental/src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-incremental/src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java?rev=1413919&r1=1413918&r2=1413919&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-incremental/src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java (original)
+++ maven/shared/trunk/maven-shared-incremental/src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java Mon Nov 26 23:12:58 2012
@@ -312,9 +312,11 @@ public class IncrementalBuildHelper
      *
      * <p><b>Attention:</b> This method shall only get invoked if the plugin re-creates <b>all</b> the output.</p>
      *
+     * @param sources file sources to store if create files are not yet stored
+     *
      * @throws MojoExecutionException
      */
-    public void afterRebuildExecution()
+    public void afterRebuildExecution( Set<File> sources )
         throws MojoExecutionException
     {
         DirectoryScanner diffScanner = getDirectoryScanner();
@@ -329,10 +331,41 @@ public class IncrementalBuildHelper
         {
             FileUtils.fileWriteArray( mojoConfigFile, scanResult.getFilesAdded() );
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             throw new MojoExecutionException( "Error while storing the mojo status", e );
         }
 
+        // in case of clean compile the file is not created so next compile won't see it
+        // we mus create it here
+        mojoConfigFile = new File( mojoConfigBase, INPUT_FILES_LST_FILENAME );
+        if ( !mojoConfigFile.exists() )
+        {
+            try
+            {
+                FileUtils.fileWriteArray( mojoConfigFile, toArrayOfPath( sources ));
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Error while storing the mojo status", e );
+            }
+        }
+
+    }
+
+    private String[] toArrayOfPath( Set<File> files )
+    {
+
+        String[] paths = new String[files.size()];
+
+        int i = 0;
+
+        for ( File file : files )
+        {
+            paths[i] = file.getPath();
+            i++;
+        }
+
+        return paths;
     }
 }