Class CommonJobs

  • All Implemented Interfaces:
    ICommonJobs

    public class CommonJobs
    extends java.lang.Object
    implements ICommonJobs
    Class implementing common jobs in a non-Eclipse environment. The CommonBuilder variables can be tested for OS, etc.
    Author:
    Christopher Mindus
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voiddestroyProcess()
      Destroys a potentially executing process.
      voiddownloadExtractArchive​(java.io.File jarExe, java.io.File tempDir, java.lang.String url, java.io.File dest)
      Creates a temporary folder and downloads and extracts an archive file that contains a single directory with some name.
      voiddownloadFile​(java.lang.String webFile, java.io.File destFile)
      Download a file using HTTP.
      intexec​(boolean showOutput, java.lang.String echo, java.io.File dir, java.util.Map<java.lang.String,​java.lang.String> env, java.lang.StringBuilder output, java.lang.String... commands)
      Executes a short command, typically for testing.
      voidextractArchive​(java.io.File jarExe, java.io.File archive, java.io.File dest, boolean deleteArchive)
      Extracts a Zip or Jar file.
      • Methods inherited from class java.lang.Object

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

      • CommonJobs

        public CommonJobs​(IPropProgressMonitor monitor,
                          boolean isVerbose)
        Constructor.
        Parameters:
        monitor - The progress monitor.
        isVerbose - The verbose flag.
      • CommonJobs

        public CommonJobs​(IPropProgressMonitor monitor,
                          IPrintAdapter printer,
                          boolean isVerbose)
        Constructor.
        Parameters:
        monitor - The progress monitor.
        printer - The printer for output.
        isVerbose - The verbose flag.
    • Method Detail

      • destroyProcess

        public void destroyProcess()
        Destroys a potentially executing process.
        Specified by:
        destroyProcess in interface ICommonJobs
      • downloadFile

        public void downloadFile​(java.lang.String webFile,
                                 java.io.File destFile)
                          throws java.io.IOException,
                                 java.lang.InterruptedException
        Download a file using HTTP.
        Specified by:
        downloadFile in interface ICommonJobs
        Parameters:
        webFile - The web file using HTTP.
        destFile - The local file system file where to place it.
        Throws:
        java.io.IOException - For errors.
        java.lang.InterruptedException - If the process is interrupted.
      • extractArchive

        public void extractArchive​(java.io.File jarExe,
                                   java.io.File archive,
                                   java.io.File dest,
                                   boolean deleteArchive)
                            throws java.io.IOException,
                                   java.lang.InterruptedException
        Extracts a Zip or Jar file.
        Specified by:
        extractArchive in interface ICommonJobs
        Parameters:
        jarExe - The Jar executable.
        archive - The file to extract.
        dest - The directory to place the extracted files in.
        deleteArchive - Flag to delete the archive.
        Throws:
        java.io.IOException - For errors.
        java.lang.InterruptedException - If the process is interrupted.
      • downloadExtractArchive

        public void downloadExtractArchive​(java.io.File jarExe,
                                           java.io.File tempDir,
                                           java.lang.String url,
                                           java.io.File dest)
                                    throws java.io.IOException,
                                           java.lang.InterruptedException
        Creates a temporary folder and downloads and extracts an archive file that contains a single directory with some name. This directory is then moved to the requested location and renamed.
        Specified by:
        downloadExtractArchive in interface ICommonJobs
        Parameters:
        jarExe - The Jar executable: if null, Java code will be used instead (also applies for ".tar" and ".tar.gz" file extensions.
        tempDir - The temporary directory.
        url - The archive file's URL to download.
        dest - The destination directory.
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • exec

        public int exec​(boolean showOutput,
                        java.lang.String echo,
                        java.io.File dir,
                        java.util.Map<java.lang.String,​java.lang.String> env,
                        java.lang.StringBuilder output,
                        java.lang.String... commands)
                 throws java.io.IOException,
                        java.lang.InterruptedException
        Executes a short command, typically for testing.
        Specified by:
        exec in interface ICommonJobs
        Parameters:
        showOutput - Shows the output of the process.
        echo - If non-null, what is placed in the output stream.
        dir - Current directory for the process.
        env - The environment to use, null for default.
        output - The StringBuilder that is filled with the output from the process.
        commands - Commands to execute.
        Returns:
        The return value.
        Throws:
        java.io.IOException - For errors.
        java.lang.InterruptedException - If the process is interrupted.