Class JavaVersionSupportDefiner

java.lang.Object
com.atlassian.bamboo.upgrade.tasks.validation.JavaVersionSupportDefiner

public class JavaVersionSupportDefiner extends Object
This class defines the supported Java versions based on the Bamboo version. This isolates the logic for defining supported versions from the rest of the application, making it easier to update in the future.
  • Method Details

    • defineSupportedJavaVersion

      public static void defineSupportedJavaVersion(String bambooVersion)
      Defines the supported Java versions based on the provided Bamboo version. The Bamboo version is compared against known versions to determine the supported Java versions. If the Bamboo version is greater than the highest known version, the rules of the highest known version will apply. This method will need to be updated any time we support a new Java version.
      Parameters:
      bambooVersion - the Bamboo version, as a string
    • parseBambooVersion

      public static Version parseBambooVersion(String versionString)
      Parses a Bamboo version string into a Version object. The version string should be in a format like "1.2.3", "1.2.3-SNAPSHOT", or similar, where each part separated by a dot represents a major, minor, or micro version. The method also handles version strings that contain non-numeric characters, such as "SNAPSHOT", which are removed before parsing. This method is designed to filter versions such as "9.4.0-SNAPSHOT", removing the "SNAPSHOT" part and parsing only the numeric version parts. The returned Version object contains the major version at index 0, the minor version at index 1, and the micro version at index 2.
      Parameters:
      versionString - - String representation of the Bamboo version
      Returns:
      Version object representing the Bamboo version
    • getSupportedJavaVersions

      public static List<Version> getSupportedJavaVersions()
      Returns the list of supported Java versions. The list is defined by the defineSupportedJavaVersion method.
      Returns:
      a list of supported Java versions
    • getFormattedSupportedJavaVersion

      public static String getFormattedSupportedJavaVersion()
      Returns a formatted string of the supported Java versions. The format is as follows: - If only one Java version is supported, it returns the Java version - If more than one Java is supported, it returns a comma-separated list with "or" before the last version - On Java 8 the version is displayed as "1.8.0_XX"; Java versions 11 and above, the version is displayed as "XX"
      Returns:
      a formatted string of the supported Java versions to be shown in the UI