public class DefaultBuildContext extends org.codehaus.plexus.logging.AbstractLogEnabled implements BuildContext
true for all paths
newScanner returns Scanner that scans all files under provided basedir
newDeletedScanner always returns empty scanner.
isIncremental returns falsenullSEVERITY_ERROR, SEVERITY_WARNING| Constructor and Description |
|---|
DefaultBuildContext() |
| Modifier and Type | Method and Description |
|---|---|
void |
addError(java.io.File file,
int line,
int column,
java.lang.String message,
java.lang.Throwable cause)
Deprecated.
Use addMessage with severity=SEVERITY_ERROR instead
|
void |
addMessage(java.io.File file,
int line,
int column,
java.lang.String message,
int severity,
java.lang.Throwable cause)
Adds a message to the build context.
|
void |
addWarning(java.io.File file,
int line,
int column,
java.lang.String message,
java.lang.Throwable cause)
Deprecated.
Use addMessage with severity=SEVERITY_WARNING instead
|
private java.lang.String |
getMessage(java.io.File file,
int line,
int column,
java.lang.String message) |
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 |
removeMessages(java.io.File file)
Removes all messages associated with a file or folder during a previous build.
|
void |
setValue(java.lang.String key,
java.lang.Object value)
Associate specified
key with specified value
in the build context. |
public boolean hasDelta(java.lang.String relpath)
BuildContexttrue if file or folder identified by relpath has
changed since last build.hasDelta in interface BuildContextrelpath - is path relative to build context basedirpublic boolean hasDelta(java.io.File file)
BuildContexttrue if the file has changed since last build or is not
under basedir.hasDelta in interface BuildContextpublic boolean hasDelta(java.util.List relpaths)
BuildContexttrue if any file or folder identified by relpaths has
changed since last build.hasDelta in interface BuildContextrelpaths - Listpublic java.io.OutputStream newFileOutputStream(java.io.File file)
throws java.io.IOException
BuildContextfile.
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.newFileOutputStream in interface BuildContextjava.io.IOExceptionpublic org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir)
BuildContextnewScanner in interface BuildContextpublic void refresh(java.io.File file)
BuildContextrefresh in interface BuildContextBuildContext.newFileOutputStream(File)public org.codehaus.plexus.util.Scanner newDeleteScanner(java.io.File basedir)
BuildContextbasedir for files and directories
deleted since last build. Returns empty Scanner if basedir
is not under this build context basedir.newDeleteScanner in interface BuildContextpublic org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir,
boolean ignoreDelta)
BuildContextbasedir.
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 BuildContext.isUptodate(File, File)
to optimized processing of uptodate target resources.
Returns empty Scanner if basedir is not under this build context basedir.newScanner in interface BuildContexthttp://jira.codehaus.org/browse/MSHARED-125public boolean isIncremental()
BuildContexttrue 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.isIncremental in interface BuildContextpublic java.lang.Object getValue(java.lang.String key)
BuildContextkey 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.getValue in interface BuildContextBuildContext.setValue(String, Object),
BuildContext.isIncremental()public void setValue(java.lang.String key,
java.lang.Object value)
BuildContextkey 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.setValue in interface BuildContextBuildContext.getValue(String)private java.lang.String getMessage(java.io.File file,
int line,
int column,
java.lang.String message)
public void addError(java.io.File file,
int line,
int column,
java.lang.String message,
java.lang.Throwable cause)
addError in interface BuildContextpublic void addWarning(java.io.File file,
int line,
int column,
java.lang.String message,
java.lang.Throwable cause)
addWarning in interface BuildContextpublic void addMessage(java.io.File file,
int line,
int column,
java.lang.String message,
int severity,
java.lang.Throwable cause)
BuildContextaddMessage in interface BuildContextfile - The file or folder with which the message is associated. Should not be null and it is recommended to be
an absolute path.line - The line number inside the file. Use 1 (not 0) for the first line. Use 0 for unknown/unspecified.column - The column number inside the file. Use 1 (not 0) for the first column. Use 0 for unknown/unspecified.severity - The severity of the message: SEVERITY_WARNING or SEVERITY_ERROR.cause - A Throwable object associated with the message. Can be null.public void removeMessages(java.io.File file)
BuildContextremoveMessages in interface BuildContextpublic boolean isUptodate(java.io.File target,
java.io.File source)
BuildContextisUptodate in interface BuildContext