Class AbstractTask


  • public abstract class AbstractTask
    extends java.lang.Object
    AbstractTask is the base class for all zBuilder provided tasks and custom tasks.

    Coding a custom task in Java:

    
     public class CustomTask extends AbstractTask {
        public CustomTask(BuildContext context, TaskVariables config) {
            super(context, config);
        }
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.lang.Integer execute()
      Execute the task
      BuildGroup getBuildGroup()
      Retrieves the common Build Group or null if there is no match.
      BuildResult getBuildResult()
      Retrieves the common Build Result or null if there is no match.
      org.apache.commons.cli.CommandLine getCommandLine()
      Retrieves the common Command Line or null if there is no match.
      void verifyRequiredContextVariable​(java.lang.Object value, java.lang.String key)
      Throw a missing task variable error if the value is null
      void verifyRequiredOption​(java.lang.Object value, org.apache.commons.cli.Option option)
      Throw a missing CLI option error if the value is null
      void verifyRequiredVariable​(java.lang.Object value, java.lang.String key)
      Throw a missing task variable error if the value is null
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractTask

        public AbstractTask​(BuildContext context,
                            TaskVariables config)
        Construct a new AbstractTask.
        Parameters:
        context - The BuildContext used to pass and receive data between tasks.
        config - The TaskVariables containing the configuration of the task.
    • Method Detail

      • execute

        public abstract java.lang.Integer execute()
                                           throws java.lang.Exception
        Execute the task
        Returns:
        Returns 0 on clean execution, or 1 if one or more steps return non-zero exit codes
        Throws:
        java.lang.Exception - on task execution error
      • verifyRequiredVariable

        public void verifyRequiredVariable​(java.lang.Object value,
                                           java.lang.String key)
                                    throws BuildException
        Throw a missing task variable error if the value is null
        Parameters:
        value - Object retrieved from any configuration variables
        key - of the required variable
        Throws:
        BuildException - if the value is null
      • verifyRequiredContextVariable

        public void verifyRequiredContextVariable​(java.lang.Object value,
                                                  java.lang.String key)
                                           throws BuildException
        Throw a missing task variable error if the value is null
        Parameters:
        value - Object retrieved from a BuildContext object
        key - of the required variable
        Throws:
        BuildException - if the value is null
      • verifyRequiredOption

        public void verifyRequiredOption​(java.lang.Object value,
                                         org.apache.commons.cli.Option option)
                                  throws BuildException
        Throw a missing CLI option error if the value is null
        Parameters:
        value - Object retrieved from command line option
        key - of the required command line option
        Throws:
        BuildException - if the value is null
      • getCommandLine

        public org.apache.commons.cli.CommandLine getCommandLine()
                                                          throws BuildException
        Retrieves the common Command Line or null if there is no match.
        Returns:
        CommandLine or null if no match is found.
        Throws:
        BuildException - if the typecast fails
      • getBuildGroup

        public BuildGroup getBuildGroup()
                                 throws BuildException
        Retrieves the common Build Group or null if there is no match.
        Returns:
        BuildGroup or null if no match is found.
        Throws:
        BuildException - if the typecast fails
      • getBuildResult

        public BuildResult getBuildResult()
                                   throws BuildException
        Retrieves the common Build Result or null if there is no match.
        Returns:
        BuildResult or null if no match is found.
        Throws:
        BuildException - if the typecast fails