All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.14.3 - Unreleased
0.14.2 - 2022-11-18
- Added ability to override the Kotlin package name for multiple packages by using a wildcard with the
kotlin_package_mapping
parameter toprotoc-gen-pbandk
. See the README for an example. (PR #232, fixes #230) (thanks @Dogacel)
- Fixed JSON serialization of default values. (PR #238, fixes #235) (thanks @antongrbin)
- Fields with explicit presence (such as proto2
optional
fields) are no longer included in the JSON output when their value isnull
. - Fields with explicit presence are included in the JSON output when they contain the default value (e.g. an
optional int32
field with a value of0
). - Message fields with a
null
value are no longer included in the JSON output even ifJsonConfig.outputDefaultValues=true
. Only non-null default values are supposed to be output whenoutputDefaultValues=true
.
- Fields with explicit presence (such as proto2
- The generated code for a protobuf message named
Sequence
will no longer cause a compiler error. (PR #241, fixes #237)
0.14.1 - 2022-06-04
Message.encodeDelimitedToStream()
andMessage.Companion.decodeDelimitedFromStream()
: these methods allow writing/reading multiple length-delimited messages to/from a single JavaOutputStream
/InputStream
. They are compatible with the encoding used byprotobuf-java
'swriteDelimitedTo()
andparseDelimitedFrom()
/mergeDelimitedFrom()
methods. (PR #213) (thanks @JohnLCaron)
- Fixed compile error about an inaccessible
InvalidProtocolBufferException
constructor for generated code that contained proto2required
fields. (PR #222, fixes #221)
0.14.0 - 2022-05-24
proto3
files that use theoptional
keyword are now supported! Fields withoptional
field presence will be nullable in generated Kotlin code. (PR #200, fixes #34) (thanks @NiematojakTomasz)- The
iosSimulatorArm64
,tvosArm64
,tvosX64
,tvosSimulatorArm64
, andlinuxArm64
Kotlin/Native targets are now supported. (PR #219, fixes #218)
- Kotlin/Native conformance tests on macOS now build using the
macosArm64
target instead of themacosX64
target when run on an Apple M1 chip. (PR #219, fixes #218)
- [BREAKING CHANGE] (for proto2 required fields only) Fixed handling of
required
fields inproto2
files. Required fields will no longer have a default value in generated code. (PR #216, fixes #71)- Constructing an instance of a message with required fields will now require providing a value for those fields as part of the constructor call.
- Decoding of a message with required fields will throw an
InvalidProtocolBufferException
if the binary/JSON input did not include the field. - Messages with required fields will no longer have a
Companion.defaultInstance
property in the generated code.
- Fixed the
pbandk-protos
library to support Java 8. (PR #212, fixes #211)
0.13.0 - 2021-12-08
- [BREAKING CHANGE] Added
MessageDescriptor.fullName
andMessageDescriptor.name
properties. All protobuf types have to be regenerated using this version ofprotoc-gen-pbandk
. (PRs #184, #192) - Added special support for protobuf's
google.protobuf.Any
message type. (PR #185, fixes #63, partially fixes #72)- Added
Any.Companion.pack()
,Any.unpack()
, andAny.isA()
convenience methods for working withAny
instances. These methods mirror the same-named methods in other protobuf libraries. - The special JSON format used for
google.protobuf.Any
messsages is now correctly used during JSON encoding/decoding. Provide a value forJsonConfig.typeRegistry
(which can be constructed using the newtypeRegistry {...}
builder) when encoding/decoding JSON messages that containgoogle.protobuf.Any
fields.
- Added
- Added
visibility
parameter toprotoc-gen-pbandk
to allow changing the visibility of generated code frompublic
tointernal
. (PR [#191}, fixes #190) - macOS builds of pbandk-runtime now include support for Apple Silicon (i.e.
pbandk-runtime-macosarm64
). (PR #189)
- Updated dependencies to Kotlin 1.5.0 and kotlinx-serialization 1.3.0-RC. (PR #189, fixes #171)
- Updated Kotlin/JS dependencies to protobuf.js 6.11.2.
- Generated code is now compatible with Kotlin's "explicit API" mode. (PR #191, fixes #134)
0.12.1 - 2021-11-11
- Enabled support for Kotlin/JS IR backend. (PR #147, fixes #136) (thanks @itegulov)
- The runtime is built in
BOTH
mode so that pbandk can be used with the old Kotlin/JS backend or the new IR one. - Conformance tests are run against the new IR backend.
- Most public pbandk APIs are now annotated with
@JsExport
to allow them to be used from Kotlin/JS code compiled with the new IR backend.@JsExport
doesn't yet support all features of Kotlin, so this annotation is currently applied on a best-effort basis where it's possible to use it. - Likewise, generated code is annoated with
@pbandk.Export
(an alias for@JsExport
) to allow it to be used from Kotlin/JS IR code.
- The runtime is built in
- macOS and iOS builds of pbandk-runtime are now built in CI and available from Maven Central. (PR #163, fixes #88) (thanks @itegulov)
- Files that contain the
deprecated
option in the.proto
file will now receive a@Deprecated
annotation in the generated Kotlin code. (PR #169, fixes #1)
- Switched Kotlin/JS runtime library to use UMD instead of CommonJS (PR #170, fixes #60)
- Minor updates to the gradle config for examples (PR #170)
0.11.0 - 2021-09-24
- [BREAKING CHANGE] Renamed
protoc-gen-kotlin
toprotoc-gen-pbandk
in order to work withprotoc
v3.17.0+. (PR #162, fixes #161) (thanks @kainosk)- All references to the
protoc-gen-kotlin
command in build files should be replaced withprotoc-gen-pbandk
. protoc
commands using--kotlin_out
should be updated to use--pbandk_out
instead (--kotlin_out
is now used byprotoc
's internal Kotlin generator).- Compile dependencies on the
pro.streem.pbandk:protoc-gen-kotlin-lib
artifact should be replaced withpro.streem.pbandk:protoc-gen-pbandk-lib
. - If using the official Protobuf Gradle Plugin, the plugin ID should be changed from "kotlin" to "pbandk" in your gradle files and the plugin artifact should be updated from
pro.streem.pbandk:protoc-gen-kotlin-jvm
topro.streem.pbandk:protoc-gen-pbandk-jvm
.
- All references to the
0.10.0 - 2021-05-07
- Experimental support for protobuf custom options on fields. Remaining work is tracked in #65. (PRs #103, #152)
- Protobuf messages that declare an extension range now extend from
ExtendableMessage
rather thanMessage
. - Protobuf extension fields are defined as Kotlin extension properties on the extended class and can be accessed like any other Kotlin property.
- Protobuf messages that declare an extension range now extend from
- Experimental support for protobuf reflection. All related APIs require opt-in to the
@ExperimentalProtoReflection
annotation for now. (PRs #103, #152)MessageDescriptor
(available viaMessage.descriptor
orMessage.Companion.descriptor
) is now part of the public API. Initially onlyMessageDescriptor.fields
is public, which provides access to descriptors for all of the message's fields. Additional properties of the message descriptor will be exposed in future versions. Please file an issue on GitHub if there are specific properties you would like to have access to. (PR #103)FieldDescriptor
(available viaMessageDescriptor.fields
) is now part of the public API. Initially, the field'sname
andoptions
are public, allowing access to custom options defined on the field in the.proto
file. (PR #103)- A new
Message.getFieldValue(FieldDescriptor)
method can be used to read the value of a protobuf field when iterating over fields generically usingMessage.descriptor.fields
.
Message.Companion.decodeFromStream()
now takes an optionalexpectedSize
parameter to allow reading multiple messages from a singleInputStream
. The method will not read more thanexpectedSize
bytes from the stream when decoding the message. (PR #148)- Add the ability to unit test the output of
CodeGenerator
(PR #117, fixes #48) (thanks @nbaztec) - Added a dedicated Android artifact
pbandk-runtime-android
of thePBandK
runtime. To migrate to this new artifact, replaceimplementation("pro.streem.pbandk:pbandk-runtime-jvm:0.9.1")
withimplementation("pro.streem.pbandk:pbandk-runtime:0.10.0")
(PR #124, fixes #75) (thanks @jeroenmols) - SNAPSHOT builds of the latest code on
master
are now available by including the https://s01.oss.sonatype.org/content/repositories/snapshots/ maven repository in yourbuild.gradle.kts
files (PR #148). - Conformance tests running on Kotlin/JVM can now be configured to use
ByteBuffer
orInputStream
/OutputStream
for their I/O instead ofByteArray
by setting thePBANDK_CONFORMANCE_JVM_IO
environment variable. (PR #148)
- Updated to Kotlin 1.4. Projects that are still on Kotlin 1.3 should be able to continue using pbandk, but this configuration is only supported on a best-effort basis (please file a GitHub issue with any problems). Projects are encouraged to update to Kotlin 1.4. (PR #114, fixes #86)
- [BREAKING CHANGE] Migrated the library from JCenter to Maven Central. Please make sure you have the
mavenCentral()
repository configured in yourbuild.gradle.kts
files (PRs #143, #144, fixes #120) (thanks @jeroenmols). - [BREAKING CHANGE] The API and implementation of
UnknownField
changed significantly. If you access the contents of unknown fields in your code, you will need to update to the new API. The unknown field no longer provides access to a decoded version of the field's wire type. Instead it only provides access to the raw binary encoding of the field. (PR #103) Message.encodeToStream()
now returns the number of bytes that were written to the stream (previously it didn't return anything). (PR #148)pbandk-runtime
on JVM and Android no longer depends on theprotobuf-java
library. It instead uses the same pure-Kotlin implementation of protobuf primitives that is used by thepbandk-runtime
on Kotlin/Native. This avoids dependency conflicts with other libraries (such ascom.google.firebase:firebase-perf
on Android). (PRs #124, #148, #151, fixes #91, #138) (thanks @jeroenmols)- Updated protobuf well-known types to the versions shipped with protobuf 3.15.5.
- Updated
pbandk-runtime-js
dependency onprotobuf.js
to6.10.2
. - Building pbandk no longer requires downloading and compiling protobuf. Running conformance tests still requires compiling protobuf however. (PR #150)
- Added workaround for an error in the Kotlin/JS implementation of
protoMergeImpl()
caused by a Kotlin compiler bug (PR #103) - Improved the code generated for messages with a large number of fields to handle even more fields (PR #103)
- Binary decoding of 64-bit numbers under Kotlin/JS with certain inputs that would previously cause a crash. (PR #103)
0.9.1 - 2021-01-07
- Compile error when proto contains a oneof field with same name as the enclosing message (PR #104, fixes #47) (thanks @nbaztec)
- All remaining JSON conformance test failures for numeric values (PR #105, partially fixes #72) (thanks @nbaztec)
0.9.0 - 2020-12-23
- Support for Kotlin/Native (PR #76, fixes #19) (thanks @sebleclerc)
- JSON encoding/decoding improvements:
- Support for the
json_name
protobuf field option - Custom encoding/decoding for most of the protobuf well-known types:
Duration
,Timestamp
,Empty
,Struct
,Value
,NullValue
,ListValue
, and all wrapper types - Added
JsonConfig
class for configuring JSON encoding/decoding at runtime. Currently supported options includeignoreUnknownFieldsInInput
,outputDefaultValues
, andoutputProtoFieldNames
(which match the options documented at https://developers.google.com/protocol-buffers/docs/proto3#json_options), and alsocompactOutput
.
- Support for the
- New binary encoding and decoding overloads on Kotlin/JVM:
Message.encodeToStream(java.io.OutputStream)
Message.Companion.decodeFromStream(java.io.InputStream)
Message.Companion.decodeFromByteBuffer(java.nio.ByteBuffer)
- [BREAKING CHANGE] Artifacts are now published to JCenter under new maven coordinates
- Runtime library:
pro.streem.pbandk:pbandk-runtime-common:0.9.0
,pro.streem.pbandk:pbandk-runtime-jvm:0.9.0
,pro.streem.pbandk:pbandk-runtime-js:0.9.0
,pro.streem.pbandk:pbandk-runtime-native:0.9.0
- Code generation plugin for the protobuf compiler:
pro.streem.pbandk:protoc-gen-kotlin-jvm:0.9.0:jvm8@jar
ServiceGenerator
library:pro.streem.pbandk:protoc-gen-kotlin-lib-jvm:0.9.0
- Runtime library:
- Projects that use
pbandk
can remove thekotlinx-serialization
gradle plugin and library dependency if they don't usekotlinx-serialization
themselves. The library is now an internal implementation detail ofpbandk
. (PR #69, fixes #61) - Completely rewritten implementation of JSON encoding/decoding, fixing numerous bugs in the old version. The new implementation is much more compliant with the official proto3 JSON spec. Remaining incompatibilities are tracked in #72.
- [BREAKING CHANGE] Moved all of the binary and JSON encoding functionality, and most of the decoding functionality, from the generated code to the runtime library. Code generated by old versions of pbandk will not run with this new pbandk version.
- [BREAKING CHANGE] Changed
Message
so that it no longer extends from itself. Uses ofMessage<T>
should be changed to justMessage
. (PR #69) - [BREAKING CHANGE] Added
@PbandkInternal
and@PublicForGeneratedCode
annotations on portions of the public API that are only public for pbandk's internal use or for use from pbandk-generated code. Using these APIs outside of pbandk will generate compiler warnings and errors. If you have a need for using any of these APIs from your project, please file an issue on GitHub describing your use case. - [BREAKING CHANGE] Code that calls any of pbandk's JSON encoding/decoding APIs must now opt-in to the
@ExperimentalProtoJson
annotation. See https://kotlinlang.org/docs/reference/opt-in-requirements.html#opting-in-to-using-api for detailed instructions. Once pbandk's JSON APIs are no longer considered experimental, this annotation will be removed. - [BREAKING CHANGE] Update the public API to follow recent naming conventions from the Kotlin standard library: "marshal"/"unmarshal" is replaced with "encode"/"decode", encoding methods are named
encodeTo*
, and decoding methods are nameddecodeFrom*
. (PRs #69, #90, fixes #89)- The below methods have been renamed and are now defined as extension methods rather than being part of the
Message
orMessage.Companion
interface. Code that calls these methods will now need to import them first.Message.protoMarshal()
->Message.encodeToByteArray()
Message.Companion.protoUnmarshal(ByteArray)
->Message.Companion.decodeFromByteArray(ByteArray)
Message.jsonMarshal()
->Message.encodeToJsonString()
Message.Companion.jsonUnmarshal(String)
->Message.Companion.decodeFromJsonString(String)
Message.protoMarshal(pbandk.Marshaller)
->Message.encodeWith(pbandk.MessageEncoder)
- The below methods have been renamed. They will become extension methods in a future pbandk release.
Message.Companion.protoUnmarshal(pbandk.Unmarshaller)
->Message.Companion.decodeWith(pbandk.MessageDecoder)
- The below methods have been renamed and are now defined as extension methods rather than being part of the
Message
orMessage.Companion
interface. Code that calls these methods will now need to import them first. TheJson
parameter fromkotlinx-serialization
has been replaced with the newJsonConfig
type frompbandk
.Message.jsonMarshal(kotlinx.serialization.json.Json)
->Message.encodeToJsonString(pbandk.json.JsonConfig)
Message.Companion.jsonUnmarshal(kotlinx.serialization.json.Json, String)
->Message.Companion.decodeFromJsonString(String, pbandk.json.JsonConfig)
- Replaced
Marshaller
andUnmarshaller
interfaces withMessageEncoder
andMessageDecoder
interfaces, which are much simpler and function differently from the previous interfaces
- The below methods have been renamed and are now defined as extension methods rather than being part of the
- [BREAKING CHANGE]
MessageMap.entries
is now aSet
instead of aList
- [BREAKING CHANGE] Removed
Sizer
andUtil
from the public API - [BREAKING CHANGE] Removed
UnknownField
constructors and theUnknownField.size()
method from the public API
- Crash on Android when encoding
google.protobuf.Timestamp
fields to JSON (PR #82, fixes #46) StackOverflowError
when generating code for really largeoneof
objects (PR #52) (thanks @tinder-aminghadersohi)- Performance problems when compiling generated code with Kotlin 1.4 (PR #101, fixes #94)
- JSON decoding of unknown enum values (PR #100)
- Map entry size computation for non-MessageMap maps (PR #99)
- Some bugs with the handling of
packed
fields, binary encoding of enums in Kotlin/JS, and base64 encoding/decoding in Kotlin/JS (PR #69, fixes #23) - Various conformance test failures (PRs #80, #82)
0.8.1 - 2020-05-22
- Enable conformance tests for Kotlin/JS
- [BREAKING CHANGE] Update to kotlin 1.3.72 and kotlinx.serialization 0.20.0. Projects that depend on
pbandk
must be using the same versions of kotlin and kotlinx.serialization. (fixes #35) - [BREAKING CHANGE] The
pbandk-runtime-common
maven package is now just calledpbandk-runtime
. Theprotoc-gen-kotlin-jvm
maven package is now calledprotoc-gen-kotlin-lib-jvm
. Thepbandk-runtime-jvm
andpbandk-runtime-js
packages have not changed names. - Use the new Kotlin multiplatform gradle plugin instead of the deprecated plugin (thanks @sebleclerc)
- Switch from Groovy to Kotlin for build.gradle files (thanks @sebleclerc)
- Update to gradle 6.2.2 (thanks @sebleclerc)
- Use the
maven-publish
gradle plugin instead of themaven
plugin (thanks @sebleclerc)