Print compiler version number in generated files
diff --git a/compiler/build.gradle b/compiler/build.gradle
index 30c5dca..240e57d 100644
--- a/compiler/build.gradle
+++ b/compiler/build.gradle
@@ -75,6 +75,7 @@
   binaries {
     all {
       if (toolChain in Gcc || toolChain in Clang) {
+        cppCompiler.define("GRPC_VERSION", version)
         cppCompiler.args "--std=c++0x"
         addEnvArgs("CXXFLAGS", cppCompiler.args)
         addEnvArgs("CPPFLAGS", cppCompiler.args)
@@ -95,6 +96,7 @@
         }
         addEnvArgs("LDFLAGS", linker.args)
       } else if (toolChain in VisualCpp) {
+        cppCompiler.define("GRPC_VERSION", version)
         cppCompiler.args "/EHsc", "/MT"
         if (rootProject.hasProperty('vcProtobufInclude')) {
           cppCompiler.args "/I${rootProject.vcProtobufInclude}"
diff --git a/compiler/src/java_plugin/cpp/java_generator.cpp b/compiler/src/java_plugin/cpp/java_generator.cpp
index 0aadd18..f59f2cd 100644
--- a/compiler/src/java_plugin/cpp/java_generator.cpp
+++ b/compiler/src/java_plugin/cpp/java_generator.cpp
@@ -9,6 +9,15 @@
 #include <google/protobuf/io/printer.h>
 #include <google/protobuf/io/zero_copy_stream.h>
 
+// Stringify helpers used solely to cast GRPC_VERSION
+#ifndef STR
+#define STR(s) #s
+#endif
+
+#ifndef XSTR
+#define XSTR(s) STR(s)
+#endif
+
 namespace java_grpc_generator {
 
 using google::protobuf::FileDescriptor;
@@ -698,10 +707,15 @@
   (*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"] = "";
+  #endif
   p->Print(
       *vars,
       "@$Generated$(\n"
-      "    value = \"by gRPC proto compiler\",\n"
+      "    value = \"by gRPC proto compiler$grpc_version$\",\n"
       "    comments = \"Source: $file_name$\")\n"
       "public class $service_class_name$ {\n\n");
   p->Indent();
diff --git a/compiler/src/test/golden/TestService.java.txt b/compiler/src/test/golden/TestService.java.txt
index cd82a81..ac6db78 100644
--- a/compiler/src/test/golden/TestService.java.txt
+++ b/compiler/src/test/golden/TestService.java.txt
@@ -16,7 +16,7 @@
 import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
 
 @javax.annotation.Generated(
-    value = "by gRPC proto compiler",
+    value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
     comments = "Source: test.proto")
 public class TestServiceGrpc {
 
diff --git a/compiler/src/testLite/golden/TestService.java.txt b/compiler/src/testLite/golden/TestService.java.txt
index 1270fc7..cb76da8 100644
--- a/compiler/src/testLite/golden/TestService.java.txt
+++ b/compiler/src/testLite/golden/TestService.java.txt
@@ -16,7 +16,7 @@
 import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
 
 @javax.annotation.Generated(
-    value = "by gRPC proto compiler",
+    value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
     comments = "Source: test.proto")
 public class TestServiceGrpc {
 
diff --git a/compiler/src/testNano/golden/TestService.java.txt b/compiler/src/testNano/golden/TestService.java.txt
index 88dc9cd..ccd028e 100644
--- a/compiler/src/testNano/golden/TestService.java.txt
+++ b/compiler/src/testNano/golden/TestService.java.txt
@@ -18,7 +18,7 @@
 import java.io.IOException;
 
 @javax.annotation.Generated(
-    value = "by gRPC proto compiler",
+    value = "by gRPC proto compiler (version 0.14.0-SNAPSHOT)",
     comments = "Source: test.proto")
 public class TestServiceGrpc {