Skip to content

Migration Guide: Version 1 to Version 2

Tim Ortel edited this page Mar 7, 2026 · 1 revision

This guide outlines the breaking changes and new configuration options introduced in version 2.0.0.


⚠️ Breaking Changes

1. New Reserved Field Names

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.


2. Enums as Sealed Interfaces

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.

3. Outer Proto Class is now an object

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.

⚙️ Naming Strategy Configuration

Version 2 introduces the NamingStrategy configuration option. This defines the naming convention for generated classes and properties.

Available Strategies

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.

Configuration Example

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.