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

Dsl marker insertions bugfix #32

Merged
merged 1 commit into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Version 0.2.2-RC3
_2018-\*\*-\*\*_

#### Proto Builders (DSL)
* Fix: Resolve ```@DslMarker``` insertion regression introduced in `0.2.2-RC1`


## Version 0.2.2-RC2
_2018-02-17_

Expand Down
44 changes: 44 additions & 0 deletions protoc-gen-kroto-plus/generator-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apply plugin: 'com.google.protobuf'

dependencies{

testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}"
testImplementation "com.google.protobuf:protobuf-java:${Versions.protobuf}"
testImplementation "io.grpc:grpc-protobuf:${Versions.grpc}"
testImplementation "io.grpc:grpc-stub:${Versions.grpc}"
testImplementation "io.grpc:grpc-netty:${Versions.grpc}"

testImplementation project(':kroto-plus-message')
testImplementation project(':kroto-plus-coroutines')
testImplementation project(':kroto-plus-test')
}

protobuf {
protoc { artifact = "com.google.protobuf:protoc:${Versions.protobuf}"}

//noinspection GroovyAssignabilityCheck
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${Versions.grpc}" }
kroto {
path = "${rootProject.projectDir}/protoc-gen-kroto-plus/build/libs/protoc-gen-kroto-plus-${project.version}-jvm8.jar"
}
}

generateProtoTasks {
def krotoConfig = file("krotoPlusConfig.asciipb")

all().each{ task ->
task.inputs.files krotoConfig
task.dependsOn ':protoc-gen-kroto-plus:bootJar'

task.plugins {
grpc { outputSubDir = "java" }
kroto {
outputSubDir = "java"
option "ConfigPath=$krotoConfig"
}
}
}
}
}
12 changes: 12 additions & 0 deletions protoc-gen-kroto-plus/generator-tests/krotoPlusConfig.asciipb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
grpc_coroutines {
filter { exclude_path: "google/*" }
}
proto_builders {
filter { exclude_path: "google/*" }
unwrap_builders: true
use_dsl_markers: true
}
grpc_stub_exts {
support_coroutines: true
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.marcoferrer.krotoplus.generators

import io.grpc.examples.helloworld.HelloReply
import io.grpc.examples.helloworld.HelloRequest
import io.grpc.examples.helloworld.HelloWorldProtoDslBuilder
import org.junit.Test
import test.message.TestMessages
import test.message.TestMessagesDslBuilder

class ProtoBuildersGeneratorTests {

@Test
fun `Test DSL Markers Insertion`(){
assert(HelloRequest.newBuilder() is HelloWorldProtoDslBuilder)
assert(HelloReply.newBuilder() is HelloWorldProtoDslBuilder)
assert(
TestMessages.L1Message2.L2Nested2.L3Nested2.L4Nested1.L5Nested1
.newBuilder() is TestMessagesDslBuilder
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package helloworld;

// The greeting service definition.
service Greeter {

// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply);

// Streams a many greetings
rpc SayHelloStreaming (stream HelloRequest) returns (stream HelloReply);

rpc SayHelloClientStreaming (stream HelloRequest) returns (HelloReply);

rpc SayHelloServerStreaming (HelloRequest) returns (stream HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
string message = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
syntax = "proto3";

package validate.test;

option java_package = "test.message";
option java_outer_classname = "TestMessages";

message L1Message1{

string field = 1;

message L2Nested1{
string field =1;
L1Message1 message_field =2;
}

message L2Nested2{
string field = 1;
L2Nested1 message_field =2;
}
}

message L1Message2{

string field = 1;

message L2Nested1{
string field = 1;
L3Nested1 message_field =2;
message L3Nested1{
string field = 1;
L1Message1 message_field =2;
}
}

message L2Nested2{
string field = 1;

message L3Nested1{
string field = 1;
}

message L3Nested2{
string field = 1;

message L4Nested1{
string field = 1;

message L5Nested1{
string field = 1;
}
}
}
}
}

enum TestEnum {
UNKNOWN = 0;
FIRST = 1;
SECOND = 2;
}

message TestRepeated {
repeated TestEnum enum_field = 1;
repeated int64 int64_field = 2;
repeated fixed64 fixed64_field = 3;
repeated sfixed64 sfixed64_field = 4;
repeated sint64 sint64_field = 5;
repeated uint64 uint64_field = 6;
repeated int32 int32_field = 7;
repeated uint32 uint32_field = 8;
repeated sfixed32 sfixed32_field = 9;
repeated sint32 sint32_field = 10;
repeated fixed32 fixed32_field = 11;
repeated double double_field = 12;
repeated float float_field = 13;
repeated bool bool_field = 14;
repeated string string_field = 15;
repeated bytes bytes_field = 16;
repeated L1Message1 message_field = 17;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object ProtoBuildersGenerator : Generator {
}

// Build DSL Insertions
context.schema.protoTypes.asSequence()
context.schema.protoTypes.values.asSequence()
.filterIsInstance<ProtoMessage>()
.filterNot { it.isMapEntry }
.forEach { protoMessage ->
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginManagement{
}

include 'protoc-gen-kroto-plus'
include 'protoc-gen-kroto-plus:generator-tests'
include 'protoc-gen-grpc-coroutines'
include 'protoc-gen-kroto-plus:docs'
include 'kroto-plus-message'
Expand Down