-
Notifications
You must be signed in to change notification settings - Fork 28
Migration Guide: Version 1 to Version 2
This guide outlines the breaking changes and new configuration options introduced in version 2.0.0.
The following names are now reserved by the internal library runtime to avoid naming collisions with generated helper properties.
enumNumberValue_enumValue_isInitialized
If your proto files use them, your declarations will be slighly renamed to avoid conflict.
To allow for better extensibility and "Unknown" value handling, Enums are no longer generated as standard Kotlin enum class. They are now generated as Sealed Interfaces.
The Kotlin class generated to represent the outer .proto file (containing nested messages, enums and extensions) has been changed from a class to a Kotlin object.
Version 2 introduces the NamingStrategy configuration option. This defines the naming convention for generated classes and properties.
| Strategy | Description |
|---|---|
KOTLIN_IDIOMATIC |
Default. Transforms names to match Kotlin conventions (e.g., snake_case becomes camelCase). Messages use PascalCase. |
PROTO_LITERAL |
Keeps names exactly as they are defined in the .proto source files without any modifications. |
LEGACY |
Matches the behavior of Version 1. Keeps original .proto names but appends List and Map suffixes where applicable. |
Update your build.gradle.kts to select your preferred strategy:
grpcLibrary {
// If you want to preserve the old v1 behavior:
namingStrategy = NamingStrategy.LEGACY
// Recommended for new projects:
// namingStrategy = NamingStrategy.KOTLIN_IDIOMATIC
}Important
Well Known Types (WKTs): If your project uses Well Known Types (e.g., google.protobuf.Timestamp), you must use NamingStrategy.KOTLIN_IDIOMATIC. The LEGACY strategy is incompatible with WKT support in v2.