org.sonatype.plexus.build.incremental

## Class DefaultBuildContext

- java.lang.Object
- - org.sonatype.plexus.build.incremental.DefaultBuildContext

All Implemented Interfaces:
  BuildContext

    public class DefaultBuildContext
    extends java.lang.Object
    implements BuildContext

Filesystem based non-incremental build context implementation which behaves as if all files were just created. More specifically, hasDelta returns `true` for all paths newScanner returns Scanner that scanns all files under provided basedir newDeletedScanner always returns empty scanner. isIncremental returns `false</code< getValue always returns <code>null`

### Constructor Summary

Constructors
Constructor and Description
`DefaultBuildContext()`

### Method Summary

Methods
`java.lang.Object` `getValue(java.lang.String key)` Returns value associated with `key` during previous mojo execution.
`boolean` `hasDelta(java.util.List relpaths)` Returns `true` if any file or folder identified by `relpaths` has changed since last build.
`boolean` `hasDelta(java.lang.String relpath)` Returns `true` if file or folder identified by `relpath` has changed since last build.
`boolean` `isIncremental()` Returns `true` if this build context is incremental.
`org.codehaus.plexus.util.Scanner` `newDeleteScanner(java.io.File basedir)` Returned Scanner scans `basedir` for files and directories deleted since last build.
`java.io.OutputStream` `newFileOutputStream(java.io.File file)` Returns new OutputStream that writes to the `file`.
`org.codehaus.plexus.util.Scanner` `newScanner(java.io.File basedir)` Convenience method, fully equal to newScanner(basedir, false)
`org.codehaus.plexus.util.Scanner` `newScanner(java.io.File basedir, boolean ignoreDelta)` Returned Scanner scans files and folders under `basedir`.
`void` `refresh(java.io.File file)` Indicates that the file or folder content has been modified during the build.
`void` `setValue(java.lang.String key, java.lang.Object value)` Associate specified `key` with specified `value` in the build context.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultBuildContext

    public DefaultBuildContext()

### Method Detail

#### hasDelta

    public boolean hasDelta(java.lang.String relpath)

Description copied from interface: `BuildContext`
Returns `true` if file or folder identified by `relpath` has changed since last build.

Specified by:
  `hasDelta` in interface `BuildContext`
Parameters:
  `relpath` - is path relative to build context basedir

#### hasDelta

    public boolean hasDelta(java.util.List relpaths)

Description copied from interface: `BuildContext`
Returns `true` if any file or folder identified by `relpaths` has changed since last build.

Specified by:
  `hasDelta` in interface `BuildContext`
Parameters:
  `relpaths` - List<String> are paths relative to build context basedir

#### newFileOutputStream

    public java.io.OutputStream newFileOutputStream(java.io.File file)
                                             throws java.io.IOException

Description copied from interface: `BuildContext`
Returns new OutputStream that writes to the `file`. Files changed using OutputStream returned by this method do not need to be explicitly refreshed using `BuildContext.refresh(File)`. As an optional optimisation, OutputStreams created by incremental build context will attempt to avoid writing to the file if file content has not changed.

Specified by:
  `newFileOutputStream` in interface `BuildContext`
Throws:
  `java.io.IOException`

#### newScanner

    public org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir)

Description copied from interface: `BuildContext`
Convenience method, fully equal to newScanner(basedir, false)

Specified by:
  `newScanner` in interface `BuildContext`

#### refresh

    public void refresh(java.io.File file)

Description copied from interface: `BuildContext`
Indicates that the file or folder content has been modified during the build.

Specified by:
  `refresh` in interface `BuildContext`
See Also:
  `BuildContext.newFileOutputStream(File)`

#### newDeleteScanner

    public org.codehaus.plexus.util.Scanner newDeleteScanner(java.io.File basedir)

Description copied from interface: `BuildContext`
Returned Scanner scans `basedir` for files and directories deleted since last build. Returns empty Scanner if `basedir` is not under this build context basedir.

Specified by:
  `newDeleteScanner` in interface `BuildContext`

#### newScanner

    public org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir,
                                              boolean ignoreDelta)

Description copied from interface: `BuildContext`
Returned Scanner scans files and folders under `basedir`. If this is an incremental build context and `ignoreDelta` is `false`, the scanner will only "see" files and folders with content changes since last build. If `ignoreDelta` is `true`, the scanner will "see" all files and folders. Returns empty Scanner if `basedir` is not under this build context basedir.

Specified by:
  `newScanner` in interface `BuildContext`

#### isIncremental

    public boolean isIncremental()

Description copied from interface: `BuildContext`
Returns `true` if this build context is incremental. Scanners created by `BuildContext.newScanner(File)` of an incremental build context will ignore files and folders that were not changed since last build. Additionally, `BuildContext.newDeleteScanner(File)` will scan files and directories deleted since last build.

Specified by:
  `isIncremental` in interface `BuildContext`

#### getValue

    public java.lang.Object getValue(java.lang.String key)

Description copied from interface: `BuildContext`
Returns value associated with `key` during previous mojo execution. This method always returns `null` for non-incremental builds (i.e., `BuildContext.isIncremental()` returns `false`) and mojos are expected to fall back to full, non-incremental behaviour.

Specified by:
  `getValue` in interface `BuildContext`
See Also:
  `BuildContext.setValue(String, Object)`, `BuildContext.isIncremental()`

#### setValue

    public void setValue(java.lang.String key,
                java.lang.Object value)

Description copied from interface: `BuildContext`
Associate specified `key` with specified `value` in the build context. Primary (and the only) purpose of this method is to allow preservation of state needed for proper incremental behaviour between consecutive executions of the same mojo needed to. For example, maven-plugin-plugin:descriptor mojo can store collection of extracted MojoDescritpor during first invocation. Then on each consecutive execution maven-plugin-plugin:descriptor will only need to extract MojoDescriptors for changed files.

Specified by:
  `setValue` in interface `BuildContext`
See Also:
  `BuildContext.getValue(String)`