AndroidPluginVersion

public final class AndroidPluginVersion implements Comparable


Represents a version of the Android Gradle Plugin

Designed for plugin authors to compare the currently running plugin version, so implements comparable.

For example AndroidPluginVersion(7, 0) refers to Android Gradle Plugin version 7.0.0, and AndroidPluginVersion(7, 0, 1) refers to Android Gradle Plugin version 7.0.1.

The internal representation is normalized, so that AndroidPluginVersion(7, 0) equals AndroidPluginVersion(7, 0, 0)

Also supports preview versions through methods alpha, beta and rc that return the more specific version. For example AndroidPluginVersion(7, 0).alpha(5) refers to Android Gradle Plugin version 7.0.0-alpha05. This is for use when developing using incubating APIs that have changed between preview releases of the Android Gradle Plugin. Once those APIs are stable in a stable version of Android Gradle Plugin, it's recommended to drop support for the preview versions. For example, if a new API was introduced in 7.0.0-alpha05, you can test for that using

``if (androidComponents.pluginVersion >= AndroidPluginVersion(7.0).alpha(5)) { ... }``

If that API is marked as stable in 7.0.0, drop support for the preview versions before it by updating your condition to:

``if (androidComponents.pluginVersion >= AndroidPluginVersion(7.0)) { ... }``

Summary

Public constructors

AndroidPluginVersion(int major, int minor)

Create an AndroidPluginVersion with the given major and minor version.

AndroidPluginVersion(int major, int minor, int micro)

Create an AndroidPluginVersion with the given major, minor and micro version.

Public methods

final @NonNull AndroidPluginVersion
alpha(int alpha)

From a stable AndroidPluginVersion returns an alpha version.

final @NonNull AndroidPluginVersion
beta(int beta)

From a stable AndroidPluginVersion returns a beta version.

int
final @NonNull AndroidPluginVersion

From a stable AndroidPluginVersion specify an internal development version.

boolean
equals(Object other)
final int

The major version.

final int

The micro, or patch version.

final int

The minor version.

final int

The preview version.

final String

The type of preview version.

int
final @NonNull AndroidPluginVersion
rc(int rc)

From a stable AndroidPluginVersion returns a release candidate version.

@NonNull String

Public constructors

AndroidPluginVersion

public AndroidPluginVersion(int major, int minor)

Create an AndroidPluginVersion with the given major and minor version.

For example AndroidPluginVersion(7, 0) refers to Android Gradle Plugin version 7.0.0.

AndroidPluginVersion

public AndroidPluginVersion(int major, int minor, int micro)

Create an AndroidPluginVersion with the given major, minor and micro version.

For example AndroidPluginVersion(7, 0, 1) refers to Android Gradle Plugin version 7.0.1.

Public methods

alpha

public final @NonNull AndroidPluginVersion alpha(int alpha)

From a stable AndroidPluginVersion returns an alpha version.

For example AndroidPluginVersion(7, 0).alpha(5) refers to Android Gradle Plugin version 7.0.0-alpha05.

beta

public final @NonNull AndroidPluginVersion beta(int beta)

From a stable AndroidPluginVersion returns a beta version.

For example AndroidPluginVersion(7, 0).beta(2) refers to Android Gradle Plugin version 7.0.0-beta02.

compareTo

public int compareTo(@NonNull AndroidPluginVersion other)

dev

@Incubating
public final @NonNull AndroidPluginVersion dev()

From a stable AndroidPluginVersion specify an internal development version.

-dev versions are never publicly released, but this can be useful if you are building the Android Gradle Plugin from source.

For example AndroidPluginVersion(7, 0).dev() refers to Android Gradle Plugin version 7.0.0-dev.

equals

public boolean equals(Object other)

getMajor

public final int getMajor()

The major version.

e.g. 7 for Android Gradle Plugin Version 7.0.1

getMicro

public final int getMicro()

The micro, or patch version.

e.g. 1 for Android Gradle Plugin Version 7.0.1

getMinor

public final int getMinor()

The minor version.

e.g. 0 for Android Gradle Plugin Version 7.0.1

getPreview

public final int getPreview()

The preview version.

e.g. 5 for Android Gradle Plugin Version 7.0.0-alpha05

getPreviewType

public final String getPreviewType()

The type of preview version.

Null in the case of a stable version. One of 'alpha', 'beta', 'rc', 'dev' for preview versions.

e.g. 'alpha' for Android Gradle Plugin Version 7.0.0-alpha05

hashCode

public int hashCode()

rc

public final @NonNull AndroidPluginVersion rc(int rc)

From a stable AndroidPluginVersion returns a release candidate version.

For example AndroidPluginVersion(7, 0).rc(1) refers to Android Gradle Plugin version 7.0.0-rc01.

toString

public @NonNull String toString()