This page documents the packaging and distribution strategies for Protocol Buffer language implementations not covered in previous sections. It focuses on how Protocol Buffers integrates with language-specific package managers and build systems, including Maven (Java), CocoaPods (Objective-C), PyPI (Python), and npm (JavaScript).
The Java implementation is a multi-module project managed by Maven. It provides separate runtimes for full features and resource-constrained environments (Lite).
The Java implementation provides five distinct artifacts coordinated through protobuf-parent and protobuf-bom:
Java Module Hierarchy
| Module | Artifact ID | Purpose | Target Platform |
|---|---|---|---|
| Parent | protobuf-parent | Maven parent POM managing all modules | Build coordination |
| BOM | protobuf-bom | Bill of Materials for version management | Dependency management |
| Core | protobuf-java | Full-featured runtime with reflection and descriptors | Server-side Java |
| Lite | protobuf-java-lite | Stripped-down runtime without reflection | Android, Embedded |
| Util | protobuf-java-util | JSON conversion and utilities | Web/JSON Interop |
Sources: java/pom.xml1-8 java/pom.xml284-291 java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java1-100 java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java1-100 java/util/src/main/java/com/google/protobuf/util/JsonFormat.java1-100
The Java runtime maintains compatibility with Java 8 and Android API level 21.
GeneratedMessageV3 java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java1-50 as the base for generated code.GeneratedMessageLite java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java1-50 to minimize binary size and method count.CodedInputStream java/core/src/main/java/com/google/protobuf/CodedInputStream.java1-100 and CodedOutputStream java/core/src/main/java/com/google/protobuf/CodedOutputStream.java1-100The Objective-C implementation distributes through CocoaPods as the Protobuf pod. It uses a custom runtime optimized for Apple platforms.
The Objective-C runtime is centered around GPBMessage and uses a descriptor-based approach for message metadata.
Objective-C Code Entity Mapping
GPBMessage objectivec/GPBMessage.m1-100GPBDescriptor objectivec/GPBDescriptor.m1-100GPBAny.pbobjc.m objectivec/GPBAny.pbobjc.m1-50 and GPBTimestamp.pbobjc.m objectivec/GPBTimestamp.pbobjc.m1-50GPBAny__storage_) within the Objective-C class to manage memory efficiently objectivec/GPBAny.pbobjc.m57-61Sources: objectivec/GPBMessage.m1-100 objectivec/GPBDescriptor.m1-100 objectivec/GPBAny.pbobjc.m50-61 objectivec/GPBTimestamp.pbobjc.m50-61
Python provides multiple backends (Pure Python, C++ extension, and UPB) distributed via PyPI.
The Python implementation dynamically selects the best available backend based on the environment.
Python Backend Interaction
python/google/protobuf/pyext/ python/google/protobuf/pyext/message.cc1-100 It wraps the core C++ runtime for maximum performance.python/message.c python/message.c1-100 and python/descriptor.c python/descriptor.c1-100 This is a lightweight alternative using the UPB runtime.PyUpb_Message struct manages the mapping between Python objects and underlying C messages python/message.c169-180python/convert.c python/convert.c1-50 which manages type translation between Python types and wire format.Sources: python/message.c1-61 python/google/protobuf/pyext/message.cc1-100 python/descriptor.c1-100 python/google/protobuf/internal/python_message.py1-100
The JavaScript implementation is distributed via npm. The build system uses Bazel to coordinate the generation of these language-specific artifacts.
The protobuf.bzl file defines the rules for generating code across these languages:
_ObjcOuts generates .pbobjc.h and .pbobjc.m files protobuf.bzl53-58_PyOuts generates _pb2.py files protobuf.bzl60-64Sources: protobuf.bzl41-76 python/dist/BUILD.bazel1-50
| Language | Distribution | Key Classes/Files | Base Runtime |
|---|---|---|---|
| Java | Maven | GeneratedMessageV3, CodedInputStream | Java JRE |
| Objective-C | CocoaPods | GPBMessage, GPBDescriptor | Foundation |
| Python | PyPI | Message, Descriptor, pyext/ | CPython/UPB |
| JavaScript | npm | jspb.Message | Node.js/Browser |
Sources: java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java1-50 objectivec/GPBMessage.m1-50 python/message.c1-50 protobuf.bzl1-100