Class BuildEnvironment

java.lang.Object
com.iizix.run.common.BuildEnvironment

public class BuildEnvironment extends Object
Class to build up the environment to use.
Author:
Christopher Mindus
  • Field Details

    • isWindows

      public static final boolean isWindows
      Executable extension (".exe" for Windows, "" for the others).
    • isMac

      public static final boolean isMac
    • isLinux

      public static final boolean isLinux
    • isAarch64

      public static final boolean isAarch64
    • isARM64

      public static final boolean isARM64
    • sep

      public static final char sep
    • pathSep

      public static final char pathSep
    • EXE_EXT

      public static final String EXE_EXT
    • BAT_EXT

      public static final String BAT_EXT
    • CMD_EXT

      public static final String CMD_EXT
    • output

      public final File output
      The "output" directory where all programs, etc, build output goes This is normally the "\iiziBuildInstall" directory.
    • homeDir

      public final File homeDir
      The home directory.
    • tempDir

      public final File tempDir
      The temporary directory for downloads, etc.
  • Constructor Details

    • BuildEnvironment

      public BuildEnvironment(File rootDir, boolean doAndroid, boolean doIOS, ICommonJobCreator jobCreator, IPrintAdapter printer) throws IOException
      Constructor verifies presence of required directories.
      Parameters:
      rootDir - The tools root directory where OS directories with Node, NPM, Android, etc, is located, null for default.
      doAndroid - Flag to enable Android building.
      doIOS - Flag to enable iOS building (ignored if not on macOS).
      jobCreator - The job creator interface.
      printer - The printer for output.
      Throws:
      IOException - For I/O errors.
  • Method Details

    • getVersionFromCommand

      public static String getVersionFromCommand(String s)
      Gets the first line of the output that contains a version number from a command line such as e.g. "node -version".
      Parameters:
      s - The String of the result of the program execution stdout.
      Returns:
      The trimmed string as version string, or "n/a?" if not found, a potential prefix of 'v' is skipped.
    • getOutputDirectory

      public File getOutputDirectory()
      Gets the output directory.
    • getExternalProcessEnvironment

      public BuildReply getExternalProcessEnvironment(Map<String,String> returnEnv, boolean logEnvironment)
      Gets the "real" environment to use for processes where some of the original environment is inherited, but "not too much".
      Parameters:
      returnEnv - The environment to use is filled in (not cleared).
      logEnvironment - Logs the environment as informational to the system log.
      Returns:
      The build reply.
    • getJavaEnvironment

      public BuildReply getJavaEnvironment(RuntimeBuilderSettings settings, ICommonJobCreator jobCreator, IPropProgressMonitor monitor, boolean isVerbose) throws IOException
      Retrieves the Java environment.
      Parameters:
      settings - Settings to use if it specified the JDK environment. If null or the JDK settings are not defined, this environment is attempted to be used.
      jobCreator - A job creator, null if not inside Eclipse.
      monitor - A progress monitor that will have 5 ticks taken from it, or null for none.
      isVerbose - The verbose flag.
      Returns:
      The build reply.
      Throws:
      IOException - For I/O errors.
    • initialize

      public BuildReply initialize(boolean isVerbose) throws IOException
      Initializes the environments: Node + NPM, Gradle, Android and Cordova.
      Parameters:
      isVerbose - The verbose flag.
      Returns:
      The build reply.
      Throws:
      IOException - For I/O errors.
    • getVersions

      public BuildReply getVersions(IPropProgressMonitor monitor, IPrintAdapter printer, boolean isVerbose)
      Gets the versions: Node + NPM, Gradle, Android and Cordova. The monitor should be configured for 5 ticks.
      Parameters:
      monitor - The monitor to use, null for non-Eclipse processes.
      printer - The console printer.
      isVerbose - If the job should be verbose or not.
      Returns:
      The build reply.
    • checkAndroidEnvironment

      public BuildReply checkAndroidEnvironment(IPropProgressMonitor monitor, IPrintAdapter printer, boolean isVerbose)
      Checks the Android environment and build tools.

      The progress monitor should be configured to 4 ticks and only be called if Android build is required.

      Parameters:
      monitor - The monitor to use, null for non-Eclipse processes.
      printer - The console printer.
      isVerbose - If the job should be verbose or not.
      Returns:
      The build reply.
    • getInstance

      public static BuildEnvironment getInstance(String rootDirPath, ICommonJobCreator jobCreator, IPropProgressMonitor monitor, IPrintAdapter printer, boolean doAndroid, boolean doIOS, boolean isVerbose) throws IOException
      Constructs the environment from the path specified from the root of the current drive in Windows, or from the HOME directory under Mac or Linux.
      Parameters:
      rootDirPath - If unspecified (null), "iiziBuildInstall" is used, otherwise the path specified. Do not specify the OS such as "windows", "mac" or "linux".
      jobCreator - A job creator, null if not inside Eclipse.
      monitor - A progress monitor that will have 5 ticks taken from it, or null for none.
      printer - A printer for redirected output, null for none.
      doAndroid - Flag to enable building for Android.
      doIOS - Flag to enable building for iOS (ignored if not using macOS).
      isVerbose - If the job should be verbose or not.
      Returns:
      The build environment instance.
      Throws:
      IOException - An IOException for failures.
    • main

      public static void main(String[] args)
      Performs the environment creation for debug purposes.
      Parameters:
      args - The arguments of the command line (ignored).