mirror of https://github.com/grpc/grpc-java.git
compiler: Add option to disable version output
If the option becomes popular, we can just remove the version.
This commit is contained in:
parent
ab65c797bf
commit
182164eafc
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: services.proto")
|
||||
public final class BenchmarkServiceGrpc {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: services.proto")
|
||||
public final class ReportQpsScenarioServiceGrpc {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: services.proto")
|
||||
public final class WorkerServiceGrpc {
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ subprojects {
|
|||
// To generate deprecated interfaces and static bindService method,
|
||||
// turn the enable_deprecated option to true below:
|
||||
option 'enable_deprecated=false'
|
||||
option 'noversion'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1023,14 +1023,16 @@ static void PrintService(const ServiceDescriptor* service,
|
|||
std::map<string, string>* vars,
|
||||
Printer* p,
|
||||
ProtoFlavor flavor,
|
||||
bool enable_deprecated) {
|
||||
bool enable_deprecated,
|
||||
bool disable_version) {
|
||||
(*vars)["service_name"] = service->name();
|
||||
(*vars)["file_name"] = service->file()->name();
|
||||
(*vars)["service_class_name"] = ServiceClassName(service);
|
||||
#ifdef GRPC_VERSION
|
||||
(*vars)["grpc_version"] = " (version " XSTR(GRPC_VERSION) ")";
|
||||
#else
|
||||
(*vars)["grpc_version"] = "";
|
||||
#ifdef GRPC_VERSION
|
||||
if (!disable_version) {
|
||||
(*vars)["grpc_version"] = " (version " XSTR(GRPC_VERSION) ")";
|
||||
}
|
||||
#endif
|
||||
// TODO(nmittler): Replace with WriteServiceDocComment once included by protobuf distro.
|
||||
GrpcWriteServiceDocComment(p, service);
|
||||
|
@ -1168,7 +1170,8 @@ void PrintImports(Printer* p, bool generate_nano) {
|
|||
void GenerateService(const ServiceDescriptor* service,
|
||||
google::protobuf::io::ZeroCopyOutputStream* out,
|
||||
ProtoFlavor flavor,
|
||||
bool enable_deprecated) {
|
||||
bool enable_deprecated,
|
||||
bool disable_version) {
|
||||
// All non-generated classes must be referred by fully qualified names to
|
||||
// avoid collision with generated classes.
|
||||
std::map<string, string> vars;
|
||||
|
@ -1212,7 +1215,7 @@ void GenerateService(const ServiceDescriptor* service,
|
|||
if (!vars["Package"].empty()) {
|
||||
vars["Package"].append(".");
|
||||
}
|
||||
PrintService(service, &vars, &printer, flavor, enable_deprecated);
|
||||
PrintService(service, &vars, &printer, flavor, enable_deprecated, disable_version);
|
||||
}
|
||||
|
||||
string ServiceJavaPackage(const FileDescriptor* file, bool nano) {
|
||||
|
|
|
@ -50,7 +50,8 @@ string ServiceClassName(const google::protobuf::ServiceDescriptor* service);
|
|||
void GenerateService(const google::protobuf::ServiceDescriptor* service,
|
||||
google::protobuf::io::ZeroCopyOutputStream* out,
|
||||
ProtoFlavor flavor,
|
||||
bool enable_deprecated);
|
||||
bool enable_deprecated,
|
||||
bool disable_version);
|
||||
|
||||
} // namespace java_grpc_generator
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
|
|||
java_grpc_generator::ProtoFlavor::NORMAL;
|
||||
|
||||
bool enable_deprecated = false;
|
||||
bool disable_version = false;
|
||||
for (size_t i = 0; i < options.size(); i++) {
|
||||
if (options[i].first == "nano") {
|
||||
flavor = java_grpc_generator::ProtoFlavor::NANO;
|
||||
|
@ -45,6 +46,8 @@ class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
|
|||
flavor = java_grpc_generator::ProtoFlavor::LITE;
|
||||
} else if (options[i].first == "enable_deprecated") {
|
||||
enable_deprecated = options[i].second == "true";
|
||||
} else if (options[i].first == "noversion") {
|
||||
disable_version = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +60,8 @@ class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
|
|||
+ java_grpc_generator::ServiceClassName(service) + ".java";
|
||||
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
|
||||
context->Open(filename));
|
||||
java_grpc_generator::GenerateService(service, output.get(), flavor, enable_deprecated);
|
||||
java_grpc_generator::GenerateService(
|
||||
service, output.get(), flavor, enable_deprecated, disable_version);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: load_balancer.proto")
|
||||
public final class LoadBalancerGrpc {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/testing/integration/metrics.proto")
|
||||
public final class MetricsServiceGrpc {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/testing/integration/test.proto")
|
||||
public final class ReconnectServiceGrpc {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/testing/integration/test.proto")
|
||||
public final class TestServiceGrpc {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/testing/integration/test.proto")
|
||||
public final class UnimplementedServiceGrpc {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: health.proto")
|
||||
public final class HealthGrpc {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: grpc/instrumentation/v1alpha/monitoring.proto")
|
||||
public final class MonitoringGrpc {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/reflection/v1alpha/reflection.proto")
|
||||
public final class ServerReflectionGrpc {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/reflection/testing/dynamic_reflection_test.proto")
|
||||
public final class AnotherDynamicServiceGrpc {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/reflection/testing/dynamic_reflection_test.proto")
|
||||
public final class DynamicServiceGrpc {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/reflection/testing/reflection_test.proto")
|
||||
public final class ReflectableServiceGrpc {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.7.0-SNAPSHOT)",
|
||||
value = "by gRPC proto compiler",
|
||||
comments = "Source: io/grpc/testing/protobuf/simpleservice.proto")
|
||||
public final class SimpleServiceGrpc {
|
||||
|
||||
|
|
Loading…
Reference in New Issue