cd protos
bazel build //...
- Run the provided script to generate Java files from proto files:
./tools/java/generate_java.sh
This script will:
- Build the Java proto library using Bazel
- Find all source JAR files containing generated Java code
- Extract the Java files to the
generated/java
directory
- You can find the generated Java files in the
generated/java
directory:
find generated/java -name "*.java" | sort
To package the generated Java files into a Maven-compatible JAR that can be used as a Gradle dependency:
- Run the provided script:
./tools/java/package_proto_jar.sh
This script will:
- Generate Java files from proto files (if not already done)
- Download the protobuf-java dependency
- Compile the Java files
- Create a Maven-compatible JAR file
- Install the JAR to your local Maven repository
- To use the JAR in a Gradle project, add the following to your build.gradle:
repositories {
mavenLocal()
}
dependencies {
implementation 'opensearch.proto:opensearch-proto:1.0.0'
}
TODO: The script uses a raw protoc command right now. Ideally, it should use bazel in the future.
Run the provided script to generate Python files from proto files:
./tools/python/generate_python.sh
This script will:
- Use protoc to generate Python code from proto files
- Create the necessary directory structure with init.py files
- Organize the generated files in the
generated/python
directory
You can import the generated code in Python with:
from opensearch.proto import common_pb2, document_pb2
from opensearch.proto.services import document_service_pb2
TODO: The script uses a raw protoc command right now. Ideally, it should use bazel in the future.
Run the provided script to generate Go files from proto files:
./tools/go/generate_go.sh
This script will:
- Use protoc to generate Go code from proto files
- Create the necessary directory structure
- Create a go.mod file for the generated code
- Place the generated files in the
generated/go
directory
You can import the generated code in Go with:
import "github.com/opensearch/proto"
import "github.com/opensearch/proto/services"
All generated files are excluded from version control via the .gitignore
file. This includes:
- Bazel generated files (bazel-*)
- Generated files (generated/)
- Compiled class files (*.class)
- Package files (*.jar)