Skip to content

Commit 489aebd

Browse files
authored
chore: Add experimental API annotation (#3227)
1 parent 5410c35 commit 489aebd

5 files changed

Lines changed: 49 additions & 3 deletions

File tree

annotations/api/annotations.api

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
public abstract interface annotation class com/amplifyframework/annotations/AmplifyFlutterApi : java/lang/annotation/Annotation {
22
}
33

4+
public abstract interface annotation class com/amplifyframework/annotations/ExperimentalAmplifyApi : java/lang/annotation/Annotation {
5+
}
6+
47
public abstract interface annotation class com/amplifyframework/annotations/InternalAmplifyApi : java/lang/annotation/Annotation {
58
}
69

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package com.amplifyframework.annotations
17+
18+
/**
19+
* An API marked with this annotation is experimental. It may be changed or removed in a future release without
20+
* following the standard deprecation cycle.
21+
*
22+
* Any usage of this API must be explicitly opted in with [OptIn] (e.g., `@OptIn(ExperimentalAmplifyApi::class)`) or
23+
* by annotating the consuming declaration with [ExperimentalAmplifyApi].
24+
*/
25+
@MustBeDocumented
26+
@Retention(AnnotationRetention.BINARY)
27+
@Target(
28+
AnnotationTarget.CLASS,
29+
AnnotationTarget.TYPEALIAS,
30+
AnnotationTarget.FUNCTION,
31+
AnnotationTarget.PROPERTY,
32+
AnnotationTarget.FIELD,
33+
AnnotationTarget.CONSTRUCTOR
34+
)
35+
@RequiresOptIn(
36+
level = RequiresOptIn.Level.WARNING,
37+
message = "This API is experimental. It may be changed or removed without notice."
38+
)
39+
annotation class ExperimentalAmplifyApi

build-logic/plugins/src/main/kotlin/KotlinConventionPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class KotlinConventionPlugin : Plugin<Project> {
5656

5757
tasks.withType<KotlinCompile>().configureEach {
5858
compilerOptions {
59-
freeCompilerArgs.addAll(amplifyInternalMarkers.map { "-opt-in=$it" })
59+
freeCompilerArgs.addAll(optInAnnotations.map { "-opt-in=$it" })
6060
freeCompilerArgs.add("-Xconsistent-data-class-copy-visibility")
6161
}
6262
}

build-logic/plugins/src/main/kotlin/KotlinMultiplatformConventionPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
7979
}
8080

8181
compilerOptions {
82-
freeCompilerArgs.addAll(amplifyInternalMarkers.map { "-opt-in=$it" })
82+
freeCompilerArgs.addAll(optInAnnotations.map { "-opt-in=$it" })
8383
freeCompilerArgs.add("-Xconsistent-data-class-copy-visibility")
8484
}
8585
}

build-logic/plugins/src/main/kotlin/Util.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ import org.gradle.kotlin.dsl.getByType
1818
* permissions and limitations under the License.
1919
*/
2020

21-
val amplifyInternalMarkers = listOf(
21+
internal val amplifyInternalMarkers = listOf(
2222
"com.amplifyframework.annotations.InternalApiWarning",
2323
"com.amplifyframework.annotations.InternalAmplifyApi",
2424
"com.amplifyframework.annotations.AmplifyFlutterApi"
2525
)
2626

27+
internal val optInAnnotations = amplifyInternalMarkers + listOf(
28+
"com.amplifyframework.annotations.ExperimentalAmplifyApi"
29+
)
30+
2731
internal val Project.libs
2832
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")

0 commit comments

Comments
 (0)