org.sonatype.plexus.build.incremental
Interface BuildContext

All Known Implementing Classes:
DefaultBuildContext, ThreadBuildContext

public interface BuildContext


Method Summary
 void addError(java.io.File file, int line, int column, java.lang.String message, java.lang.Throwable cause)
           
 void addWarning(java.io.File file, int line, int column, java.lang.String message, java.lang.Throwable cause)
           
 java.lang.Object getValue(java.lang.String key)
          Returns value associated with key during previous mojo execution.
 boolean hasDelta(java.io.File file)
          Returns true if the file has changed since last build or is not under basedir.
 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.
 boolean isUptodate(java.io.File target, java.io.File source)
          Returns true, if the target file exists and is uptodate compared to the source file.
 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.
 

Method Detail

hasDelta

boolean hasDelta(java.lang.String relpath)
Returns true if file or folder identified by relpath has changed since last build.

Parameters:
relpath - is path relative to build context basedir

hasDelta

boolean hasDelta(java.io.File file)
Returns true if the file has changed since last build or is not under basedir.

Since:
0.5.0

hasDelta

boolean hasDelta(java.util.List relpaths)
Returns true if any file or folder identified by relpaths has changed since last build.

Parameters:
relpaths - List are paths relative to build context basedir

refresh

void refresh(java.io.File file)
Indicates that the file or folder content has been modified during the build.

See Also:
newFileOutputStream(File)

newFileOutputStream

java.io.OutputStream newFileOutputStream(java.io.File file)
                                         throws java.io.IOException
Returns new OutputStream that writes to the file. Files changed using OutputStream returned by this method do not need to be explicitly refreshed using 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.

Throws:
java.io.IOException

newScanner

org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir)
Convenience method, fully equal to newScanner(basedir, false)


newDeleteScanner

org.codehaus.plexus.util.Scanner newDeleteScanner(java.io.File basedir)
Returned Scanner scans basedir for files and directories deleted since last build. Returns empty Scanner if basedir is not under this build context basedir.


newScanner

org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir,
                                            boolean ignoreDelta)
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. Please beware that ignoreDelta=false does NOT work reliably for operations that copy resources from source to target locations. Returned Scanner only scans changed source resources and it does not consider changed or deleted target resources. This results in missing or stale target resources. Starting with 0.5.0, recommended way to process resources is to use #newScanner(basedir,true) to locate all source resources and isUptodate(File, File) to optimized processing of uptodate target resources. Returns empty Scanner if basedir is not under this build context basedir.

See Also:
http://jira.codehaus.org/browse/MSHARED-125

isIncremental

boolean isIncremental()
Returns true if this build context is incremental. Scanners created by newScanner(File) of an incremental build context will ignore files and folders that were not changed since last build. Additionally, newDeleteScanner(File) will scan files and directories deleted since last build.


setValue

void setValue(java.lang.String key,
              java.lang.Object value)
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.

See Also:
getValue(String)

getValue

java.lang.Object getValue(java.lang.String key)
Returns value associated with key during previous mojo execution. This method always returns null for non-incremental builds (i.e., isIncremental() returns false) and mojos are expected to fall back to full, non-incremental behaviour.

See Also:
setValue(String, Object), isIncremental()

addWarning

void addWarning(java.io.File file,
                int line,
                int column,
                java.lang.String message,
                java.lang.Throwable cause)
Since:
0.5.0

addError

void addError(java.io.File file,
              int line,
              int column,
              java.lang.String message,
              java.lang.Throwable cause)
Since:
0.5.0

isUptodate

boolean isUptodate(java.io.File target,
                   java.io.File source)
Returns true, if the target file exists and is uptodate compared to the source file. More specifically, this method returns true when both target and source files exist, do not have changes since last incremental build and the target file was last modified later than the source file. Returns false in all other cases.

Since:
0.5.0


Copyright © 2008-2011. All Rights Reserved.