org.apache.maven.shared.incremental
Class IncrementalBuildHelper

java.lang.Object
  extended by org.apache.maven.shared.incremental.IncrementalBuildHelper

public class IncrementalBuildHelper
extends Object

Various helper methods to support incremental builds


Field Summary
static String CREATED_FILES_LST_FILENAME
           
 
Constructor Summary
IncrementalBuildHelper(MojoExecution mojoExecution, MavenProject mavenProject)
           
IncrementalBuildHelper(MojoExecution mojoExecution, MavenSession mavenSession)
           
 
Method Summary
 void afterRebuildExecution(IncrementalBuildHelperRequest incrementalBuildHelperRequest)
          This method collects and stores all information about files changed since the call to beforeRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest).
 String[] beforeRebuildExecution(IncrementalBuildHelperRequest incrementalBuildHelperRequest)
          This method shall get invoked before the actual Mojo task gets triggered, e.g. the actual compile in maven-compiler-plugin.
 DirectoryScanner getDirectoryScanner()
          Get the existing DirectoryScanner used by this helper, or create new a DirectoryScanner if none is yet set.
 File getMojoStatusDirectory()
          We use a specific status directory for each Mojo execution to store state which is needed during the next build invocation run.
 boolean inputFileTreeChanged(DirectoryScanner dirScanner)
          Detect whether the list of detected files picked up by the DirectoryScanner has changed since the last build.
 boolean inputFileTreeChanged(IncrementalBuildHelperRequest incrementalBuildHelperRequest)
          Detect whether the list of detected files has changed since the last build.
 void setDirectoryScanner(DirectoryScanner directoryScanner)
          Set the DirectoryScanner which shall get used by this build helper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATED_FILES_LST_FILENAME

public static final String CREATED_FILES_LST_FILENAME
See Also:
Constant Field Values
Constructor Detail

IncrementalBuildHelper

public IncrementalBuildHelper(MojoExecution mojoExecution,
                              MavenSession mavenSession)

IncrementalBuildHelper

public IncrementalBuildHelper(MojoExecution mojoExecution,
                              MavenProject mavenProject)
Method Detail

getDirectoryScanner

public DirectoryScanner getDirectoryScanner()
Get the existing DirectoryScanner used by this helper, or create new a DirectoryScanner if none is yet set. The DirectoryScanner is used for detecting changes in a directory


setDirectoryScanner

public void setDirectoryScanner(DirectoryScanner directoryScanner)
Set the DirectoryScanner which shall get used by this build helper.

Parameters:
directoryScanner -

getMojoStatusDirectory

public File getMojoStatusDirectory()
                            throws MojoExecutionException
We use a specific status directory for each Mojo execution to store state which is needed during the next build invocation run.

Returns:
the directory for storing status information of the current Mojo execution.
Throws:
MojoExecutionException

inputFileTreeChanged

public boolean inputFileTreeChanged(IncrementalBuildHelperRequest incrementalBuildHelperRequest)
                             throws MojoExecutionException
Detect whether the list of detected files has changed since the last build. We simply load the list of files for the previous build from a status file and compare it with the new list. Afterwards we store the new list in the status file.

Parameters:
incrementalBuildHelperRequest -
Returns:
true if the set of inputFiles got changed since the last build.
Throws:
MojoExecutionException

inputFileTreeChanged

public boolean inputFileTreeChanged(DirectoryScanner dirScanner)
                             throws MojoExecutionException
Detect whether the list of detected files picked up by the DirectoryScanner has changed since the last build. We simply load the list of files for the previous build from a status file and compare it with the result of the new DirectoryScanner#scan(). Afterwards we store the new list in the status file.

Parameters:
dirScanner -
Returns:
true if the set of inputFiles got changed since the last build.
Throws:
MojoExecutionException

beforeRebuildExecution

public String[] beforeRebuildExecution(IncrementalBuildHelperRequest incrementalBuildHelperRequest)
                                throws MojoExecutionException

This method shall get invoked before the actual Mojo task gets triggered, e.g. the actual compile in maven-compiler-plugin.

Attention: This method shall only get invoked if the plugin re-creates all the output.

It first picks up the list of files created in the previous build and delete them. This step is necessary to prevent left-overs. After that we take a 'directory snapshot' (list of all files which exist in the outputDirectory after the clean).

After the actual Mojo task got executed you should invoke the method afterRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest) to collect the list of files which got changed by this task.

Parameters:
incrementalBuildHelperRequest -
Returns:
all files which got created in the previous build and have been deleted now.
Throws:
MojoExecutionException

afterRebuildExecution

public void afterRebuildExecution(IncrementalBuildHelperRequest incrementalBuildHelperRequest)
                           throws MojoExecutionException

This method collects and stores all information about files changed since the call to beforeRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest).

Attention: This method shall only get invoked if the plugin re-creates all the output.

Parameters:
incrementalBuildHelperRequest - will contains file sources to store if create files are not yet stored
Throws:
MojoExecutionException


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.