Skip to content

Commit fa6df45

Browse files
authored
Use protobuf package for gRPC service qualification, not the Kotlin package (#49)
* use protobuf package for gRPC service qualification, not the kotlin package * gradle 6.4 and depend on grpc-stub
1 parent 62a6349 commit fa6df45

File tree

7 files changed

+58
-2
lines changed

7 files changed

+58
-2
lines changed

gradle/wrapper/gradle-wrapper.jar

-1 Bytes
Binary file not shown.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

protokt-codegen/src/main/kotlin/com/toasttab/protokt/codegen/impl/ServiceAnnotator.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal object ServiceAnnotator {
3838
if (ctx.pkg.default) {
3939
s.name
4040
} else {
41-
"${ctx.pkg}.${s.name}"
41+
"${ctx.desc.packageName}.${s.name}"
4242
}
4343

4444
private fun renderDescriptor(s: Service) =

testing/plugin-options/ignore-java-package/build.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ sourceSets {
3030
protokt {
3131
respectJavaPackage = false
3232
}
33+
34+
dependencies {
35+
implementation(project(":protokt-runtime-grpc"))
36+
implementation(libraries.grpcStub)
37+
}

testing/runtime-tests/build.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ pureKotlin()
1818

1919
dependencies {
2020
implementation(kotlin("reflect"))
21+
implementation(project(":protokt-runtime-grpc"))
2122
implementation(project(":testing:protobuf-java"))
23+
implementation(libraries.grpcStub)
2224

2325
testImplementation(libraries.jackson)
2426
testImplementation(libraries.protobuf)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2020 Toast Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
syntax = "proto3";
17+
18+
package toasttab.protokt.testing.rt;
19+
20+
option java_package = "com.toasttab.protokt.testing.rt";
21+
22+
service TestService {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2020 Toast Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
package com.toasttab.protokt.testing.rt
17+
18+
import com.google.common.truth.Truth.assertThat
19+
import org.junit.jupiter.api.Test
20+
21+
class ServicePackageTest {
22+
@Test
23+
fun `service has protobuf package`() {
24+
assertThat(TestServiceGrpc.SERVICE_NAME.substringBeforeLast("."))
25+
.isEqualTo("toasttab.protokt.testing.rt")
26+
}
27+
}

0 commit comments

Comments
 (0)