Class IncrementalBuildHelper

java.lang.Object
org.apache.maven.plugin.compiler.IncrementalBuildHelper

public class IncrementalBuildHelper extends Object
Various helper methods to support incremental builds
  • Field Details

  • Constructor Details

    • IncrementalBuildHelper

      public IncrementalBuildHelper(String mojoStatusPath, Set<Path> sources, Path directory, Path outputDirectory)
  • Method Details

    • getMojoStatusDirectory

      public Path getMojoStatusDirectory() throws org.apache.maven.api.plugin.MojoException
      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:
      org.apache.maven.api.plugin.MojoException
    • inputFileTreeChanged

      public boolean inputFileTreeChanged(List<String> added, List<String> removed)
      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.
      Returns:
      true if the set of inputFiles got changed since the last build.
    • beforeRebuildExecution

      public void beforeRebuildExecution()

      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() to collect the list of files which got changed by this task.

    • afterRebuildExecution

      public void afterRebuildExecution()

      This method collects and stores all information about files changed since the call to beforeRebuildExecution().

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