parent
c160ae52a9
commit
dfd99e7ec0
18 changed files with 1327 additions and 21 deletions
@ -0,0 +1,169 @@ |
||||
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_test") |
||||
load("@rules_java//java:defs.bzl", "java_lite_proto_library") |
||||
|
||||
java_lite_proto_library( |
||||
name = "example_extensible_message_java_proto_lite", |
||||
deps = ["//java/kotlin:example_extensible_message_proto"], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "lite_extensions", |
||||
srcs = ["src/main/kotlin/com/google/protobuf/ExtendableMessageLiteExtensions.kt"], |
||||
deps = ["//java/lite"], |
||||
) |
||||
|
||||
test_suite( |
||||
name = "tests", |
||||
tests = [ |
||||
"test_lite_extensions", |
||||
"proto2_test_lite", |
||||
"proto3_test_lite", |
||||
], |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "test_lite_extensions", |
||||
srcs = ["src/test/kotlin/com/google/protobuf/ExtendableMessageLiteExtensionsTest.kt"], |
||||
deps = [ |
||||
":example_extensible_message_java_proto_lite", |
||||
":lite_extensions", |
||||
"//java/lite", |
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
"//java/kotlin:shared_runtime", |
||||
"@com_github_jetbrains_kotlin//:kotlin-test", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.ExtendableMessageLiteExtensionsTest", |
||||
) |
||||
|
||||
java_lite_proto_library( |
||||
name = "evil_names_proto2_java_proto_lite", |
||||
deps = ["//java/kotlin:evil_names_proto2"], |
||||
) |
||||
|
||||
java_lite_proto_library( |
||||
name = "evil_names_proto3_java_proto_lite", |
||||
deps = ["//java/kotlin:evil_names_proto3"], |
||||
) |
||||
|
||||
java_lite_proto_library( |
||||
name = "multiple_files_proto3_java_proto_lite", |
||||
deps = ["//java/kotlin:multiple_files_proto3"], |
||||
) |
||||
|
||||
genrule( |
||||
name = "gen_kotlin_proto3_java_multiple_files_lite", |
||||
srcs = ["src/test/proto/com/google/protobuf/multiple_files_proto3.proto"], |
||||
outs = [ |
||||
"MultipleFilesMessageALiteKt.kt", |
||||
"MultipleFilesMessageBLiteKt.kt", |
||||
"MultipleFilesProto3LiteKt.kt", |
||||
], |
||||
cmd = "$(location //:protoc) " + |
||||
"--kotlin_out=lite:$(@D) " + |
||||
"$(location src/test/proto/com/google/protobuf/multiple_files_proto3.proto) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/MultipleFilesMessageAKt.kt " + |
||||
"$(location MultipleFilesMessageALiteKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/MultipleFilesMessageBKt.kt " + |
||||
"$(location MultipleFilesMessageBLiteKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/MultipleFilesProto3Kt.kt " + |
||||
"$(location MultipleFilesProto3LiteKt.kt)", |
||||
tools = ["//:protoc"], |
||||
) |
||||
|
||||
genrule( |
||||
name = "gen_evil_names_proto2_lite", |
||||
srcs = ["src/test/proto/com/google/protobuf/evil_names_proto2.proto"], |
||||
outs = [ |
||||
"EvilNamesProto2LiteKt.kt", |
||||
"HardKeywordsAllTypesProto2LiteKt.kt", |
||||
"InterfaceKt.kt", |
||||
], |
||||
cmd = "$(location //:protoc) " + |
||||
"--kotlin_out=lite:$(@D) " + |
||||
"$(location src/test/proto/com/google/protobuf/evil_names_proto2.proto) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/EvilNamesProto2Kt.kt " + |
||||
"$(location EvilNamesProto2LiteKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/HardKeywordsAllTypesProto2Kt.kt " + |
||||
"$(location HardKeywordsAllTypesProto2LiteKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/InterfaceKt.kt " + |
||||
"$(location InterfaceKt.kt)", |
||||
tools = ["//:protoc"], |
||||
) |
||||
|
||||
genrule( |
||||
name = "gen_evil_names_proto3_lite", |
||||
srcs = ["src/test/proto/com/google/protobuf/evil_names_proto3.proto"], |
||||
outs = [ |
||||
"ClassKt.kt", |
||||
"EvilNamesProto3Kt.kt", |
||||
"HardKeywordsAllTypesProto3Kt.kt", |
||||
], |
||||
cmd = "$(location //:protoc) " + |
||||
"--kotlin_out=lite:$(@D) " + |
||||
"$(location src/test/proto/com/google/protobuf/evil_names_proto3.proto) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/ClassKt.kt " + |
||||
"$(location ClassKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/EvilNamesProto3Kt.kt " + |
||||
"$(location EvilNamesProto3Kt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/HardKeywordsAllTypesProto3Kt.kt " + |
||||
"$(location HardKeywordsAllTypesProto3Kt.kt)", |
||||
tools = ["//:protoc"], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "kotlin_unittest_lite", |
||||
srcs = [ |
||||
":gen_evil_names_proto2_lite", |
||||
"//:gen_kotlin_unittest_lite", |
||||
], |
||||
deps = [ |
||||
":evil_names_proto2_java_proto_lite", |
||||
"//java/lite:lite", |
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
"//java/kotlin:shared_runtime", |
||||
"//:java_lite_test_protos", |
||||
], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "kotlin_proto3_unittest_lite", |
||||
srcs = [ |
||||
":gen_evil_names_proto3_lite", |
||||
":gen_kotlin_proto3_java_multiple_files_lite", |
||||
"//:gen_kotlin_proto3_unittest_lite", |
||||
], |
||||
deps = [ |
||||
":evil_names_proto3_java_proto_lite", |
||||
":multiple_files_proto3_java_proto_lite", |
||||
"//java/lite:lite", |
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
"//java/kotlin:shared_runtime", |
||||
"//:java_lite_test_protos", |
||||
], |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "proto2_test_lite", |
||||
srcs = ["src/test/kotlin/com/google/protobuf/Proto2LiteTest.kt"], |
||||
deps = [ |
||||
":kotlin_unittest_lite", |
||||
"//java/core:test_util_lite", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.Proto2LiteTest", |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "proto3_test_lite", |
||||
srcs = ["src/test/kotlin/com/google/protobuf/Proto3LiteTest.kt"], |
||||
deps = [ |
||||
":kotlin_proto3_unittest_lite", |
||||
"//java/core:test_util_lite", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.Proto3LiteTest", |
||||
) |
@ -0,0 +1,22 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>{groupId}</groupId> |
||||
<artifactId>protobuf-parent</artifactId> |
||||
<version>{version}</version> |
||||
</parent> |
||||
|
||||
<artifactId>{artifactId}</artifactId> |
||||
<packaging>{type}</packaging> |
||||
|
||||
<name>Protocol Buffers [Kotlin lite]</name> |
||||
<description> |
||||
Kotlin lite Protocol Buffers library. Protocol Buffers are a way of encoding structured data in an |
||||
efficient yet extensible format. |
||||
</description> |
||||
|
||||
<properties> |
||||
<kotlin.version>1.5.0</kotlin.version> |
||||
</properties> |
||||
</project> |
@ -0,0 +1,365 @@ |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 Google Inc. All rights reserved. |
||||
// https://developers.google.com/protocol-buffers/ |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
package com.google.protobuf.kotlin |
||||
|
||||
import com.google.common.truth.Truth.assertThat |
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.Class |
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.EvilNamesProto3 |
||||
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.HardKeywordsAllTypesProto3 |
||||
import com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto3Kt |
||||
import com.google.protobuf.kotlin.generator.class_ |
||||
import com.google.protobuf.kotlin.generator.evilNamesProto3 |
||||
import com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto3 |
||||
import proto3_lite_unittest.TestAllTypesKt |
||||
import proto3_lite_unittest.TestAllTypesKt.nestedMessage |
||||
import proto3_lite_unittest.UnittestProto3Lite.TestAllTypes |
||||
import proto3_lite_unittest.UnittestProto3Lite.TestAllTypes.NestedEnum |
||||
import proto3_lite_unittest.UnittestProto3Lite.TestEmptyMessage |
||||
import proto3_lite_unittest.copy |
||||
import proto3_lite_unittest.testAllTypes |
||||
import proto3_lite_unittest.testEmptyMessage |
||||
import org.junit.Test |
||||
import org.junit.runner.RunWith |
||||
import org.junit.runners.JUnit4 |
||||
|
||||
@RunWith(JUnit4::class) |
||||
class Proto3LiteTest { |
||||
@Test |
||||
fun testGettersAndSetters() { |
||||
testAllTypes { |
||||
optionalInt32 = 101 |
||||
assertThat(optionalInt32).isEqualTo(101) |
||||
optionalString = "115" |
||||
assertThat(optionalString).isEqualTo("115") |
||||
optionalNestedMessage = TestAllTypesKt.nestedMessage { bb = 118 } |
||||
assertThat(optionalNestedMessage).isEqualTo(TestAllTypesKt.nestedMessage { bb = 118 }) |
||||
optionalNestedEnum = NestedEnum.BAZ |
||||
assertThat(optionalNestedEnum).isEqualTo(NestedEnum.BAZ) |
||||
oneofUint32 = 601 |
||||
assertThat(oneofUint32).isEqualTo(601) |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
fun testRepeatedGettersAndSetters() { |
||||
testAllTypes { |
||||
repeatedInt32.addAll(listOf(1, 2)) |
||||
assertThat(repeatedInt32).isEqualTo(listOf(1, 2)) |
||||
repeatedInt32 += listOf(3, 4) |
||||
assertThat(repeatedInt32).isEqualTo(listOf(1, 2, 3, 4)) |
||||
repeatedInt32[0] = 5 |
||||
assertThat(repeatedInt32).isEqualTo(listOf(5, 2, 3, 4)) |
||||
|
||||
repeatedString.addAll(listOf("1", "2")) |
||||
assertThat(repeatedString).isEqualTo(listOf("1", "2")) |
||||
repeatedString += listOf("3", "4") |
||||
assertThat(repeatedString).isEqualTo(listOf("1", "2", "3", "4")) |
||||
repeatedString[0] = "5" |
||||
assertThat(repeatedString).isEqualTo(listOf("5", "2", "3", "4")) |
||||
|
||||
repeatedNestedMessage.addAll(listOf(nestedMessage { bb = 1 }, nestedMessage { bb = 2 })) |
||||
assertThat(repeatedNestedMessage).isEqualTo( |
||||
listOf( |
||||
nestedMessage { bb = 1 }, |
||||
nestedMessage { bb = 2 } |
||||
) |
||||
) |
||||
repeatedNestedMessage += listOf(nestedMessage { bb = 3 }, nestedMessage { bb = 4 }) |
||||
assertThat(repeatedNestedMessage).isEqualTo( |
||||
listOf( |
||||
nestedMessage { bb = 1 }, |
||||
nestedMessage { bb = 2 }, |
||||
nestedMessage { bb = 3 }, |
||||
nestedMessage { bb = 4 } |
||||
) |
||||
) |
||||
repeatedNestedMessage[0] = nestedMessage { bb = 5 } |
||||
assertThat(repeatedNestedMessage).isEqualTo( |
||||
listOf( |
||||
nestedMessage { bb = 5 }, |
||||
nestedMessage { bb = 2 }, |
||||
nestedMessage { bb = 3 }, |
||||
nestedMessage { bb = 4 } |
||||
) |
||||
) |
||||
|
||||
repeatedNestedEnum.addAll(listOf(NestedEnum.FOO, NestedEnum.BAR)) |
||||
assertThat(repeatedNestedEnum).isEqualTo(listOf(NestedEnum.FOO, NestedEnum.BAR)) |
||||
repeatedNestedEnum += listOf(NestedEnum.BAZ, NestedEnum.FOO) |
||||
assertThat(repeatedNestedEnum).isEqualTo( |
||||
listOf(NestedEnum.FOO, NestedEnum.BAR, NestedEnum.BAZ, NestedEnum.FOO) |
||||
) |
||||
repeatedNestedEnum[0] = NestedEnum.BAR |
||||
assertThat(repeatedNestedEnum).isEqualTo( |
||||
listOf(NestedEnum.BAR, NestedEnum.BAR, NestedEnum.BAZ, NestedEnum.FOO) |
||||
) |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
fun testClears() { |
||||
assertThat( |
||||
testAllTypes { |
||||
optionalInt32 = 101 |
||||
clearOptionalInt32() |
||||
|
||||
optionalString = "115" |
||||
clearOptionalString() |
||||
|
||||
optionalNestedMessage = TestAllTypesKt.nestedMessage { bb = 118 } |
||||
clearOptionalNestedMessage() |
||||
|
||||
optionalNestedEnum = NestedEnum.BAZ |
||||
clearOptionalNestedEnum() |
||||
|
||||
oneofUint32 = 601 |
||||
clearOneofUint32() |
||||
} |
||||
).isEqualTo( |
||||
TestAllTypes.newBuilder().build() |
||||
) |
||||
} |
||||
|
||||
@Test |
||||
fun testCopy() { |
||||
val message = testAllTypes { |
||||
optionalInt32 = 101 |
||||
optionalString = "115" |
||||
} |
||||
val modifiedMessage = message.copy { |
||||
optionalInt32 = 201 |
||||
} |
||||
|
||||
assertThat(message).isEqualTo( |
||||
TestAllTypes.newBuilder() |
||||
.setOptionalInt32(101) |
||||
.setOptionalString("115") |
||||
.build() |
||||
) |
||||
assertThat(modifiedMessage).isEqualTo( |
||||
TestAllTypes.newBuilder() |
||||
.setOptionalInt32(201) |
||||
.setOptionalString("115") |
||||
.build() |
||||
) |
||||
} |
||||
|
||||
@Test |
||||
fun testOneof() { |
||||
val message = testAllTypes { |
||||
oneofString = "foo" |
||||
assertThat(oneofFieldCase) |
||||
.isEqualTo(TestAllTypes.OneofFieldCase.ONEOF_STRING) |
||||
assertThat(oneofString).isEqualTo("foo") |
||||
clearOneofField() |
||||
assertThat(oneofFieldCase) |
||||
.isEqualTo(TestAllTypes.OneofFieldCase.ONEOFFIELD_NOT_SET) |
||||
oneofUint32 = 5 |
||||
} |
||||
|
||||
assertThat(message.getOneofFieldCase()) |
||||
.isEqualTo(TestAllTypes.OneofFieldCase.ONEOF_UINT32) |
||||
assertThat(message.getOneofUint32()).isEqualTo(5) |
||||
} |
||||
|
||||
@Test |
||||
fun testEmptyMessages() { |
||||
assertThat( |
||||
testEmptyMessage {} |
||||
).isEqualTo( |
||||
TestEmptyMessage.newBuilder().build() |
||||
) |
||||
} |
||||
|
||||
@Test |
||||
fun testEvilNames() { |
||||
assertThat( |
||||
evilNamesProto3 { |
||||
initialized = true |
||||
hasFoo = true |
||||
bar = "foo" |
||||
isInitialized = true |
||||
fooBar = "foo" |
||||
aLLCAPS += "foo" |
||||
aLLCAPSMAP[1] = true |
||||
hasUnderbarPrecedingNumeric1Foo = true |
||||
hasUnderbarPrecedingNumeric42Bar = true |
||||
hasUnderbarPrecedingNumeric123Foo42BarBaz = true |
||||
extension += "foo" |
||||
class_ = "foo" |
||||
int = 1.0 |
||||
long = true |
||||
boolean = 1L |
||||
sealed = "foo" |
||||
interface_ = 1F |
||||
in_ = 1 |
||||
object_ = "foo" |
||||
cachedSize_ = "foo" |
||||
serializedSize_ = true |
||||
value = "foo" |
||||
index = 1L |
||||
values += "foo" |
||||
newValues += "foo" |
||||
builder = true |
||||
k[1] = 1 |
||||
v["foo"] = "foo" |
||||
key["foo"] = 1 |
||||
map[1] = "foo" |
||||
pairs["foo"] = 1 |
||||
LeadingUnderscore = "foo" |
||||
option = 1 |
||||
} |
||||
).isEqualTo( |
||||
EvilNamesProto3.newBuilder() |
||||
.setInitialized(true) |
||||
.setHasFoo(true) |
||||
.setBar("foo") |
||||
.setIsInitialized(true) |
||||
.setFooBar("foo") |
||||
.addALLCAPS("foo") |
||||
.putALLCAPSMAP(1, true) |
||||
.setHasUnderbarPrecedingNumeric1Foo(true) |
||||
.setHasUnderbarPrecedingNumeric42Bar(true) |
||||
.setHasUnderbarPrecedingNumeric123Foo42BarBaz(true) |
||||
.addExtension("foo") |
||||
.setClass_("foo") |
||||
.setInt(1.0) |
||||
.setLong(true) |
||||
.setBoolean(1L) |
||||
.setSealed("foo") |
||||
.setInterface(1F) |
||||
.setIn(1) |
||||
.setObject("foo") |
||||
.setCachedSize_("foo") |
||||
.setSerializedSize_(true) |
||||
.setValue("foo") |
||||
.setIndex(1L) |
||||
.addValues("foo") |
||||
.addNewValues("foo") |
||||
.setBuilder(true) |
||||
.putK(1, 1) |
||||
.putV("foo", "foo") |
||||
.putKey("foo", 1) |
||||
.putMap(1, "foo") |
||||
.putPairs("foo", 1) |
||||
.setLeadingUnderscore("foo") |
||||
.setOption(1) |
||||
.build() |
||||
) |
||||
|
||||
assertThat(class_ {}).isEqualTo(Class.newBuilder().build()) |
||||
} |
||||
|
||||
@Test |
||||
fun testHardKeywordGettersAndSetters() { |
||||
hardKeywordsAllTypesProto3 { |
||||
as_ = 1 |
||||
assertThat(as_).isEqualTo(1) |
||||
|
||||
in_ = "foo" |
||||
assertThat(in_).isEqualTo("foo") |
||||
|
||||
break_ = HardKeywordsAllTypesProto3.NestedEnum.FOO |
||||
assertThat(break_).isEqualTo(HardKeywordsAllTypesProto3.NestedEnum.FOO) |
||||
|
||||
do_ = HardKeywordsAllTypesProto3Kt.nestedMessage { while_ = 1 } |
||||
assertThat(do_).isEqualTo(HardKeywordsAllTypesProto3Kt.nestedMessage { while_ = 1 }) |
||||
|
||||
continue_[1] = 1 |
||||
assertThat(continue_[1]).isEqualTo(1) |
||||
|
||||
else_ += 1 |
||||
assertThat(else_).isEqualTo(listOf(1)) |
||||
|
||||
for_ += "foo" |
||||
assertThat(for_).isEqualTo(listOf("foo")) |
||||
|
||||
fun_ += HardKeywordsAllTypesProto3.NestedEnum.FOO |
||||
assertThat(fun_).isEqualTo(listOf(HardKeywordsAllTypesProto3.NestedEnum.FOO)) |
||||
|
||||
if_ += HardKeywordsAllTypesProto3Kt.nestedMessage { while_ = 1 } |
||||
assertThat(if_).isEqualTo(listOf(HardKeywordsAllTypesProto3Kt.nestedMessage { while_ = 1 })) |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
fun testHardKeywordHazzers() { |
||||
hardKeywordsAllTypesProto3 { |
||||
as_ = 1 |
||||
assertThat(hasAs_()).isTrue() |
||||
|
||||
in_ = "foo" |
||||
assertThat(hasIn_()).isTrue() |
||||
|
||||
break_ = HardKeywordsAllTypesProto3.NestedEnum.FOO |
||||
assertThat(hasBreak_()).isTrue() |
||||
|
||||
do_ = HardKeywordsAllTypesProto3Kt.nestedMessage { while_ = 1 } |
||||
assertThat(hasDo_()).isTrue() |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
fun testHardKeywordClears() { |
||||
hardKeywordsAllTypesProto3 { |
||||
as_ = 1 |
||||
clearAs_() |
||||
assertThat(hasAs_()).isFalse() |
||||
|
||||
in_ = "foo" |
||||
clearIn_() |
||||
assertThat(hasIn_()).isFalse() |
||||
|
||||
break_ = HardKeywordsAllTypesProto3.NestedEnum.FOO |
||||
clearBreak_() |
||||
assertThat(hasBreak_()).isFalse() |
||||
|
||||
do_ = HardKeywordsAllTypesProto3Kt.nestedMessage { while_ = 1 } |
||||
clearDo_() |
||||
assertThat(hasDo_()).isFalse() |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
fun testMultipleFiles() { |
||||
assertThat( |
||||
com.google.protobuf.kotlin.generator.multipleFilesMessageA {} |
||||
).isEqualTo( |
||||
com.google.protobuf.kotlin.generator.MultipleFilesMessageA.newBuilder().build() |
||||
) |
||||
|
||||
assertThat( |
||||
com.google.protobuf.kotlin.generator.multipleFilesMessageB {} |
||||
).isEqualTo( |
||||
com.google.protobuf.kotlin.generator.MultipleFilesMessageB.newBuilder().build() |
||||
) |
||||
} |
||||
} |
@ -0,0 +1,93 @@ |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 Google Inc. All rights reserved. |
||||
// https://developers.google.com/protocol-buffers/ |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
// LINT: LEGACY_NAMES |
||||
syntax = "proto2"; |
||||
|
||||
package protobuf.kotlin.generator; |
||||
|
||||
option java_package = "com.google.protobuf.kotlin.generator"; |
||||
|
||||
message EvilNamesProto2 { |
||||
optional bool initialized = 1; |
||||
optional bool has_foo = 2; |
||||
optional string Bar = 3; |
||||
optional bool is_initialized = 4; |
||||
|
||||
oneof camelCase { |
||||
string fooBar = 5; |
||||
} |
||||
|
||||
repeated string ALL_CAPS = 7; |
||||
map<int32, bool> ALL_CAPS_MAP = 8; |
||||
|
||||
optional bool has_underbar_preceding_numeric_1foo = 9; |
||||
optional bool has_underbar_preceding_numeric_42bar = 13; |
||||
optional bool has_underbar_preceding_numeric_123foo42bar_baz = 14; |
||||
|
||||
extensions 100 to max; |
||||
|
||||
repeated string extension = 12; |
||||
repeated int32 class = 15; |
||||
optional double int = 16; |
||||
optional bool long = 17; |
||||
optional int64 boolean = 18; |
||||
optional string sealed = 19; |
||||
optional float interface = 20; |
||||
optional int32 in = 21; |
||||
optional string object = 22; |
||||
optional string cached_size = 23; |
||||
optional bool serialized_size = 24; |
||||
optional string by = 25; |
||||
} |
||||
|
||||
message HardKeywordsAllTypesProto2 { |
||||
message NestedMessage { |
||||
optional int32 while = 1; |
||||
} |
||||
|
||||
enum NestedEnum { |
||||
FOO = 1; |
||||
BAR = 2; |
||||
} |
||||
|
||||
optional int32 as = 1; |
||||
optional string in = 2; |
||||
optional NestedEnum break = 3; |
||||
map<int32, int32> continue = 4; |
||||
optional NestedMessage do = 5; |
||||
|
||||
repeated int32 else = 6; |
||||
repeated string for = 7; |
||||
repeated NestedEnum fun = 8; |
||||
repeated NestedMessage if = 9; |
||||
} |
||||
|
||||
message Interface {} |
@ -0,0 +1,107 @@ |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 Google Inc. All rights reserved. |
||||
// https://developers.google.com/protocol-buffers/ |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
// LINT: LEGACY_NAMES |
||||
syntax = "proto3"; |
||||
|
||||
package protobuf.kotlin.generator; |
||||
|
||||
option java_package = "com.google.protobuf.kotlin.generator"; |
||||
|
||||
message EvilNamesProto3 { |
||||
bool initialized = 1; |
||||
bool has_foo = 2; |
||||
string Bar = 3; |
||||
bool is_initialized = 4; |
||||
|
||||
oneof camelCase { |
||||
string fooBar = 5; |
||||
} |
||||
|
||||
repeated string ALL_CAPS = 7; |
||||
map<int32, bool> ALL_CAPS_MAP = 8; |
||||
|
||||
bool has_underbar_preceding_numeric_1foo = 9; |
||||
bool has_underbar_preceding_numeric_42bar = 10; |
||||
bool has_underbar_preceding_numeric_123foo42bar_baz = 11; |
||||
|
||||
repeated string extension = 12; |
||||
|
||||
string class = 13; |
||||
double int = 14; |
||||
bool long = 15; |
||||
int64 boolean = 16; |
||||
string sealed = 17; |
||||
float interface = 18; |
||||
int32 in = 19; |
||||
string object = 20; |
||||
string cached_size = 21; |
||||
bool serialized_size = 22; |
||||
string value = 23; |
||||
int64 index = 24; |
||||
repeated string values = 25; |
||||
repeated string new_values = 26; |
||||
bool builder = 27; |
||||
map<int32, int32> k = 28; |
||||
map<string, string> v = 29; |
||||
map<string, int32> key = 30; |
||||
map<int32, string> map = 31; |
||||
map<string, int32> pairs = 32; |
||||
|
||||
string _leading_underscore = 33; |
||||
oneof _leading_underscore_oneof { |
||||
int32 option = 34; |
||||
} |
||||
} |
||||
|
||||
message HardKeywordsAllTypesProto3 { |
||||
message NestedMessage { |
||||
optional int32 while = 1; |
||||
} |
||||
|
||||
enum NestedEnum { |
||||
ZERO = 0; |
||||
FOO = 1; |
||||
BAR = 2; |
||||
} |
||||
|
||||
optional int32 as = 1; |
||||
optional string in = 2; |
||||
optional NestedEnum break = 3; |
||||
map<int32, int32> continue = 4; |
||||
optional NestedMessage do = 5; |
||||
|
||||
repeated int32 else = 6; |
||||
repeated string for = 7; |
||||
repeated NestedEnum fun = 8; |
||||
repeated NestedMessage if = 9; |
||||
} |
||||
|
||||
message Class {} |
@ -0,0 +1,42 @@ |
||||
// Protocol Buffers - Google's data interchange format |
||||
// Copyright 2008 Google Inc. All rights reserved. |
||||
// https://developers.google.com/protocol-buffers/ |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
package protobuf.kotlin.generator; |
||||
|
||||
option java_package = "com.google.protobuf.kotlin.generator"; |
||||
option java_multiple_files = true; |
||||
|
||||
enum NestedEnum { FOO = 0; } |
||||
|
||||
message MultipleFilesMessageA {} |
||||
|
||||
message MultipleFilesMessageB {} |
@ -0,0 +1,278 @@ |
||||
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_test", "kt_jvm_binary") |
||||
load("@rules_java//java:defs.bzl", "java_proto_library") |
||||
load("@rules_jvm_external//:defs.bzl", "java_export") |
||||
load("@rules_proto//proto:defs.bzl", "proto_library") |
||||
load("//:protobuf_version.bzl", "PROTOBUF_VERSION") |
||||
|
||||
# Kotlin generated protos depend on this and only this. |
||||
kt_jvm_library( |
||||
name = "shared_runtime", |
||||
srcs = [ |
||||
"src/main/kotlin/com/google/protobuf/DslList.kt", |
||||
"src/main/kotlin/com/google/protobuf/DslMap.kt", |
||||
"src/main/kotlin/com/google/protobuf/DslProxy.kt", |
||||
"src/main/kotlin/com/google/protobuf/ExtensionList.kt", |
||||
"src/main/kotlin/com/google/protobuf/ProtoDslMarker.kt", |
||||
"src/main/kotlin/com/google/protobuf/UnmodifiableCollections.kt", |
||||
], |
||||
visibility = ["//visibility:public"], |
||||
deps = [ |
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
"//java/lite", |
||||
], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
srcs = ["src/main/kotlin/com/google/protobuf/OnlyForUseByGeneratedProtoCode.kt"], |
||||
visibility = ["//java:__subpackages__"], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "bytestring_lib", |
||||
srcs = ["src/main/kotlin/com/google/protobuf/ByteStrings.kt"], |
||||
deps = ["//java/lite"], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "full_extensions", |
||||
srcs = ["src/main/kotlin/com/google/protobuf/ExtendableMessageExtensions.kt"], |
||||
deps = ["//java/core"], |
||||
) |
||||
|
||||
test_suite( |
||||
name = "tests", |
||||
tests = [ |
||||
"bytestring_test", |
||||
"shared_tests", |
||||
"test_extensions", |
||||
"proto2_test", |
||||
"proto3_test", |
||||
], |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "bytestring_test", |
||||
srcs = ["src/test/kotlin/com/google/protobuf/ByteStringsTest.kt"], |
||||
deps = [ |
||||
":bytestring_lib", |
||||
"//java/lite", |
||||
"@com_github_jetbrains_kotlin//:kotlin-test", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.ByteStringsTest", |
||||
) |
||||
|
||||
proto_library( |
||||
name = "example_extensible_message_proto", |
||||
srcs = ["src/test/proto/com/google/protobuf/example_extensible_message.proto"], |
||||
visibility = ["//visibility:public"], |
||||
) |
||||
|
||||
java_proto_library( |
||||
name = "example_extensible_message_java_proto", |
||||
deps = [":example_extensible_message_proto"], |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "shared_tests", |
||||
srcs = [ |
||||
"src/test/kotlin/com/google/protobuf/DslListTest.kt", |
||||
"src/test/kotlin/com/google/protobuf/DslMapTest.kt", |
||||
"src/test/kotlin/com/google/protobuf/ExtensionListTest.kt", |
||||
], |
||||
deps = [ |
||||
":bytestring_lib", |
||||
":example_extensible_message_java_proto", |
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
":shared_runtime", |
||||
"@com_github_jetbrains_kotlin//:kotlin-test", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:com_google_guava_guava_testlib", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.DslListTest", |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "test_extensions", |
||||
srcs = ["src/test/kotlin/com/google/protobuf/ExtendableMessageExtensionsTest.kt"], |
||||
deps = [ |
||||
":example_extensible_message_java_proto", |
||||
":full_extensions", |
||||
"//java/lite", |
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
":shared_runtime", |
||||
"@com_github_jetbrains_kotlin//:kotlin-test", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.ExtendableMessageExtensionsTest", |
||||
) |
||||
|
||||
proto_library( |
||||
name = "evil_names_proto2", |
||||
srcs = ["src/test/proto/com/google/protobuf/evil_names_proto2.proto"], |
||||
visibility = ["//:__subpackages__"], |
||||
) |
||||
|
||||
proto_library( |
||||
name = "evil_names_proto3", |
||||
srcs = ["src/test/proto/com/google/protobuf/evil_names_proto3.proto"], |
||||
visibility = ["//:__subpackages__"], |
||||
) |
||||
|
||||
java_proto_library( |
||||
name = "evil_names_proto2_java_proto", |
||||
deps = [":evil_names_proto2"], |
||||
) |
||||
|
||||
java_proto_library( |
||||
name = "evil_names_proto3_java_proto", |
||||
deps = [":evil_names_proto3"], |
||||
) |
||||
|
||||
proto_library( |
||||
name = "multiple_files_proto3", |
||||
srcs = ["src/test/proto/com/google/protobuf/multiple_files_proto3.proto"], |
||||
visibility = ["//:__subpackages__"], |
||||
) |
||||
|
||||
java_proto_library( name = "multiple_files_proto3_java_proto", |
||||
deps = [":multiple_files_proto3"], |
||||
) |
||||
|
||||
genrule( |
||||
name = "gen_kotlin_proto3_java_multiple_files", |
||||
srcs = ["src/test/proto/com/google/protobuf/multiple_files_proto3.proto"], |
||||
outs = [ |
||||
"MultipleFilesMessageAKt.kt", |
||||
"MultipleFilesMessageBKt.kt", |
||||
"MultipleFilesProto3Kt.kt", |
||||
], |
||||
cmd = "$(location //:protoc) " + |
||||
"--kotlin_out=shared,immutable:$(@D) " + |
||||
"$(location src/test/proto/com/google/protobuf/multiple_files_proto3.proto) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/MultipleFilesMessageAKt.kt " + |
||||
"$(location MultipleFilesMessageAKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/MultipleFilesMessageBKt.kt " + |
||||
"$(location MultipleFilesMessageBKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/MultipleFilesProto3Kt.kt " + |
||||
"$(location MultipleFilesProto3Kt.kt)", |
||||
tools = ["//:protoc"], |
||||
) |
||||
|
||||
genrule( |
||||
name = "gen_evil_names_proto2", |
||||
srcs = ["src/test/proto/com/google/protobuf/evil_names_proto2.proto"], |
||||
outs = [ |
||||
"EvilNamesProto2Kt.kt", |
||||
"HardKeywordsAllTypesProto2Kt.kt", |
||||
"InterfaceKt.kt", |
||||
], |
||||
cmd = "$(location //:protoc) " + |
||||
"--kotlin_out=shared,immutable:$(@D) " + |
||||
"$(location src/test/proto/com/google/protobuf/evil_names_proto2.proto) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/EvilNamesProto2Kt.kt " + |
||||
"$(location EvilNamesProto2Kt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/HardKeywordsAllTypesProto2Kt.kt " + |
||||
"$(location HardKeywordsAllTypesProto2Kt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/InterfaceKt.kt " + |
||||
"$(location InterfaceKt.kt)", |
||||
tools = ["//:protoc"], |
||||
) |
||||
|
||||
genrule( |
||||
name = "gen_evil_names_proto3", |
||||
srcs = ["src/test/proto/com/google/protobuf/evil_names_proto3.proto"], |
||||
outs = [ |
||||
"ClassKt.kt", |
||||
"EvilNamesProto3Kt.kt", |
||||
"HardKeywordsAllTypesProto3Kt.kt", |
||||
], |
||||
cmd = "$(location //:protoc) " + |
||||
"--kotlin_out=shared,immutable:$(@D) " + |
||||
"$(location src/test/proto/com/google/protobuf/evil_names_proto3.proto) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/ClassKt.kt " + |
||||
"$(location ClassKt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/EvilNamesProto3Kt.kt " + |
||||
"$(location EvilNamesProto3Kt.kt) && " + |
||||
"cp $(@D)/com/google/protobuf/kotlin/generator/HardKeywordsAllTypesProto3Kt.kt " + |
||||
"$(location HardKeywordsAllTypesProto3Kt.kt)", |
||||
tools = ["//:protoc"], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "kotlin_unittest", |
||||
srcs = [ |
||||
":gen_evil_names_proto2", |
||||
"//:gen_kotlin_unittest", |
||||
], |
||||
deps = [ |
||||
":evil_names_proto2_java_proto", |
||||
"//java/core:core", |
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
":shared_runtime", |
||||
"//:java_test_protos", |
||||
], |
||||
) |
||||
|
||||
kt_jvm_library( |
||||
name = "kotlin_proto3_unittest", |
||||
srcs = [ |
||||
":gen_evil_names_proto3", |
||||
":gen_kotlin_proto3_java_multiple_files", |
||||
"//:gen_kotlin_proto3_unittest", |
||||
], |
||||
deps = [ |
||||
":evil_names_proto3_java_proto", |
||||
":multiple_files_proto3_java_proto", |
||||
"//java/core:core", |
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests", |
||||
":shared_runtime", |
||||
"//:java_test_protos", |
||||
], |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "proto2_test", |
||||
srcs = ["src/test/kotlin/com/google/protobuf/Proto2Test.kt"], |
||||
deps = [ |
||||
":kotlin_unittest", |
||||
"//java/core:test_util", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.Proto2Test", |
||||
) |
||||
|
||||
kt_jvm_test( |
||||
name = "proto3_test", |
||||
srcs = ["src/test/kotlin/com/google/protobuf/Proto3Test.kt"], |
||||
deps = [ |
||||
":kotlin_proto3_unittest", |
||||
"//java/core:test_util", |
||||
"@maven//:com_google_truth_truth", |
||||
"@maven//:junit_junit", |
||||
], |
||||
test_class = "com.google.protobuf.kotlin.Proto3Test", |
||||
) |
||||
|
||||
java_export( |
||||
name = "kotlin_mvn", |
||||
maven_coordinates = "com.google.protobuf:protobuf-kotlin:%s" % PROTOBUF_VERSION, |
||||
pom_template = "pom_template.xml", |
||||
runtime_deps = [":shared_runtime"], |
||||
) |
||||
|
||||
filegroup( |
||||
name = "release", |
||||
srcs = [ |
||||
":kotlin_mvn-docs", |
||||
":kotlin_mvn-maven-source", |
||||
":kotlin_mvn-pom", |
||||
":kotlin_mvn-project", |
||||
], |
||||
visibility = ["//java:__pkg__"], |
||||
) |
@ -0,0 +1,23 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>{groupId}</groupId> |
||||
<artifactId>protobuf-parent</artifactId> |
||||
<version>{version}</version> |
||||
</parent> |
||||
|
||||
<artifactId>{artifactId}</artifactId> |
||||
<packaging>{type}</packaging> |
||||
|
||||
<name>Protocol Buffers [Kotlin]</name> |
||||
<description> |
||||
Kotlin core Protocol Buffers library. Protocol Buffers are a way of encoding structured data in an |
||||
efficient yet extensible format. |
||||
</description> |
||||
|
||||
<properties> |
||||
<kotlin.version>1.5.0</kotlin.version> |
||||
</properties> |
||||
|
||||
</project> |
Loading…
Reference in new issue