-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin ABI checks #919
base: main
Are you sure you want to change the base?
Kotlin ABI checks #919
Conversation
5f9dd4b
to
084ebbd
Compare
084ebbd
to
dd85a2d
Compare
Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
dd85a2d
to
7058067
Compare
apiValidation { | ||
ignoredProjects += listOf("bench", "docs") | ||
nonPublicMarkers += "org.pkl.commons.annotations.PklExperimental" | ||
|
||
@OptIn(kotlinx.validation.ExperimentalBCVApi::class) klib { enabled = true } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best to configure this plugin in the root build.gradle.kts
, because then projects can be ignored by name. I've enabled experimental KLib validation since Pkl is well past the minimum of 1.9.20
.
/** | ||
* Marks experimental APIs in Kotlin or Java. Such APIs may be publicly exposed by the Pkl project, | ||
* but are not provided with a stability guarantee, and require opt-in use from Kotlin. | ||
*/ | ||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING) | ||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class PklExperimental |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this annotation is added as an escape hatch for public API pins. it can be used like this:
@PklExperimental
public class SomeClass {
// ...
}
Then, in user code:
@OptIn(PklExperimental::class)
fun someUserFunction {
// usage of an experimental type
val x = SomeClass()
}
Omission of the @OptIn
generates a compile-time warning, and any type annotated with @PklExperimental
is omitted from API pins.
Summary
Kotlin ABI Check: Checks Kotlin public library symbols for drift. Run
apiCheck
to make sure a change does not break downstream Java/Kotlin library consumers; runapiDump
to re-seal public API lockfiles.Initial API lockfiles were generated as well.
apiCheck
runs on./gradlew check
by default, preventing downstream API/ABI breakage when Pkl is used as a Maven library.PklExperimental
annotation for opt-out of API pinningPklExperimental
as Kotlin opt-in