diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2018-04-12 17:58:55 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2018-04-12 17:58:55 -0700 |
commit | 7d55040eebab0f2345e6d73905137a030bef35bb (patch) | |
tree | 09edcffd8dc3c94221a30147774a81b42a82e7a5 /java/lite.md | |
parent | 320d56c833f835f40c56bdaf2a375768cdd1b334 (diff) |
Cleanup + documentation for Java Lite runtime.
Diffstat (limited to 'java/lite.md')
-rw-r--r-- | java/lite.md | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/java/lite.md b/java/lite.md new file mode 100644 index 00000000..84a45ec5 --- /dev/null +++ b/java/lite.md @@ -0,0 +1,50 @@ +# Protocol Buffers - Google's data interchange format + +Copyright 2008 Google Inc. + +https://developers.google.com/protocol-buffers/ + +## Use Protobuf Java Lite Runtime + +Protobuf Java Lite runtime is separated from the main Java runtime because +it's designed/implemented with different constraints. In particular, Java +Lite runtime has a much smaller code size which makes it more suitable to +be used on Android. + +To use Java Lite runtime, you need to install protoc and the protoc plugin for +Java Lite runtime. You can obtain protoc following the instructions in the +toplevel [README.md](../README.md) file. For the protoc plugin, you can +download it from maven: + + https://repo1.maven.org/maven2/com/google/protobuf/protoc-gen-javalite/ + +Choose the version that works on your platform (e.g., on windows you can +download `protoc-gen-javalite-3.0.0-windows-x86_32.exe`), rename it to +protoc-gen-javalite (or protoc-gen-javalite.exe on windows) and place it +in a directory where it can be find in PATH. + +Once you have the protoc and protoc plugin, you can generate Java Lite code +for your .proto files: + + $ protoc --javalite_out=${OUTPUT_DIR} path/to/your/proto/file + +Include the generated Java files in your project and add a dependency on the +protobuf Java runtime. If you are using Maven, use the following: + +```xml +<dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-lite</artifactId> + <version>3.0.1</version> +</dependency> +``` + +Make sure the version number of the runtime matches (or is newer than) the +version number of the protoc plugin. The version number of the protoc doesn't +matter and any version >= 3.0.0 should work. + +### Use Protobuf Java Lite Runtime with Bazel + +Bazel has native build rules to work with protobuf. For Java Lite runtime, +you can use the `java_lite_proto_library` rule. Check out [our build files +examples](../examples/BUILD) to learn how to use it. |