Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove importresolver package #5

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7beadd7
Use 4 spaces instead of 2 for default indent
pranjalvachaspati-toast Oct 12, 2021
5665e73
Remove message.stg
pranjalvachaspati-toast Oct 13, 2021
2cc5b3a
Remove Descriptor template
pranjalvachaspati-toast Oct 13, 2021
7ecc79f
Remove Descriptor template
pranjalvachaspati-toast Oct 13, 2021
14bd064
Remove dead code in header template and most of services template.
pranjalvachaspati-toast Oct 13, 2021
0861dcd
Set locale for decapitalize to get rid of compiler warning.
pranjalvachaspati-toast Oct 13, 2021
1cca8d0
Remove unused templates
pranjalvachaspati-toast Oct 13, 2021
151e25c
Create subpackage for annotators.
pranjalvachaspati-toast Oct 13, 2021
945b990
Merge branch 'kotlinpoet' of https://github.com/andrewparmet/protokt …
pranjalvachaspati-toast Oct 13, 2021
e24fb1d
Move methodType to kotlinpoet and get rid of services.stg
pranjalvachaspati-toast Oct 13, 2021
0369624
Remove Oneof stringtemplates.
pranjalvachaspati-toast Oct 13, 2021
5964ab4
Get rid of a couple renderers
pranjalvachaspati-toast Oct 13, 2021
46839ce
Migrate boxing & default value renderers away from StringTemplate.
pranjalvachaspati-toast Oct 14, 2021
f12ca3c
Remove sizeof stringtemplates.
pranjalvachaspati-toast Oct 15, 2021
9981c53
Add non-stringtemplate serializer generation
pranjalvachaspati-toast Oct 15, 2021
ec526a1
Get rid of renderers stringtemplate
pranjalvachaspati-toast Oct 15, 2021
91accd6
Remove options stringtemplate
pranjalvachaspati-toast Oct 15, 2021
8aec02e
--amend
pranjalvachaspati-toast Oct 15, 2021
8223782
Merge branch 'kotlinpoet' of https://github.com/andrewparmet/protokt …
pranjalvachaspati-toast Oct 15, 2021
4f4d40a
Convert deserializer to use kotlinpoet
pranjalvachaspati-toast Oct 16, 2021
d4af5e5
Create packages for import resolution and descriptor stuff
pranjalvachaspati-toast Oct 16, 2021
f38ffed
Create packages for import resolution and descriptor stuff
pranjalvachaspati-toast Oct 16, 2021
2125158
This merge required some additional changes - mostly changing Strings…
pranjalvachaspati-toast Oct 18, 2021
9b264a3
Additional changes from Strings to CodeBlocks
pranjalvachaspati-toast Oct 18, 2021
8bb76ce
Disable non-kotlinpoet import resolution
pranjalvachaspati-toast Oct 18, 2021
db9d992
Remove importresolution package
pranjalvachaspati-toast Oct 18, 2021
764782c
Merge branch 'kotlinpoet' of https://github.com/andrewparmet/protokt …
pranjalvachaspati-toast Oct 18, 2021
1f53989
Make fixes for PR comments
pranjalvachaspati-toast Oct 19, 2021
e84eae0
Use DSL typename in DeserializerAnnotator
pranjalvachaspati-toast Oct 19, 2021
a4193df
Remove dependency on stringtemplate
pranjalvachaspati-toast Oct 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'kotlinpoet' of https://github.com/andrewparmet/protokt
…into convert-to-types
  • Loading branch information
pranjalvachaspati-toast committed Oct 18, 2021
commit 764782ca9430e05946d68df65c4346e9f0a5e998
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@
* limitations under the License.
*/

import com.toasttab.protokt.gradle.protokt
import com.toasttab.protokt.gradle.protoktExtensions

apply(plugin = "kotlin-kapt")
plugins {
kotlin("kapt")
}

localProtokt()
enablePublishing()
trackKotlinApiCompatibility(false)

protokt {
lite = true
}

dependencies {
protoktExtensions(project(":extensions:protokt-extensions-simple"))

implementation(project(":extensions:protokt-extensions-api"))
implementation(libraries.autoServiceAnnotations)

add("kapt", libraries.autoService)

protoktExtensions(project(":extensions:protokt-extensions-simple"))
kapt(libraries.autoService)
}
6 changes: 4 additions & 2 deletions extensions/protokt-extensions-simple/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* limitations under the License.
*/

apply(plugin = "kotlin-kapt")
plugins {
kotlin("kapt")
}

enablePublishing()
trackKotlinApiCompatibility()
Expand All @@ -22,5 +24,5 @@ dependencies {
implementation(project(":protokt-core"))
implementation(libraries.autoServiceAnnotations)

add("kapt", libraries.autoService)
kapt(libraries.autoService)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Toast Inc.
* Copyright (c) 2021 Toast Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,21 +13,25 @@
* limitations under the License.
*/

enablePublishing(defaultJars = false)
import com.google.protobuf.gradle.proto
import com.toasttab.protokt.gradle.protokt

localProtokt()
enablePublishing()
trackKotlinApiCompatibility(false)

protokt {
onlyGenerateDescriptors = true
}

dependencies {
api(project(":extensions:protokt-extensions-simple"))
api(project(":extensions:protokt-extensions-proto-based"))
api(project(":extensions:protokt-extensions-api"))
api(project(":extensions:protokt-extensions-lite"))
}

configure<PublishingExtension> {
publications {
create<MavenPublication>("extensionsJar") {
from(project.components["java"])
artifactId = "protokt-extensions"
version = "${rootProject.version}"
groupId = "${rootProject.group}"
sourceSets {
main {
proto {
srcDir("../protokt-extensions-lite/src/main/proto")
}
}
}
2 changes: 1 addition & 1 deletion protokt-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ tasks.withType<Test> {
sourceSets {
main {
proto {
srcDir("../protokt-runtime/src/main/resources")
srcDir("../extensions/protokt-extensions-lite/src/main/proto")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.squareup.kotlinpoet.LambdaTypeName
import com.squareup.kotlinpoet.ParameterSpec
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.TypeSpec
import com.squareup.kotlinpoet.TypeVariableName
import com.squareup.kotlinpoet.asTypeName
import com.squareup.kotlinpoet.buildCodeBlock
import com.toasttab.protokt.codegen.annotators.Annotator.Context
Expand Down Expand Up @@ -97,7 +96,7 @@ private constructor(

addModifiers(KModifier.OVERRIDE)
addParameter("deserializer", KtMessageDeserializer::class)
returns(TypeVariableName(msg.name))
returns(msg.typeName)

if (properties.isNotEmpty()) {
properties.forEach { addStatement("var %L", deserializeVar(it)) }
Expand All @@ -107,9 +106,7 @@ private constructor(
beginControlFlow("when(deserializer.readTag())")
addStatement("0 -> return·%N(%L)", msg.name, constructorLines(properties))
deserializerInfo.forEach() { addStatement("%L -> %L = %L", it.tag, it.assignment.fieldName, it.assignment.value) }
// We need to do this statement as two addStatements because otherwise it wraps the line after also, which is invalid Kotlin.
addStatement("else -> unknownFields = (unknownFields ?: %T.Builder()).also {", UnknownFieldSet::class)
addStatement("it.add(deserializer.readUnknown()) }")
addStatement("else -> unknownFields = (unknownFields ?: %T.Builder()).also·{it.add(deserializer.readUnknown()) }", UnknownFieldSet::class)
endControlFlow()
endControlFlow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ private constructor(
) =
Info(
fieldName = f.fieldName,
type = if (f.wrapped) {
type =
if (f.wrapped) {
interceptTypeName(
f,
TypeVariableName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private constructor(
}

private fun name(f: StandardField) = when (f.type) {
FieldType.ENUM -> f.typePClass.renderName(ctx.pkg)
FieldType.ENUM -> f.typePClass.qualifiedName
else -> ""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MainTest {
"--plugin=protoc-gen-custom=$binGenerator",
"--custom_out=.", // ignored
"-I$codegenTestingProto",
"-I$runtimeResources",
"-I$extensionsProto",
"-I$includeProtos",
buildPluginOptions(ext),
"$testProto"
Expand Down Expand Up @@ -90,8 +90,8 @@ private val codegenTestingProto =
private val testProto =
File(codegenTestingProto.toFile(), "test.proto")

private val runtimeResources =
Path.of("protokt-runtime", "src", "main", "resources")
private val extensionsProto =
Path.of("extensions", "protokt-extensions-lite", "src", "main", "proto")

private val generatedFile =
File(
Expand Down
15 changes: 4 additions & 11 deletions protokt-core-lite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
* limitations under the License.
*/

import com.google.protobuf.gradle.proto
import com.google.protobuf.gradle.protobuf
import com.toasttab.protokt.gradle.protokt

apply(plugin = "kotlin-kapt")
plugins {
kotlin("kapt")
}

localProtokt()
pureKotlin()
Expand All @@ -38,13 +39,5 @@ dependencies {

implementation(libraries.autoServiceAnnotations)

add("kapt", libraries.autoService)
}

sourceSets {
main {
proto {
srcDir("../protokt-runtime/src/main/resources")
}
}
kapt(libraries.autoService)
}
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ include(
"extensions",
"extensions:protokt-extensions-api",
"extensions:protokt-extensions-simple",
"extensions:protokt-extensions-proto-based",
"extensions:publish",
"extensions:protokt-extensions",
"extensions:protokt-extensions-lite",

"testing:android",
"testing:android-test-configurations",
Expand Down
2 changes: 1 addition & 1 deletion testing/options-test-configurations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pureKotlin()

dependencies {
testProtoktExtensions(project(":testing:options-api"))
testProtoktExtensions(project(":extensions:publish"))
testProtoktExtensions(project(":extensions:protokt-extensions"))

testProtobuf(project(":testing:options"))
}
2 changes: 1 addition & 1 deletion testing/options/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protokt {

dependencies {
protoktExtensions(project(":testing:options-api"))
protoktExtensions(project(":extensions:publish"))
protoktExtensions(project(":extensions:protokt-extensions"))

implementation(libraries.grpcStub)

Expand Down
2 changes: 2 additions & 0 deletions testing/plugin-options/lite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

import com.toasttab.protokt.gradle.protokt
import com.toasttab.protokt.gradle.protoktExtensions

localProtokt()
pureKotlin()
Expand All @@ -23,5 +24,6 @@ protokt {
}

dependencies {
protoktExtensions(project(":extensions:protokt-extensions-lite"))
testImplementation(kotlin("reflect"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@

package com.toasttab.protokt.testing.pluginoptions

import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import toasttab.protokt.testing.lite.LiteEnum
import toasttab.protokt.testing.lite.LiteMessage
import kotlin.reflect.full.declaredMemberProperties

class LiteOptionTest {
@Test
Expand All @@ -31,23 +27,16 @@ class LiteOptionTest {
}

@Test
fun `enum has no descriptor reference`() {
assertThat(
LiteEnum.Deserializer::class.declaredMemberProperties.map { it.name }
).doesNotContain("descriptor")
}

@Test
fun `message has no descriptor reference`() {
assertThat(
LiteMessage.Deserializer::class.declaredMemberProperties.map { it.name }
).doesNotContain("descriptor")
fun `service descriptor doesn't exist`() {
assertThrows<ClassNotFoundException> {
Class.forName("toasttab.protokt.testing.lite.LiteService")
}
}

@Test
fun `service descriptor doesn't exist`() {
fun `protokt descriptor isn't available`() {
assertThrows<ClassNotFoundException> {
Class.forName("toasttab.protokt.testing.lite.LiteService")
Class.forName("com.toasttab.protokt.ext.Protokt")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ syntax = "proto3";
package toasttab.protokt.testing.lite;

import "google/protobuf/wrappers.proto";
import "protokt/ext/inet_socket_address.proto";
import "protokt/protokt.proto";

message LiteMessage {}

Expand All @@ -37,4 +39,6 @@ message WellKnownTypesLite {
google.protobuf.BoolValue bool = 7;
google.protobuf.StringValue string = 8;
google.protobuf.BytesValue bytes = 9;

.protokt.ext.InetSocketAddress address = 10 [(.protokt.property).wrap = "java.net.InetSocketAddress"];
}
You are viewing a condensed version of this merge commit. You can view the full changes here.