This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
package io.github.efenglu.protobuf.examples.oneof; | |
option java_multiple_files = true; | |
import "google/protobuf/struct.proto"; | |
service MyDataService { | |
rpc UpateMyData (UpdateMyDataRequest) returns (UpdateMyDataResponse); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<profiles> | |
<profile> | |
<id>release</id> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-javadoc-plugin</artifactId> | |
<version>3.0.0</version> | |
<executions> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<settings xmlns="http://maven.apache.org/settings/1.0.0" | |
> | |
<servers> | |
<server> | |
<id>ossrh</id> | |
<!-- Your sonatype username --> | |
<username></username> | |
<!-- Your sonatype password | |
<password></password> | |
</server> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<distributionManagement> | |
<snapshotRepository> | |
<id>ossrh</id> | |
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | |
</snapshotRepository> | |
<repository> | |
<id>ossrh</id> | |
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> | |
</repository> | |
</distributionManagement> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project> | |
<!-- Typical Name Pattern --> | |
<name>${project.groupId}:${project.artifactId}</name> | |
<!-- Human Readable description --> | |
<description>Parent pom for the full featured parent pom demo</description> | |
<!-- URL To the project page, usually github project page --> | |
<url>https://github.com/efenglu/maven</url> | |
<!-- License for the project, pick a License from opensource.org --> | |
<licenses> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<build> | |
<plugins> | |
<plugin> | |
<groupId>kr.motd.maven</groupId> | |
<artifactId>os-maven-plugin</artifactId> | |
<version>1.6.1</version> | |
<extensions>true</extensions> | |
<executions> | |
<execution> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Stream<PluginProtos.CodeGeneratorResponse.File> handleMessageType(final DescriptorProtos.DescriptorProto messageTypeDesc) { | |
String fileName = javaPackage.replace(".", "/") + "/" + messageTypeDesc.getName() + JAVA_EXTENSION; | |
String builder_methods = messageTypeDesc.getFieldList().stream() | |
.map(this::handleBuilderField) | |
.filter(StringUtils::isNotBlank) | |
.collect(Collectors.joining("\n\n")); | |
List<PluginProtos.CodeGeneratorResponse.File> files = new ArrayList<>(); | |
if (StringUtils.isNotBlank(builder_methods)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Stream<PluginProtos.CodeGeneratorResponse.File> handleProtoFile(final DescriptorProtos.FileDescriptorProto fileDesc) { | |
this.fileDesc = fileDesc; | |
if (fileDesc.getOptions().hasJavaPackage()) { | |
this.javaPackage = fileDesc.getOptions().getJavaPackage(); | |
} else { | |
this.javaPackage = fileDesc.getPackage(); | |
} | |
return Stream.of( | |
fileDesc.getMessageTypeList().stream() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Stream<PluginProtos.CodeGeneratorResponse.File> generate(PluginProtos.CodeGeneratorRequest request) | |
throws GeneratorException { | |
// create a map from proto types to java types | |
this.protoTypeMap = ProtoTypeMap.of(request.getProtoFileList()); | |
return request.getProtoFileList().stream() | |
.filter(file -> request.getFileToGenerateList().contains(file.getName())) | |
.map(this::handleProtoFile) | |
.flatMap(Function.identity()); |