Class BuildContextHolder


  • public class BuildContextHolder
    extends java.lang.Object
    Encapsulate the details about state persisted across multiple build runs. This class hides the details about the storage used to persist the data produced during a build. By default the BuildContext is used, but if it is not available - the alternate storage (a properties file stored in the file system) is used.
    Since:
    1.7.1
    Author:
    Alex Objelean
    • Constructor Summary

      Constructors 
      Constructor Description
      BuildContextHolder​(org.sonatype.plexus.build.incremental.BuildContext buildContext, java.io.File buildDirectory)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      Destroy the persisted storage and all stored data.
      java.lang.String getValue​(java.lang.String key)  
      boolean isIncrementalBuild()  
      void persist()
      Persist the fallbackStorage to the fallbackStorageFile.
      void setIncrementalBuildEnabled​(boolean incrementalBuildEnabled)  
      void setValue​(java.lang.String key, java.lang.String value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BuildContextHolder

        public BuildContextHolder​(org.sonatype.plexus.build.incremental.BuildContext buildContext,
                                  java.io.File buildDirectory)
        Parameters:
        buildContext - - The context provided by maven. If this is not provided, the default mechanism for persisting build data is used.
        buildDirectory - the folder where the build output is created. If this value is null, the temp folder will be used.
    • Method Detail

      • getValue

        public java.lang.String getValue​(java.lang.String key)
        Parameters:
        key - of the value to retrieve.
        Returns:
        the persisted value stored under the provided key. If no value exist, the returned result will be null.
      • setValue

        public void setValue​(java.lang.String key,
                             java.lang.String value)
        Parameters:
        key - to associate with the value to be persisted.
        value - to persist.
      • setIncrementalBuildEnabled

        public void setIncrementalBuildEnabled​(boolean incrementalBuildEnabled)
      • isIncrementalBuild

        public boolean isIncrementalBuild()
        Returns:
        the flag indicating the incremental build change. A build is incremental, when the modified resources should be processed only. Useful to avoid unnecessary processing when there is actually no change detected.
      • destroy

        public void destroy()
        Destroy the persisted storage and all stored data.
      • persist

        public void persist()
        Persist the fallbackStorage to the fallbackStorageFile. This method should be invoked only once during build, since it is relatively expensive. Not invoking it, would break the incremental build feature.