From 4e1f48fd59203bd5e70b41457375f133c73d3a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fa=C3=A7=20Eldenk?= Date: Sun, 8 Oct 2023 00:49:50 +0300 Subject: [PATCH] codecov + gradle fixes --- .DS_Store | Bin 0 -> 6148 bytes .editorconfig | 4 + .github/workflows/build.yaml | 5 + README.md | 21 +- app/build.gradle.kts | 14 +- .../kotlinx/protobuf/gen/CodeGenerator.kt | 26 +- .../protobuf/gen/CodeGeneratorOptions.kt | 4 +- .../protobuf/gen/wkt/WellKnownSerializers.kt | 232 ------------------ .../protobuf/gen/wkt/WellKnownTypes.kt | 2 +- build.gradle.kts | 21 ++ examples/sample-grpc-server/build.gradle.kts | 22 +- .../sample-protoc-plugin/build.gradle.kts | 15 ++ .../src/main/kotlin/App.kt | 2 +- generated-code-tests/build.gradle.kts | 9 +- .../protobuf/gen/json/PrimitiveTest.kt | 79 ++++++ .../protobuf/gen/{ => proto}/BytesTest.kt | 4 +- .../protobuf/gen/{ => proto}/EnumTest.kt | 2 +- .../protobuf/gen/{ => proto}/MapTest.kt | 2 +- .../protobuf/gen/{ => proto}/MessageTest.kt | 2 +- .../protobuf/gen/{ => proto}/OneofPOC.kt | 12 +- .../protobuf/gen/{ => proto}/OneofTest.kt | 2 +- .../protobuf/gen/{ => proto}/PrimitiveTest.kt | 2 +- .../{ => proto}/RepeatedInvestigationTest.kt | 2 +- .../protobuf/gen/{ => proto}/RepeatedTest.kt | 2 +- .../gen/{ => proto}/WellKnownTypesTest.kt | 9 +- runtime-common/build.gradle.kts | 39 ++- .../protobuf/gen/wkt/WellKnownSerializers.kt | 14 +- settings.gradle.kts | 10 +- 28 files changed, 229 insertions(+), 329 deletions(-) create mode 100644 .DS_Store create mode 100644 .editorconfig delete mode 100644 app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt create mode 100644 generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/json/PrimitiveTest.kt rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/BytesTest.kt (94%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/EnumTest.kt (98%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/MapTest.kt (99%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/MessageTest.kt (98%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/OneofPOC.kt (95%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/OneofTest.kt (98%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/PrimitiveTest.kt (98%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/RepeatedInvestigationTest.kt (97%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/RepeatedTest.kt (99%) rename generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/{ => proto}/WellKnownTypesTest.kt (97%) diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fd2b78a2db05431935b3415add14948bbf567e3a GIT binary patch literal 6148 zcmeHKyG{c^3>-s>NHi%ZDE9{__=8mxz92sUB2gN2krJT3itpmn7(axFF3{1SvE-dy zpU114;(P{R%h$~vumCWpJL27!srhsFiCt90h;-IC;1Ms_VuRaB_W6KwudyR%pnvB- zVb3~SR`QBRuE)3aVR+sTyS(pwK}Ds26p#W^Knh5KUls7)OPgOMYLx;~Kni>*;NOQv zckG2@VthKd#0Wr~F&xHy%o4=r0b(y46B(gdQi(~m8Zj*CjJL|`g=1pUVKsbM-E1|X zSlrI~Ez)5R literal 0 HcmV?d00001 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5aaba17 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*.{kt,kts}] +ktlint_no-wildcard-imports = disabled diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b66d898..008595a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,3 +17,8 @@ jobs: - uses: gradle/gradle-build-action@v2 with: arguments: build --scan + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 94dd437..fd90884 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Generate kotlin data classes from `protobuf` files that supports _Kotlin Native_ deserialized to protobuf using [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization). > [!NOTE] -> Full documentation for the project including setup instruction can be found -> at [GitHub Pages](https://dogacel.github.io/kotlinx-protobuf-gen). +> Setup instructions and detailed documentation can be found +> at [Setup and Documentation](https://dogacel.github.io/kotlinx-protobuf-gen). ![Demonstrate Code](./docs/src/doc/docs/assets/demonstrate_code.png) @@ -23,16 +23,13 @@ deserialized to protobuf using [kotlinx.serialization](https://github.com/Kotlin ## Roadmap -I will probably move those stuff to issues and projects later on. For now, here is a list of stuff that I have -been thinking about, - -Our goal is to eventually support all features of Protobuf in Kotlin without depending on the Java library. Here -is a list of features we are working on that are required to release first stable version. +The goal is to eventually support all features of Protobuf in Kotlin without depending on the Java library. Here +is a list of features we are working on that are required to release first stable version: - [ ] Proper serialization / deserialization of all types. Check "Known Issues" section below to see all major issues. -- [ ] Make data classes with `ByteArray` implement equals and hashcode correctly. -- [ ] Run full conformance tests on the generated code. +- [ ] Run full conformance tests on the generated code.] +- [ ] Support Protobuf JSON format. And here is a list of features that we are planning to work on after the first stable release. @@ -42,9 +39,9 @@ And here is a list of features that we are planning to work on after the first s - More WKT additions will be added. - [ ] Support various options such as `deprecated`, `default`, `json_name`. - [ ] Auto-generated comments from `.proto` files in the generated code. -- [ ] Support Protobuf JSON format by default. - [x] gRPC support. - Stub generation is completed but it does not include any functionality to call or receive gRPC yet. + - It is tricky to support gRPC without depending on the Java library. - [ ] Plugin and more option support for customizing the generated code. (Such as non-enforced nullability to gimmick proto2 required fields based on certain rules) @@ -61,8 +58,8 @@ Focusing on core functionality, here is a list of known major issues: - [ ] Generated `repeated` fields with `fixedXX`, `sfixedXX` and `uintXX` types can't be serialized. - [ ] Generated `repeated` fields with `sintXX` deserializes incorrectly. - [ ] Generated `map` fields with `fixedXX` and `sfixedXX` keys can't be serialized. -- [ ] Generated `enum` fields with negative values can't be serialized / deserialized. - - PR opened in `kotlinx.serialization`: https://github.com/Kotlin/kotlinx.serialization/pull/2400 +- [x] Generated `enum` fields with negative values can't be serialized / deserialized. +- [ ] Make data classes with `ByteArray` implement equals and hashcode correctly. ## Contribution diff --git a/app/build.gradle.kts b/app/build.gradle.kts index dcbbd5c..e712a71 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,11 +5,10 @@ plugins { id("org.jetbrains.kotlin.jvm") kotlin("plugin.serialization") id("com.google.protobuf") - id("org.jlleitschuh.gradle.ktlint") - id("org.jetbrains.kotlinx.kover") application `maven-publish` id("org.jetbrains.dokka") + id("org.jetbrains.kotlinx.kover") } repositories { @@ -40,17 +39,6 @@ java { } } -ktlint { - ignoreFailures.set(true) - filter { - exclude { entry -> - val condition = - entry.file.toString().contains("generated") || entry.file.toString().contains("testgen") - condition - } - } -} - application { // Define the main class for the application. mainClass.set("dogacel.kotlinx.protobuf.gen.AppKt") diff --git a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt b/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt index 7038bd9..c8ffbf7 100644 --- a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt +++ b/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGenerator.kt @@ -38,7 +38,7 @@ class CodeGenerator { */ constructor( request: PluginProtos.CodeGeneratorRequest, - options: CodeGeneratorOptions = CodeGeneratorOptions(), + options: CodeGeneratorOptions = CodeGeneratorOptions() ) { this.options = options // https://protobuf.dev/reference/java/api-docs/com/google/protobuf/compiler/PluginProtos.CodeGeneratorRequest @@ -48,7 +48,7 @@ class CodeGenerator { val files = mutableMapOf() filesInOrder = request.protoFileList.map { file -> files.computeIfAbsent( - file.name, + file.name ) { val deps = file.dependencyList.map { dep -> files[dep] ?: throw IllegalStateException("Dependency $dep not found for file ${file.name}") @@ -67,7 +67,7 @@ class CodeGenerator { */ constructor( vararg fileDescriptors: Descriptors.FileDescriptor, - options: CodeGeneratorOptions = CodeGeneratorOptions(), + options: CodeGeneratorOptions = CodeGeneratorOptions() ) { this.options = options @@ -116,8 +116,8 @@ class CodeGenerator { } /** - * Whether to generate a class for the given descriptor or not. Currently we do not create classes for - * well-known types. + * Whether to generate a class for the given descriptor or not. Currently, we do not create classes for + * well-known types. They are imported from "io.github.dogacel:kotlinx-protobuf-runtime-common" library. */ fun shouldGenerateClass(descriptor: Descriptors.Descriptor): Boolean { return options.wellKnownTypes.getFor(descriptor) == null @@ -234,7 +234,7 @@ class CodeGenerator { typeSpec.addProperty( PropertySpec.builder(fieldName, type) .initializer(fieldName) - .build(), + .build() ) } @@ -275,7 +275,7 @@ class CodeGenerator { valueDescriptor.name, TypeSpec.anonymousClassBuilder() .addAnnotations(Annotations.annotationsOf(valueDescriptor)) - .build(), + .build() ) } @@ -294,7 +294,7 @@ class CodeGenerator { */ private fun generateSingleService( serviceDescriptor: Descriptors.ServiceDescriptor, - isGrpcCompatible: Boolean, + isGrpcCompatible: Boolean ): TypeSpec.Builder { val typeSpec = TypeSpec .classBuilder(serviceDescriptor.name) @@ -344,11 +344,11 @@ class CodeGenerator { private fun getEnumLink( enumDescriptor: Descriptors.EnumDescriptor, packageName: String, - simpleNames: List, + simpleNames: List ): Link { return Link( enumDescriptor, - ClassName(packageName, simpleNames + enumDescriptor.name), + ClassName(packageName, simpleNames + enumDescriptor.name) ) } @@ -361,7 +361,7 @@ class CodeGenerator { private fun getAllLinks( descriptor: Descriptors.Descriptor, packageName: String, - simpleNames: List, + simpleNames: List ): List { val wellKnownType = options.wellKnownTypes.getFor(descriptor) @@ -379,7 +379,7 @@ class CodeGenerator { val self = Link( descriptor, - ClassName(packageName, simpleNames + descriptor.name), + ClassName(packageName, simpleNames + descriptor.name) ) return (messages + enums + self) } @@ -391,7 +391,7 @@ class CodeGenerator { */ private fun getAllLinks( fileDescriptor: Descriptors.FileDescriptor, - packagePrefix: String = "", + packagePrefix: String = "" ): List { val publicDependencies = fileDescriptor.publicDependencies.flatMap { getAllLinks(it, packagePrefix) diff --git a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGeneratorOptions.kt b/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGeneratorOptions.kt index 659f23e..55c45dd 100644 --- a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGeneratorOptions.kt +++ b/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/CodeGeneratorOptions.kt @@ -24,7 +24,7 @@ data class CodeGeneratorOptions( val generateServices: Boolean = true, val generateGrpcServices: Boolean = true, val generateGrpcMethodsSuspend: Boolean = true, - val wellKnownTypes: WellKnownTypes = NoWellKnownTypes, + val wellKnownTypes: WellKnownTypes = NoWellKnownTypes ) { companion object { fun parse(parameter: String): CodeGeneratorOptions { @@ -41,7 +41,7 @@ data class CodeGeneratorOptions( generateGrpcMethodsSuspend = flags.contains("disable_grpc_methods_suspend").not(), wellKnownTypes = flags.contains("use_well_known_types").let { if (it) DefaultWellKnownTypes else NoWellKnownTypes - }, + } ) } } diff --git a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt b/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt deleted file mode 100644 index 71c9b7c..0000000 --- a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt +++ /dev/null @@ -1,232 +0,0 @@ -package dogacel.kotlinx.protobuf.gen.wkt - -import kotlinx.datetime.Instant -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlin.time.Duration -import kotlin.time.Duration.Companion.nanoseconds -import kotlin.time.Duration.Companion.seconds - -// @ProtoNumber(number = 12) -// public val optionalFieldMask: FieldMask? = null, -// @ProtoNumber(number = 13) -// public val optionalStruct: Struct? = null, -// @ProtoNumber(number = 14) -// public val optionalAny: Any? = null, -// @ProtoNumber(number = 15) -// public val optionalValue: Value? = null, -// @ProtoNumber(number = 16) -// public val repeatedListValue: ListValue? = null, - -typealias BoolValueP = @Serializable(with = BoolValueSerializer::class) Boolean? -typealias Int32ValueP = @Serializable(with = Int32ValueSerializer::class) Int? -typealias Int64ValueP = @Serializable(with = Int64ValueSerializer::class) Long? -typealias UInt32ValueP = @Serializable(with = UInt32ValueSerializer::class) UInt? -typealias UInt64ValueP = @Serializable(with = UInt64ValueSerializer::class) ULong? -typealias FloatValueP = @Serializable(with = FloatValueSerializer::class) Float? -typealias DoubleValueP = @Serializable(with = DoubleValueSerializer::class) Double? -typealias StringValueP = @Serializable(with = StringValueSerializer::class) String? -typealias BytesValueP = @Serializable(with = BytesValueSerializer::class) ByteArray? -typealias DurationP = @Serializable(with = DurationSerializer::class) Duration? -typealias TimestampP = @Serializable(with = TimestampSerializer::class) Instant? - -object BoolValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: Boolean = false - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: Boolean?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): Boolean? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object Int32ValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: Int = 0 - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: Int?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): Int? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object Int64ValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: Long = 0L - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: Long?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): Long? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object UInt32ValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: UInt = 0U - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: UInt?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): UInt? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object UInt64ValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: ULong = 0UL - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: ULong?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): ULong? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object FloatValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: Float = 0f - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: Float?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): Float? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object DoubleValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: Double = 0.0 - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: Double?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): Double? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - - -object StringValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: String = "" - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: String?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): String? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object BytesValueSerializer : KSerializer { - @Serializable - private data class Boxed( - val `value`: ByteArray = ByteArray(0) - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: ByteArray?) { - encoder.encodeNullableSerializableValue(Boxed.serializer(), value?.let { Boxed(it) }) - } - - override fun deserialize(decoder: Decoder): ByteArray? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.`value` - } -} - -object DurationSerializer : KSerializer { - @Serializable - private data class Boxed( - val seconds: Long = 0L, - val nanos: Int = 0, - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: Duration?) { - encoder.encodeNullableSerializableValue( - Boxed.serializer(), - value?.toComponents { seconds, nanoseconds -> - Boxed( - seconds = seconds, - nanos = nanoseconds, - ) - }) - } - - override fun deserialize(decoder: Decoder): Duration? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.let { - it.seconds.seconds + it.nanos.nanoseconds - } - } -} - -object TimestampSerializer : KSerializer { - @Serializable - private data class Boxed( - val seconds: Long = 0L, - val nanos: Int = 0, - ) - - override val descriptor: SerialDescriptor = Boxed.serializer().descriptor - override fun serialize(encoder: Encoder, value: Instant?) { - encoder.encodeNullableSerializableValue( - Boxed.serializer(), - value?.let { - Boxed( - seconds = it.epochSeconds, - nanos = it.nanosecondsOfSecond, - ) - }, - ) - } - - override fun deserialize(decoder: Decoder): Instant? { - return decoder.decodeNullableSerializableValue(Boxed.serializer())?.let { - Instant.fromEpochSeconds(it.seconds, it.nanos) - } - } -} diff --git a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownTypes.kt b/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownTypes.kt index 381a05e..40a0422 100644 --- a/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownTypes.kt +++ b/app/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownTypes.kt @@ -69,7 +69,7 @@ object DefaultWellKnownTypes : WellKnownTypes() { com.google.protobuf.Empty.getDescriptor() to UNIT, // com.google.protobuf.FieldMask.getDescriptor() to ???, // com.google.protobuf.ListValue.getDescriptor() to ???, - com.google.protobuf.NullValue.getDescriptor() to NOTHING.copy(nullable = true), + com.google.protobuf.NullValue.getDescriptor() to NOTHING.copy(nullable = true) // com.google.protobuf.Struct.getDescriptor() to ???, // com.google.protobuf.Value.getDescriptor() to ???, ).mapKeys { diff --git a/build.gradle.kts b/build.gradle.kts index 4d6a76c..aed84bb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,3 +32,24 @@ signing { sign(extension.publications) } } + +subprojects { + apply(plugin = "org.jlleitschuh.gradle.ktlint") // Version should be inherited from parent + + repositories { + // Required to download KtLint + mavenCentral() + } + + // Optionally configure plugin + configure { + ignoreFailures.set(true) + filter { + exclude { entry -> + val condition = + entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated") + condition + } + } + } +} diff --git a/examples/sample-grpc-server/build.gradle.kts b/examples/sample-grpc-server/build.gradle.kts index c57a5dc..a6dbc10 100644 --- a/examples/sample-grpc-server/build.gradle.kts +++ b/examples/sample-grpc-server/build.gradle.kts @@ -24,15 +24,19 @@ var protobufVersion = "3.23.4" val grpcVersion = "1.58.0" val grpcKotlinVersion = "1.3.1" - dependencies { implementation("io.github.dogacel:kotlinx-protobuf-gen-runtime:alpha-SNAPSHOT") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") + listOf( "armeria", "armeria-grpc", "armeria-logback", - "armeria-kotlin", + "armeria-kotlin" ).forEach { implementation("com.linecorp.armeria:$it:1.25.2") } @@ -47,6 +51,10 @@ dependencies { runtimeOnly("org.slf4j:log4j-over-slf4j:1.7.36") } +configurations.all { + resolutionStrategy.sortArtifacts(ResolutionStrategy.SortOrder.DEPENDENCY_FIRST) +} + tasks.named("generateProto") { dependsOn(project(":app").tasks.jar) } @@ -87,3 +95,13 @@ protobuf { } } } + +ktlint { + filter { + exclude { entry -> + val condition = + entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated") + condition + } + } +} diff --git a/examples/sample-protoc-plugin/build.gradle.kts b/examples/sample-protoc-plugin/build.gradle.kts index d1596bd..8c45335 100644 --- a/examples/sample-protoc-plugin/build.gradle.kts +++ b/examples/sample-protoc-plugin/build.gradle.kts @@ -20,6 +20,11 @@ var protobufVersion = "3.23.4" dependencies { implementation("io.github.dogacel:kotlinx-protobuf-gen-runtime:alpha-SNAPSHOT") + + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") } configurations.all { @@ -55,3 +60,13 @@ protobuf { } } } + +ktlint { + filter { + exclude { entry -> + val condition = + entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated") + condition + } + } +} diff --git a/examples/sample-protoc-plugin/src/main/kotlin/App.kt b/examples/sample-protoc-plugin/src/main/kotlin/App.kt index 39c99ff..08221d6 100644 --- a/examples/sample-protoc-plugin/src/main/kotlin/App.kt +++ b/examples/sample-protoc-plugin/src/main/kotlin/App.kt @@ -10,7 +10,7 @@ fun main() { tags = listOf("fast", "reliable"), attributes = mapOf( "ip" to "192.168.1.1", - "host" to "9000", + "host" to "9000" ), status = NodeStatus.ACTIVE, next = Node( diff --git a/generated-code-tests/build.gradle.kts b/generated-code-tests/build.gradle.kts index 91f3c41..3593295 100644 --- a/generated-code-tests/build.gradle.kts +++ b/generated-code-tests/build.gradle.kts @@ -6,7 +6,6 @@ plugins { id("com.google.protobuf") kotlin("plugin.serialization") id("org.jetbrains.kotlinx.kover") - id("org.jlleitschuh.gradle.ktlint") application } @@ -20,6 +19,11 @@ dependencies { implementation("com.google.protobuf:protobuf-kotlin:$protobufVersion") implementation("com.google.protobuf:protobuf-java-util:$protobufVersion") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0-RC") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.6.0-RC") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") + implementation(project(":runtime-common")) testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") @@ -108,11 +112,10 @@ tasks.named("runKtlintCheckOverMainSourceSet") { } ktlint { - ignoreFailures.set(true) filter { exclude { entry -> val condition = - entry.file.toString().contains("generated") || entry.file.toString().contains("testgen") + entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated") condition } } diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/json/PrimitiveTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/json/PrimitiveTest.kt new file mode 100644 index 0000000..209e812 --- /dev/null +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/json/PrimitiveTest.kt @@ -0,0 +1,79 @@ +package dogacel.kotlinx.protobuf.gen.json + +import com.google.protobuf.util.JsonFormat +import kotlinx.serialization.decodeFromByteArray +import kotlinx.serialization.encodeToByteArray +import kotlinx.serialization.json.Json +import kotlinx.serialization.protobuf.ProtoBuf +import org.junit.jupiter.api.Assertions.assertEquals +import testgen.primitives.PrimitivesMessage +import kotlin.test.Test + +class PrimitiveTest { + @Test + fun shouldDeSerAll() { + val message = primitives.Primitives.PrimitivesMessage.newBuilder() + .setOptionalInt32(32) + .setOptionalInt64(57L) + .setOptionalUint32(12) + .setOptionalUint64(68L) + .setOptionalFixed32(4358) + .setOptionalFixed64(543587L) + .setOptionalSint32(-283) + .setOptionalSint64(349L) + .setOptionalSfixed32(21934) + .setOptionalSfixed64(901235L) + .setOptionalFloat(0.123f) + .setOptionalDouble(0.391284) + .setOptionalBool(true) + .setOptionalString("Hello") +// .setOptionalBytes("934u9234".toByteStringUtf8()) + .build() + + val protoJson = JsonFormat.printer().print(message) + val result: PrimitivesMessage = Json.decodeFromString(protoJson) + + assertEquals(message.optionalInt32, result.optionalInt32) + assertEquals(message.optionalInt64, result.optionalInt64) + assertEquals(message.optionalUint32.toUInt(), result.optionalUint32) + assertEquals(message.optionalUint64.toULong(), result.optionalUint64) + assertEquals(message.optionalFixed32, result.optionalFixed32) + assertEquals(message.optionalFixed64, result.optionalFixed64) + assertEquals(message.optionalSint32, result.optionalSint32) + assertEquals(message.optionalSint64, result.optionalSint64) + assertEquals(message.optionalSfixed32, result.optionalSfixed32) + assertEquals(message.optionalSfixed64, result.optionalSfixed64) + assertEquals(message.optionalFloat, result.optionalFloat) + assertEquals(message.optionalDouble, result.optionalDouble) + assertEquals(message.optionalBool, result.optionalBool) + assertEquals(message.optionalString, result.optionalString) + + val deser = primitives.Primitives.PrimitivesMessage.parseFrom(ProtoBuf.encodeToByteArray(result)) + assertEquals(message, deser) + } + + @Test + fun shouldDeSerEmpty() { + val message = primitives.Primitives.PrimitivesMessage.newBuilder().build() + + val result: PrimitivesMessage = ProtoBuf.decodeFromByteArray(message.toByteArray()) + + assertEquals(message.optionalInt32, result.optionalInt32) + assertEquals(message.optionalInt64, result.optionalInt64) + assertEquals(message.optionalUint32.toUInt(), result.optionalUint32) + assertEquals(message.optionalUint64.toULong(), result.optionalUint64) + assertEquals(message.optionalFixed32, result.optionalFixed32) + assertEquals(message.optionalFixed64, result.optionalFixed64) + assertEquals(message.optionalSint32, result.optionalSint32) + assertEquals(message.optionalSint64, result.optionalSint64) + assertEquals(message.optionalSfixed32, result.optionalSfixed32) + assertEquals(message.optionalSfixed64, result.optionalSfixed64) + assertEquals(message.optionalFloat, result.optionalFloat) + assertEquals(message.optionalDouble, result.optionalDouble) + assertEquals(message.optionalBool, result.optionalBool) + assertEquals(message.optionalString, result.optionalString) + + val deser = primitives.Primitives.PrimitivesMessage.parseFrom(ProtoBuf.encodeToByteArray(result)) + assertEquals(message, deser) + } +} diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/BytesTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/BytesTest.kt similarity index 94% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/BytesTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/BytesTest.kt index bcb2163..5a67a9a 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/BytesTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/BytesTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import com.google.protobuf.ByteString import kotlinx.serialization.Serializable @@ -23,7 +23,7 @@ class BytesTest { } } -@Serializable +@kotlinx.serialization.Serializable data class ByteWrapper( @ProtoNumber(1) @ProtoPacked diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/EnumTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/EnumTest.kt similarity index 98% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/EnumTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/EnumTest.kt index a1cf50b..ddd8717 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/EnumTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/EnumTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import enums.Enums import kotlinx.serialization.decodeFromByteArray diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/MapTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/MapTest.kt similarity index 99% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/MapTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/MapTest.kt index 6032278..cd102cd 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/MapTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/MapTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import com.google.protobuf.kotlin.toByteStringUtf8 import kotlinx.serialization.decodeFromByteArray diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/MessageTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/MessageTest.kt similarity index 98% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/MessageTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/MessageTest.kt index 4e903ce..d2f6eb1 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/MessageTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/MessageTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import kotlinx.serialization.decodeFromByteArray import kotlinx.serialization.encodeToByteArray diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/OneofPOC.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/OneofPOC.kt similarity index 95% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/OneofPOC.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/OneofPOC.kt index 7f48bfb..3051a37 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/OneofPOC.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/OneofPOC.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable @@ -84,13 +84,13 @@ public data class OneofPOCMessage( value class Bool( @ProtoNumber(number = 5) override val value: kotlin.Boolean - ) : OneofField + ) : OneofField @JvmInline value class Uint64( @ProtoNumber(number = 6) override val value: ULong - ) : OneofField + ) : OneofField @JvmInline value class Float( @@ -111,7 +111,7 @@ public data class OneofPOCMessage( ) : OneofField } - @Serializable + @kotlinx.serialization.Serializable sealed interface SecondOneOfField : KOneof { @JvmInline value class Left( @@ -126,7 +126,7 @@ public data class OneofPOCMessage( ) : SecondOneOfField } - @Serializable + @kotlinx.serialization.Serializable public data class NestedMessage( @ProtoNumber(number = 1) public val a: Int = 0, @@ -134,7 +134,7 @@ public data class OneofPOCMessage( public val corecursive: OneofMessage? = null ) - @Serializable + @kotlinx.serialization.Serializable public enum class NestedEnum { @ProtoNumber(number = 0) FOO, diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/OneofTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/OneofTest.kt similarity index 98% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/OneofTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/OneofTest.kt index 13074d3..8dd0efd 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/OneofTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/OneofTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import kotlinx.serialization.decodeFromByteArray import kotlinx.serialization.encodeToByteArray diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/PrimitiveTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/PrimitiveTest.kt similarity index 98% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/PrimitiveTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/PrimitiveTest.kt index bf04e88..440c877 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/PrimitiveTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/PrimitiveTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import com.google.protobuf.kotlin.toByteStringUtf8 import kotlinx.serialization.decodeFromByteArray diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/RepeatedInvestigationTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/RepeatedInvestigationTest.kt similarity index 97% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/RepeatedInvestigationTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/RepeatedInvestigationTest.kt index dc5ea68..bd4a1d6 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/RepeatedInvestigationTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/RepeatedInvestigationTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromByteArray diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/RepeatedTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/RepeatedTest.kt similarity index 99% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/RepeatedTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/RepeatedTest.kt index 1262b9a..5564c3d 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/RepeatedTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/RepeatedTest.kt @@ -1,4 +1,4 @@ -package dogacel.kotlinx.protobuf.gen +package dogacel.kotlinx.protobuf.gen.proto import com.google.protobuf.kotlin.toByteStringUtf8 import kotlinx.serialization.decodeFromByteArray diff --git a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/WellKnownTypesTest.kt b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/WellKnownTypesTest.kt similarity index 97% rename from generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/WellKnownTypesTest.kt rename to generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/WellKnownTypesTest.kt index cac05f5..5863151 100644 --- a/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/WellKnownTypesTest.kt +++ b/generated-code-tests/src/test/kotlin/dogacel/kotlinx/protobuf/gen/proto/WellKnownTypesTest.kt @@ -1,5 +1,4 @@ -package dogacel.kotlinx.protobuf.gen - +package dogacel.kotlinx.protobuf.gen.proto import com.google.protobuf.* import kotlinx.datetime.Instant @@ -12,16 +11,14 @@ import kotlin.test.assertEquals import kotlin.time.Duration.Companion.nanoseconds import kotlin.time.Duration.Companion.seconds - class WellKnownTypesTest { private fun builder(): wkt.WellKnownType.MessageWithWellKnownTypes.Builder = wkt.WellKnownType.MessageWithWellKnownTypes.newBuilder() private fun wkt.WellKnownType.MessageWithWellKnownTypes.Builder.test( - scope: - ( + scope: ( original: wkt.WellKnownType.MessageWithWellKnownTypes, - result: MessageWithWellKnownTypes, + result: MessageWithWellKnownTypes ) -> Unit ) { val message = this.build() diff --git a/runtime-common/build.gradle.kts b/runtime-common/build.gradle.kts index 1d5b507..fd8f595 100644 --- a/runtime-common/build.gradle.kts +++ b/runtime-common/build.gradle.kts @@ -18,11 +18,10 @@ dependencies { implementation("com.google.protobuf:protobuf-kotlin:$protobufVersion") implementation("com.google.protobuf:protobuf-java-util:$protobufVersion") - api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0") - api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") - api("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.6.0") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.1") @@ -35,17 +34,6 @@ java { } } -//ktlint { -// ignoreFailures.set(true) -// filter { -// exclude { entry -> -// val condition = -// entry.file.toString().contains("generated") || entry.file.toString().contains("testgen") -// condition -// } -// } -//} - tasks.named("test") { // Use JUnit Platform for unit tests. useJUnitPlatform() @@ -66,16 +54,15 @@ tasks.jar { archiveClassifier.set("jvm8") } - -//sourceSets { +// sourceSets { // main { // proto { // srcDir("$rootDir/testProtos") // } // } -//} +// } -//protobuf { +// protobuf { // protoc { // artifact = "com.google.protobuf:protoc:$protobufVersion" // } @@ -88,7 +75,7 @@ tasks.jar { // } // } // } -//} +// } // Publishing @@ -144,3 +131,13 @@ publishing { } } } + +ktlint { + filter { + exclude { entry -> + val condition = + entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated") + condition + } + } +} diff --git a/runtime-common/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt b/runtime-common/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt index 71c9b7c..622e87f 100644 --- a/runtime-common/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt +++ b/runtime-common/src/main/kotlin/dogacel/kotlinx/protobuf/gen/wkt/WellKnownSerializers.kt @@ -145,7 +145,6 @@ object DoubleValueSerializer : KSerializer { } } - object StringValueSerializer : KSerializer { @Serializable private data class Boxed( @@ -182,7 +181,7 @@ object DurationSerializer : KSerializer { @Serializable private data class Boxed( val seconds: Long = 0L, - val nanos: Int = 0, + val nanos: Int = 0 ) override val descriptor: SerialDescriptor = Boxed.serializer().descriptor @@ -192,9 +191,10 @@ object DurationSerializer : KSerializer { value?.toComponents { seconds, nanoseconds -> Boxed( seconds = seconds, - nanos = nanoseconds, + nanos = nanoseconds ) - }) + } + ) } override fun deserialize(decoder: Decoder): Duration? { @@ -208,7 +208,7 @@ object TimestampSerializer : KSerializer { @Serializable private data class Boxed( val seconds: Long = 0L, - val nanos: Int = 0, + val nanos: Int = 0 ) override val descriptor: SerialDescriptor = Boxed.serializer().descriptor @@ -218,9 +218,9 @@ object TimestampSerializer : KSerializer { value?.let { Boxed( seconds = it.epochSeconds, - nanos = it.nanosecondsOfSecond, + nanos = it.nanosecondsOfSecond ) - }, + } ) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 2920adb..8bfbaa5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,13 +1,14 @@ plugins { // Apply the foojay-resolver plugin to allow automatic download of JDKs id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0" + id("com.gradle.enterprise") version("3.15.1") id("org.jetbrains.kotlin.jvm") version "1.9.0" apply false kotlin("plugin.serialization") version "1.9.0" apply false id("com.google.protobuf") version "0.9.4" apply false id("org.jetbrains.kotlinx.kover") version "0.7.3" apply false - id("org.jlleitschuh.gradle.ktlint") version "11.5.0" apply false + id("org.jlleitschuh.gradle.ktlint") version "11.6.0" apply false id("ru.vyarus.mkdocs") version "3.0.0" apply false id("org.jetbrains.dokka") version "1.8.20" apply false } @@ -20,3 +21,10 @@ include("generated-code-tests") include("examples:sample-protoc-plugin") include("examples:sample-grpc-server") include("docs") + +gradleEnterprise { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + } +}