Browse Source

Add failOnError attribute (submitted by Steven Tamm -- PR #7549).

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272072 13f79535-47bb-0310-9956-ffa450edef68
master
Diane Holt 23 years ago
parent
commit
16a57441b2
1 changed files with 18 additions and 1 deletions
  1. +18
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java

+ 18
- 1
src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java View File

@@ -95,6 +95,10 @@ public abstract class P4Base extends org.apache.tools.ant.Task {
/** Perforce view for commands. (eg //projects/foobar/main/source/... )*/ /** Perforce view for commands. (eg //projects/foobar/main/source/... )*/
protected String P4View = ""; protected String P4View = "";


// Perforce task directives
/** Keep going or fail on error - defaults to fail. */
protected boolean failOnError = true;

//P4 g-opts and cmd opts (rtfm) //P4 g-opts and cmd opts (rtfm)
/** Perforce 'global' opts. /** Perforce 'global' opts.
* Forms half of low level API */ * Forms half of low level API */
@@ -124,6 +128,13 @@ public abstract class P4Base extends org.apache.tools.ant.Task {
this.P4CmdOpts = P4CmdOpts; this.P4CmdOpts = P4CmdOpts;
} }


/**
* Optionally throw a BuildException if p4 command fails
*/
public void setFailonerror(boolean fail) {
failOnError = fail;
}

public void init() { public void init() {


util = new Perl5Util(); util = new Perl5Util();
@@ -201,7 +212,13 @@ public abstract class P4Base extends org.apache.tools.ant.Task {




} catch (Exception e) { } catch (Exception e) {
throw new BuildException("Problem exec'ing P4 command: " + e.getMessage());
String failMsg = "Problem exec'ing P4 command: " + e.getMessage();
if (failOnError) {
throw new BuildException(failMsg);
} else {
log(failMsg, Project.MSG_ERR);
}

} }
} }
} }

Loading…
Cancel
Save