|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.haefelingerit.tagmod.Plugin
public class Plugin
This class implements a SourceControl element to be plugged into CruiseControl as a method to detected modifications.
The modification to be detected is whether a CVS tag got assigned to a CVS project. CVS does not provide a direct way to detect this. Instead it is assumed that a tag handler is plugged into the CVS server which records relevant tag operations[1].
This plugin assumes then, that a local file exists which contains all recorded tag operations. The content of this file must follow some simple syntax rules - see class Parser for further details. How the content of this file is transferred from the CVS server side to the side hosting CruiseControl is not subject of this plugin. The default implementation of the CVS script saves each tag operation itself into CVS as log message of a particular log file. Getting a list of all tag operations is than as simple as calling% cvs rlog $somefileThis command can then also be used in CruiseControl to regularly query the current list of all tag operations.
About the life-cycle of a source control element within CruiseControl:
For each XML element, a instance of this class gets created. After creation,
the object is validated by calling method validate(). If the
configuration file changes, the object will be thrown away eventually and a
new object gets created and validated.
[1] A example implementation of a tag handler is part of this
package. See the folder named scripts.
| Field Summary | |
|---|---|
protected boolean |
debug
A flag to enable individual debugging. |
protected File |
file
The file to read and parse tag related actions from, see also setFile(File). |
List |
mods
The list of modifications, see also getModifications(Date, Date) |
protected Parser |
parser
The parser to use for parsing tag related actions from. |
protected Hashtable |
properties
A hash table for all those properties to be passed down to the build engine, see also getProperties(). |
protected String |
stem
The prefix to use for naming properties, see also setStem(String). |
| Constructor Summary | |
|---|---|
Plugin()
|
|
| Method Summary | |
|---|---|
protected void |
checkfilestatus()
A helper method to check (internal) file's status. |
protected boolean |
debugmode()
Check whether debug has been enabled. |
protected void |
fetch(Date last,
Date now)
Fetch all tag related changes between [ last,
now]. |
List |
getModifications(Date last,
Date now)
Returns a list of modifications detailing all the changes between the last build and now. |
Map |
getProperties()
Returns properties defined by this modification to be passed down to a build engine. |
void |
setDebug(boolean b)
If set to true, then debug messages will be sent to the log
stream using level info for this particular element. |
void |
setFile(File file)
The file to be parsed. |
void |
setProject(String project)
The name of the project to watch for tag related action. |
void |
setPropertyOnDelete(String propertyOnDelete)
Name of property to define if a deletion is detected. |
void |
setStem(String stem)
Set the stem to be used as prefix for properties passed to CruiseControl. |
void |
setTagaction(String s)
Use this method to trigger a build if the tag operation matches a given regular expression. |
void |
setTagvalue(String re)
Use this method to filter specific tag values. |
void |
validate()
Called once CruiseControl whenever the underlying configuration got changed or when starting up CruiseControl. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean debug
setDebug(boolean).
protected Hashtable properties
getProperties().
protected File file
setFile(File).
protected String stem
setStem(String).
protected Parser parser
public List mods
getModifications(Date, Date)
| Constructor Detail |
|---|
public Plugin()
| Method Detail |
|---|
public void setFile(File file)
This file is expected to contain tag related events in a well defined format. For further information on this format, see class Parser.
If the argument is null, a default value will be used (see validate() for a table of default values.
The file specified does not need to exist prior to starting up CruiseControl. A warning message will be logged however, if CruiseControl calls getModifications(Date, Date) and the file does not exist or is otherwise not accessible.
public void setDebug(boolean b)
true, then debug messages will be sent to the log
stream using level info for this particular element. This may
help to debug this particular element.
public void setProject(String project)
project is either null or empty, the default value will
be used.
public void setTagvalue(String re)
By default, every tag value is taken into account. However, not every tag value indicates a release, a version or, in general, something that should trigger a project build.
Therefore a regular expression can be
set to filter interesting tag values while ignoring others. When a tag
value is ignored, no build is triggered. For example, assume that the
convention exists, that tags starting with either r- or
v- indicate a version or release while other values are used
to preserve the current project's state. You would then use the regular
expression (?:r|v)-.*?
as filter to trigger a version or release build.
When grouping, care must be taken. In the example above,
(r|v)-.*? would match exactly the same text. The problem is
that using capturing groups will break the underlying algorithm. You
are therefore asked to use non capturing groups.
For performance reasons, it is wise to use non greedy quantifiers. So instead of using .* (to match everything), you would use .*? instead.
For details on regular expressions see Pattern and
see also Mastering Regular Expressions, an
outstanding good book on this subject by Jeffrey Friedl.
If the value given is null or empty, a default value is being used.
public void setTagaction(String s)
By default, add tag operations are processed. Other operations
like mov and del are ignored.
See also setTagvalue(String) for further details on using regular expressions.
If the value given is null or empty, a default value is being used.
public void setPropertyOnDelete(String propertyOnDelete)
getProperties()
call.
This is an (unsupported) interface method.
propertyOnDelete - (not used)public void setStem(String stem)
tagmod..
The properties passed are: tagmod.act = mov | add | del tagmod.val = the
tag value used (like v-1_0) tagmod.user = the user which tagged (if known)
tagmod.date = the time string
It is possible to pass an empty string as stem.
public Map getProperties()
The following properties are defined and set by this plug-in:
| Property | Value |
stemtag |
tag value |
stemtagdate |
date (D) field |
stemtaguser |
user (U) field |
stemtagop |
operation (o) field |
The stem is a prefix that can be set via attribute stem to make properties unique.
getProperties in interface SourceControlprotected boolean debugmode()
protected void checkfilestatus()
protected void fetch(Date last,
Date now)
throws Exception
last,
now].
The behavior is undefined, if last is newer than
now.
Exception
public void validate()
throws CruiseControlException
Rather than throwing an exception, this implementation provides a default value for every property. Whether chosen default values are useful is a different story. If a default value is chosen, a warning message is once logged.
The following default values are used:
| Method | plugin's attribute name | value |
|---|---|---|
| setFile(File) | file | tag.log |
| setStem(String) | stem | tagmod. |
| setTagaction(String) | tagaction | add |
| setTagvalue(String) | tagvalue | .*? |
| setProject(String) | project | foo/bar |
validate in interface SourceControlCruiseControlException - in case the underlying parser can not be properly configured.
This is most likely the case if the combined regular
expression is not valid.
public List getModifications(Date last,
Date now)
getModifications in interface SourceControllast - last build timenow - current date
null
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||