org.apache.tools.ant.taskdefs.optional.perforce

## Class P4Base

- java.lang.Object
- - org.apache.tools.ant.ProjectComponent
  - - org.apache.tools.ant.Task
    - - org.apache.tools.ant.taskdefs.optional.perforce.P4Base

- All Implemented Interfaces:
    java.lang.Cloneable
  Direct Known Subclasses:
    P4Add, P4Change, P4Counter, P4Delete, P4Edit, P4Fstat, P4Have, P4Integrate, P4Label, P4Labelsync, P4Reopen, P4Resolve, P4Revert, P4Submit, P4Sync

      public abstract class P4Base
      extends Task

  Base class for Perforce (P4) ANT tasks. See individual task for example usage.
  See Also:
    `P4Sync`, `P4Have`, `P4Change`, `P4Edit`, `P4Submit`, `P4Label`, `Execute`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `failOnError` Keep going or fail on error - defaults to fail.
    `protected java.lang.String` | `P4Client` Perforce Client (eg myclientspec)
    `protected java.lang.String` | `P4CmdOpts` Perforce command opts.
    `protected java.lang.String` | `P4Opts` Perforce 'global' opts.
    `protected java.lang.String` | `P4Port` Perforce Server Port (eg KM01:1666)
    `protected java.lang.String` | `P4User` Perforce User (eg fbloggs)
    `protected java.lang.String` | `P4View` Perforce view for commands.
    `protected java.lang.String` | `shell` The OS shell to use (cmd.exe or /bin/sh)
    `protected org.apache.oro.text.perl.Perl5Util` | `util` Perl5 regexp in Java - cool eh?

    - ### Fields inherited from class org.apache.tools.ant.Task

      `target, taskName, taskType, wrapper`

    - ### Fields inherited from class org.apache.tools.ant.ProjectComponent

      `description, location, project`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `P4Base()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `execP4Command(java.lang.String command)` no usages found for this method runs a Perforce command without a handler
    `protected void` | `execP4Command(java.lang.String command, P4Handler handler)` Execute P4 command assembled by subclasses.
    `java.lang.String` | `getErrorMessage()` gets the error message recorded by the Perforce handler
    `boolean` | `getInError()` gets whether or not the task has encountered an error
    `void` | `init()` sets attributes Port, Client, User from properties if these properties are defined.
    `void` | `setClient(java.lang.String p4Client)` The p4 client spec to use; optional, defaults to the current user
    `void` | `setCmdopts(java.lang.String p4CmdOpts)` Set extra command options; only used on some of the Perforce tasks.
    `void` | `setErrorMessage(java.lang.String errorMessage)` sets the error message
    `void` | `setFailonerror(boolean fail)` whether to stop the build (true, default) or keep going if an error is returned from the p4 command
    `void` | `setGlobalopts(java.lang.String p4Opts)` Set global P4 options; Used on all of the Perforce tasks.
    `void` | `setInError(boolean inError)` sets the error flag on the task
    `void` | `setPort(java.lang.String p4Port)` The p4d server and port to connect to; optional, default "perforce:1666"
    `void` | `setUser(java.lang.String p4User)` The p4 username; optional, defaults to the current user
    `void` | `setView(java.lang.String p4View)` The client, branch or label view to operate upon; optional default "//...".

    - ### Methods inherited from class org.apache.tools.ant.Task

      `bindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`

    - ### Methods inherited from class org.apache.tools.ant.ProjectComponent

      `clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### util

          protected org.apache.oro.text.perl.Perl5Util util

      Perl5 regexp in Java - cool eh?

    - #### shell

          protected java.lang.String shell

      The OS shell to use (cmd.exe or /bin/sh)

    - #### P4Port

          protected java.lang.String P4Port

      Perforce Server Port (eg KM01:1666)

    - #### P4Client

          protected java.lang.String P4Client

      Perforce Client (eg myclientspec)

    - #### P4User

          protected java.lang.String P4User

      Perforce User (eg fbloggs)

    - #### P4View

          protected java.lang.String P4View

      Perforce view for commands. (eg //projects/foobar/main/source/... )

    - #### failOnError

          protected boolean failOnError

      Keep going or fail on error - defaults to fail.

    - #### P4Opts

          protected java.lang.String P4Opts

      Perforce 'global' opts. Forms half of low level API

    - #### P4CmdOpts

          protected java.lang.String P4CmdOpts

      Perforce command opts. Forms half of low level API

  - ### Constructor Detail

    - #### P4Base

          public P4Base()

  - ### Method Detail

    - #### getInError

          public boolean getInError()

      gets whether or not the task has encountered an error
      Returns:
        error flag
      Since:
        ant 1.6

    - #### setInError

          public void setInError(boolean inError)

      sets the error flag on the task
      Parameters:
        `inError` - if true an error has been encountered by the handler
      Since:
        ant 1.6

    - #### getErrorMessage

          public java.lang.String getErrorMessage()

      gets the error message recorded by the Perforce handler
      Returns:
        error message

    - #### setErrorMessage

          public void setErrorMessage(java.lang.String errorMessage)

      sets the error message
      Parameters:
        `errorMessage` - line of error output

    - #### setPort

          public void setPort(java.lang.String p4Port)

      The p4d server and port to connect to; optional, default "perforce:1666"
      Parameters:
        `p4Port` - the port one wants to set such as localhost:1666

    - #### setClient

          public void setClient(java.lang.String p4Client)

      The p4 client spec to use; optional, defaults to the current user
      Parameters:
        `p4Client` - the name of the Perforce client spec

    - #### setUser

          public void setUser(java.lang.String p4User)

      The p4 username; optional, defaults to the current user
      Parameters:
        `p4User` - the user name

    - #### setGlobalopts

          public void setGlobalopts(java.lang.String p4Opts)

      Set global P4 options; Used on all of the Perforce tasks.
      Parameters:
        `p4Opts` - global options, to use a specific P4Config file for instance

    - #### setView

          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
      Parameters:
        `p4View` - the view one wants to use

    - #### setCmdopts

          public void setCmdopts(java.lang.String p4CmdOpts)

      Set extra command options; only used on some of the Perforce tasks.
      Parameters:
        `p4CmdOpts` - command line options going after the particular Perforce command

    - #### setFailonerror

          public void setFailonerror(boolean fail)

      whether to stop the build (true, default) or keep going if an error is returned from the p4 command
      Parameters:
        `fail` - indicates whether one wants to fail the build if an error comes from the Perforce command

    - #### init

          public void init()

      sets attributes Port, Client, User from properties if these properties are defined. Called automatically by UnknownElement
      Overrides:
        `init` in class `Task`
      See Also:
        `

        Property | Attribute
        --- | ---
        p4.port | Port
        p4.client | Client
        p4.user | User

        `

    - #### execP4Command

          protected void execP4Command(java.lang.String command)
                                throws BuildException

      no usages found for this method runs a Perforce command without a handler
      Parameters:
        `command` - the command that one wants to execute
      Throws:
        `BuildException` - if failonerror is set and the command fails

    - #### execP4Command

          protected void execP4Command(java.lang.String command,
                           P4Handler handler)
                                throws BuildException

      Execute P4 command assembled by subclasses.
      Parameters:
        `command` - The command to run
        `handler` - A P4Handler to process any input and output
      Throws:
        `BuildException` - if failonerror has been set to true