Class JavaVersionIsSupported
- java.lang.Object
-
- com.atlassian.bamboo.upgrade.AbstractUpgradeTask
-
- com.atlassian.bamboo.upgrade.AbstractBootstrapUpgradeTask
-
- com.atlassian.bamboo.upgrade.tasks.validation.JavaVersionIsSupported
-
- All Implemented Interfaces:
BootstrapUpgradeTask
,UpgradeTask
@Component public class JavaVersionIsSupported extends AbstractBootstrapUpgradeTask
-
-
Field Summary
Fields Modifier and Type Field Description static String
UNSUPPORTED_JAVA_ERROR
-
Fields inherited from class com.atlassian.bamboo.upgrade.AbstractBootstrapUpgradeTask
bootstrapManager, hibernateConfig
-
Fields inherited from class com.atlassian.bamboo.upgrade.AbstractUpgradeTask
errors
-
-
Constructor Summary
Constructors Constructor Description JavaVersionIsSupported()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doUpgrade()
Checks if the current Java version is compatible with Bamboo.protected String
getBambooVersion()
protected String
getJavaVersion()
protected boolean
isFunctionalTest()
protected boolean
isJavaVersionCheckDisabled()
boolean
isJavaVersionSupported()
Checks if a given Java version is supported by Bamboo.static Version
parseJavaVersion(String[] version)
Parses an array representation of a Java version into a Version object.static String[]
parseVersionArray(String version)
Parses a Java version string into an array representation.-
Methods inherited from class com.atlassian.bamboo.upgrade.AbstractBootstrapUpgradeTask
getDatabaseConnection, getDialect, setBootstrapManager, setHibernateConfig, withDatabaseConnection
-
Methods inherited from class com.atlassian.bamboo.upgrade.AbstractUpgradeTask
getBuildNumber, getErrors, getShortDescription
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.upgrade.UpgradeTask
getBuildNumber, getErrors, getShortDescription
-
-
-
-
Field Detail
-
UNSUPPORTED_JAVA_ERROR
public static final String UNSUPPORTED_JAVA_ERROR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getJavaVersion
protected String getJavaVersion()
-
getBambooVersion
protected String getBambooVersion()
-
isFunctionalTest
protected boolean isFunctionalTest()
-
isJavaVersionCheckDisabled
protected boolean isJavaVersionCheckDisabled()
-
doUpgrade
public void doUpgrade() throws ValidationException
Checks if the current Java version is compatible with Bamboo. This method first checks if the application is running a functional test or if the Java version check is disabled. If neither of these conditions is true, it parses the current Java version and checks if it is supported by Bamboo. If the Java version is not supported, it throws a ValidationException.- Throws:
ValidationException
- if the current Java version is not supported by Bamboo
-
isJavaVersionSupported
public boolean isJavaVersionSupported()
Checks if a given Java version is supported by Bamboo. This method compares the major, minor, and micro versions of the given Java version with the supported Java versions. It returns true if the given version is equal to or higher than a supported version, and false otherwise.- Returns:
- true if the Java version is supported, false otherwise
-
parseVersionArray
public static String[] parseVersionArray(String version)
Parses a Java version string into an array representation. The version string should be in a format like "1.8.0_232", "11.0.2", or "9.1.2+123". The returned array contains the major version at index 0, the minor version at index 1, and the micro version at index 2. For Java 8 versions (like "1.8.0_232"), the part after the underscore is considered as part of the minor version. For non-Java 8 versions (like "11.0.2" or "9.1.2+123"), the third part of the version string is considered as the micro version. If the version string does not contain a micro version, "0" is used by default.- Parameters:
version
- - Java version- Returns:
- array representation of Java version, eg: "1.8.0_232" -> ["1", "8232", "0"] "11.0.2" -> ["11", "0", "2"] "13-ea" -> ["13", "0", "0"]
-
parseJavaVersion
public static Version parseJavaVersion(String[] version)
Parses an array representation of a Java version into a Version object. The array should have the major version at index 0, the minor version at index 1, and the micro version at index 2. The micro version is considered for all Java versions.- Parameters:
version
- - array representation of Java version, eg: "1.8.0_212" -> ["1", "8", "212"] "11.0.2" -> ["11", "0", "2"] "13-ea" -> ["13", "0", "0"]- Returns:
- parsedVersion - Parsed Version object
-
-