|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sonatype.plexus.build.incremental.ThreadBuildContext
public class ThreadBuildContext
BuildContext implementation that delegates actual work to thread-local
build context set using setThreadBuildContext(BuildContext)
.
DefaultBuildContext
is used if no thread local build context was set.
Note that plexus component metadata is not generated for this implementation.
Apparently, older version of plexus used by maven-filtering and likely
other projects, does not honour "default" role-hint.
Constructor Summary | |
---|---|
ThreadBuildContext()
|
Method Summary | |
---|---|
static BuildContext |
getContext()
|
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. |
static void |
setThreadBuildContext(BuildContext context)
|
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 |
---|
public ThreadBuildContext()
Method Detail |
---|
public static BuildContext getContext()
public static void setThreadBuildContext(BuildContext context)
public boolean hasDelta(java.lang.String relPath)
BuildContext
true
if file or folder identified by relpath
has
changed since last build.
hasDelta
in interface BuildContext
relPath
- is path relative to build context basedirpublic boolean hasDelta(java.util.List relPaths)
BuildContext
true
if any file or folder identified by relpaths
has
changed since last build.
hasDelta
in interface BuildContext
relPaths
- Listpublic org.codehaus.plexus.util.Scanner newDeleteScanner(java.io.File basedir)
BuildContext
basedir
for files and directories
deleted since last build. Returns empty Scanner if basedir
is not under this build context basedir.
newDeleteScanner
in interface BuildContext
public java.io.OutputStream newFileOutputStream(java.io.File file) throws java.io.IOException
BuildContext
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.
newFileOutputStream
in interface BuildContext
java.io.IOException
public org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir)
BuildContext
newScanner
in interface BuildContext
public org.codehaus.plexus.util.Scanner newScanner(java.io.File basedir, boolean ignoreDelta)
BuildContext
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.
newScanner
in interface BuildContext
public void refresh(java.io.File file)
BuildContext
refresh
in interface BuildContext
BuildContext.newFileOutputStream(File)
public java.lang.Object getValue(java.lang.String key)
BuildContext
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.
getValue
in interface BuildContext
BuildContext.setValue(String, Object)
,
BuildContext.isIncremental()
public boolean isIncremental()
BuildContext
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.
isIncremental
in interface BuildContext
public void setValue(java.lang.String key, java.lang.Object value)
BuildContext
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.
setValue
in interface BuildContext
BuildContext.getValue(String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |