一键导入
api-lifecycle
// Guidelines and playbooks for managing the API lifecycle (BetaApi, GA, ObsoleteApi, Deprecated, and Removal) in the Google Cloud Java SDK. Use this skill when modifying, deprecating, or introducing new public API surfaces.
// Guidelines and playbooks for managing the API lifecycle (BetaApi, GA, ObsoleteApi, Deprecated, and Removal) in the Google Cloud Java SDK. Use this skill when modifying, deprecating, or introducing new public API surfaces.
| name | api-lifecycle |
| description | Guidelines and playbooks for managing the API lifecycle (BetaApi, GA, ObsoleteApi, Deprecated, and Removal) in the Google Cloud Java SDK. Use this skill when modifying, deprecating, or introducing new public API surfaces. |
This guide defines the lifecycle phases and stability annotations of public APIs inside the Google Cloud Java SDK. Use this to ensure all public methods, classes, and fields correctly adhere to Semantic Versioning (Semver) and safely transition through deprecation phases.
[!IMPORTANT] Scope & Visibility Rule This guideline applies ONLY to public API surfaces (e.g.,
publicclasses, interfaces, methods, and fields) that are exposed to external/downstream consumers. It does NOT apply to private, package-private, or internal implementation details.
To reduce maintenance overhead and ensure long-term flexibility, developers should actively avoid creating public APIs unless absolutely necessary.
private, package-private, or @InternalApi) for new classes, methods, and fields. Only expose an API as public if there is a clear, justified requirement for external consumers.An API does not have to start with @BetaApi. Stable, well-designed features can be introduced directly as General Availability (GA). The @BetaApi annotation is reserved for experimental, preview, or unstable APIs.
Below is the transition flow for public APIs:
Standard Lifecycle (Direct to GA):
General Availability (GA) ──> @ObsoleteApi (Staged Deprecation) ──> @Deprecated (Official) ──> Removed
Experimental Lifecycle (Beta first):
@BetaApi (Experimental) ──> General Availability (GA) ──> @ObsoleteApi (Staged Deprecation) ──> @Deprecated (Official) ──> Removed
@BetaApi (Experimental Phase)@BetaApi, it is intended to eventually graduate to a GA feature by removing the @BetaApi annotation.@BetaApi features inside a public library B that has downstream consumers, unless the consuming components of library B are also marked with @BetaApi.google-cloud-java is allowed to depend on @BetaApi features in gax-java without declaring the consuming code @BetaApi, as they move in lockstep.@ObsoleteApi (Staged Deprecation)@ObsoleteApi("Reason or alternative instructions"). A descriptive reason is required.{@link}.@Deprecated (Official Deprecation)v2.0.0), or in rare emergency cases to fix critical security vulnerabilities. However, it can be acceptable in minor version releases if the library owners explicitly review and determine that the deprecation is low-risk for downstream consumers.@Deprecated annotation to the code element.@deprecated Javadoc tag describing alternative APIs or transition steps.While the standard API Lifecycle Stages section above defines how public APIs transition over time, the SDK also utilizes specialized stability annotations. These annotations serve as "exceptions" or "special contracts" that dictate how Semantic Versioning applies to public elements:
@InternalApipublic because of Java's access modifier limitations, but intended only for internal use.@InternalExtensionOnlypublic interface that is only intended to be implemented by internal SDK classes, though it can be consumed publicly.(Note: For experimental public APIs, see the @BetaApi stage in the Lifecycle Stages section above.)
@Deprecated directly in a minor release. Apply @ObsoleteApi first.@InternalApi so downstream users don't rely on it.@InternalExtensionOnly to protect future extensions.@ObsoleteApi or @Deprecated have a value parameter? The string must explain why and what the user should do instead.{@link #alternativeMethod()} so the user can easily navigate in their IDE.