Fields Summary |
---|
protected org.apache.oro.text.perl.Perl5Util | utilPerl5 regexp in Java - cool eh? |
protected String | shellThe OS shell to use (cmd.exe or /bin/sh) |
protected String | P4PortPerforce Server Port (eg KM01:1666) |
protected String | P4ClientPerforce Client (eg myclientspec) |
protected String | P4UserPerforce User (eg fbloggs) |
protected String | P4ViewPerforce view for commands. (eg //projects/foobar/main/source/... ) |
protected boolean | failOnErrorKeep going or fail on error - defaults to fail. |
protected String | P4OptsPerforce 'global' opts.
Forms half of low level API |
protected String | P4CmdOptsPerforce command opts.
Forms half of low level API |
private boolean | inErrorSet by the task or a handler to indicate that the task has failed. BuildExceptions
can also be thrown to indicate failure. |
private String | errorMessageIf inError is set, then errorMessage needs to contain the reason why. |
Methods Summary |
---|
protected void | execP4Command(java.lang.String command)no usages found for this method
runs a Perforce command without a handler
execP4Command(command, null);
|
protected void | execP4Command(java.lang.String command, P4Handler handler)Execute P4 command assembled by subclasses.
try {
// reset error flags before executing the command
inError = false;
errorMessage = "";
Commandline commandline = new Commandline();
commandline.setExecutable("p4");
//Check API for these - it's how CVS does it...
if (P4Port != null && P4Port.length() != 0) {
commandline.createArgument().setValue(P4Port);
}
if (P4User != null && P4User.length() != 0) {
commandline.createArgument().setValue(P4User);
}
if (P4Client != null && P4Client.length() != 0) {
commandline.createArgument().setValue(P4Client);
}
if (P4Opts != null && P4Opts.length() != 0) {
commandline.createArgument().setLine(P4Opts);
}
commandline.createArgument().setLine(command);
log(commandline.describeCommand(), Project.MSG_VERBOSE);
if (handler == null) {
handler = new SimpleP4OutputHandler(this);
}
Execute exe = new Execute(handler, null);
exe.setAntRun(getProject());
exe.setCommandline(commandline.getCommandline());
try {
exe.execute();
if (inError && failOnError) {
throw new BuildException(errorMessage);
}
} catch (IOException e) {
throw new BuildException(e);
} finally {
try {
handler.stop();
} catch (Exception e) {
log(e.toString(), Project.MSG_ERR);
}
}
} catch (Exception e) {
String failMsg = "Problem exec'ing P4 command: " + e.getMessage();
if (failOnError) {
throw new BuildException(failMsg);
} else {
log(failMsg, Project.MSG_ERR);
}
}
|
public java.lang.String | getErrorMessage()gets the error message recorded by the Perforce handler
return errorMessage;
|
public boolean | getInError()gets whether or not the task has encountered an error
// CheckStyle:MemberNameCheck ON
// CheckStyle:VisibilityModifier ON
return inError;
|
public void | init()sets attributes Port, Client, User from properties
if these properties are defined.
Called automatically by UnknownElement
util = new Perl5Util();
//Get default P4 settings from environment - Mark would have done something cool with
//introspection here.....:-)
String tmpprop;
if ((tmpprop = getProject().getProperty("p4.port")) != null) {
setPort(tmpprop);
}
if ((tmpprop = getProject().getProperty("p4.client")) != null) {
setClient(tmpprop);
}
if ((tmpprop = getProject().getProperty("p4.user")) != null) {
setUser(tmpprop);
}
|
public void | setClient(java.lang.String p4Client)The p4 client spec to use;
optional, defaults to the current user
this.P4Client = "-c" + p4Client;
|
public void | setCmdopts(java.lang.String p4CmdOpts)Set extra command options; only used on some
of the Perforce tasks.
this.P4CmdOpts = p4CmdOpts;
|
public void | setErrorMessage(java.lang.String errorMessage)sets the error message
this.errorMessage = errorMessage;
|
public void | setFailonerror(boolean fail)whether to stop the build (true, default)
or keep going if an error is returned from the p4 command
failOnError = fail;
|
public void | setGlobalopts(java.lang.String p4Opts)Set global P4 options; Used on all
of the Perforce tasks.
this.P4Opts = p4Opts;
|
public void | setInError(boolean inError)sets the error flag on the task
this.inError = inError;
|
public void | setPort(java.lang.String p4Port)The p4d server and port to connect to;
optional, default "perforce:1666"
this.P4Port = "-p" + p4Port;
|
public void | setUser(java.lang.String p4User)The p4 username;
optional, defaults to the current user
this.P4User = "-u" + p4User;
|
public void | setView(java.lang.String p4View)The client, branch or label view to operate upon;
optional default "//...".
the view is required for the following tasks :
- p4delete
- p4edit
- p4reopen
- p4resolve
this.P4View = p4View;
|