Skip to content

Commit

Permalink
Generating classes for protobuf file
Browse files Browse the repository at this point in the history
  • Loading branch information
mingshi committed May 26, 2022
1 parent c9ec0ee commit 3f8894b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ backend_packages = [
"pants.backend.experimental.java.lint.google_java_format",
"pants.backend.experimental.scala",
"pants.backend.experimental.scala.lint.scalafmt",
"pants.backend.experimental.codegen.protobuf.java",
]

[source]
Expand Down
9 changes: 9 additions & 0 deletions src/jvm/org/pantsbuild/example/lib/ExampleLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
import com.google.common.base.Joiner;
import com.google.common.io.Resources;
import java.io.IOException;
import javax.annotation.Nonnull;
import org.pantsbuild.example.SubmitPynestJobRequest;

public class ExampleLib {
public static String hello() throws IOException {
SubmitPynestJobRequest request = new SubmitPynestJobRequest();
ExampleLib.printScope(request);

String world =
Resources.toString(Resources.getResource(ExampleLib.class, "world.txt"), Charsets.UTF_8)
.strip();
return Joiner.on(" ").join("Hello", world);
}

private static void printScope(@Nonnull final SubmitPynestJobRequest request) {
System.out.println(request.getConfigScope());
}
}
1 change: 1 addition & 0 deletions src/jvm/org/pantsbuild/example/proto/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
protobuf_sources(grpc=True)
32 changes: 32 additions & 0 deletions src/jvm/org/pantsbuild/example/proto/example.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

option java_multiple_files = true;
option java_package = "org.pantsbuild.example";
option java_outer_classname = "DatabricksAPIProto";

package org.pantsbuild.example;


message SubmitPynestJobRequest {
// To deduplicate retried job submits. This will be a UUID token generated by the requester
string idempotency_token = 1;

// The git SHA commit id of the job you want to run
string git_sha = 2;

// The preregisterd job name to run
string job_name = 3;

// The service role to run the job with: e.g. etl, secure_etl, etc.
// If the caller does not have access to the role the request will be rejected
string requested_role = 4;

// A list of arguments to pass to the job
repeated string task_args = 5;

// Config service scope
string config_scope = 6;

// The jar version for a data/jms-package-manager project that you want to run
string jmspm_jar_version = 100;
}

0 comments on commit 3f8894b

Please sign in to comment.