Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc-gen-grpc-java 1.68.2 (new formula) #199494

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Formula/a/apache-pulsar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ class ApachePulsar < Formula
end

depends_on "maven" => :build
depends_on arch: :x86_64 # https://github.com/grpc/grpc-java/issues/7690
depends_on "protoc-gen-grpc-java" => :build
depends_on "openjdk@21"

def install
# Avoid using pre-built `protoc-gen-grpc-java`
grpc_java_files = ["pulsar-client/pom.xml", "pulsar-functions/proto/pom.xml"]
plugin_artifact = "io.grpc:protoc-gen-grpc-java:${protoc-gen-grpc-java.version}:exe:${os.detected.classifier}"
inreplace grpc_java_files, %r{<pluginArtifact>#{Regexp.escape(plugin_artifact)}\s*</pluginArtifact>}, ""

java_home_env = Language::Java.java_home_env("21")
with_env(TMPDIR: buildpath, **java_home_env) do
system "mvn", "clean", "package", "-DskipTests", "-Pcore-modules"
Expand Down Expand Up @@ -60,7 +65,8 @@ def post_install
spawn bin/"pulsar", "standalone", "--zookeeper-dir", "#{testpath}/zk", "--bookkeeper-dir", "#{testpath}/bk"
# The daemon takes some time to start; pulsar-client will retry until it gets a connection, but emit confusing
# errors until that happens, so sleep to reduce log spam.
sleep 45
sleep 30
sleep 30 if OS.mac? && Hardware::CPU.intel?

output = shell_output("#{bin}/pulsar-client produce my-topic --messages 'hello-pulsar'")
assert_match "1 messages successfully produced", output
Expand Down
42 changes: 42 additions & 0 deletions Formula/p/protoc-gen-grpc-java.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class ProtocGenGrpcJava < Formula

Check notice on line 1 in Formula/p/protoc-gen-grpc-java.rb

View workflow job for this annotation

GitHub Actions / Linux

Bottle cache hit

Bottle for protoc-gen-grpc-java built at a2d7bb7c556 (Merge ccad51c6469c4559494b93c7813e96b6e5849b24 into cc93d996bcfedc84db0c51b023afb7085edd5300, 2024-11-30)

Check notice on line 1 in Formula/p/protoc-gen-grpc-java.rb

View workflow job for this annotation

GitHub Actions / macOS 15-arm64

Bottle cache hit

Bottle for protoc-gen-grpc-java built at a2d7bb7c556 (Merge ccad51c6469c4559494b93c7813e96b6e5849b24 into cc93d996bcfedc84db0c51b023afb7085edd5300, 2024-11-30)

Check notice on line 1 in Formula/p/protoc-gen-grpc-java.rb

View workflow job for this annotation

GitHub Actions / macOS 14-arm64

Bottle cache hit

Bottle for protoc-gen-grpc-java built at a2d7bb7c556 (Merge ccad51c6469c4559494b93c7813e96b6e5849b24 into cc93d996bcfedc84db0c51b023afb7085edd5300, 2024-11-30)

Check notice on line 1 in Formula/p/protoc-gen-grpc-java.rb

View workflow job for this annotation

GitHub Actions / macOS 13-arm64

Bottle cache hit

Bottle for protoc-gen-grpc-java built at a2d7bb7c556 (Merge ccad51c6469c4559494b93c7813e96b6e5849b24 into cc93d996bcfedc84db0c51b023afb7085edd5300, 2024-11-30)

Check notice on line 1 in Formula/p/protoc-gen-grpc-java.rb

View workflow job for this annotation

GitHub Actions / macOS 13-x86_64

Bottle cache hit

Bottle for protoc-gen-grpc-java built at a2d7bb7c556 (Merge ccad51c6469c4559494b93c7813e96b6e5849b24 into cc93d996bcfedc84db0c51b023afb7085edd5300, 2024-11-30)
desc "Protoc plugin for gRPC Java"
homepage "https://grpc.io/docs/languages/java/"
url "https://github.com/grpc/grpc-java/archive/refs/tags/v1.68.2.tar.gz"
sha256 "dc1ad2272c1442075c59116ec468a7227d0612350c44401237facd35aab15732"
license "Apache-2.0"

depends_on "openjdk@21" => :build # due to Gradle 8.5
depends_on "pkgconf" => :build
depends_on "abseil"
depends_on "protobuf"

def install
# Workaround for newer Protobuf to link to Abseil libraries
# Ref: https://github.com/grpc/grpc-java/issues/11475
ENV.append "CXXFLAGS", "-std=c++17"
ENV.append "CXXFLAGS", Utils.safe_popen_read("pkgconf", "--cflags", "protobuf").chomp
ENV.append "LDFLAGS", Utils.safe_popen_read("pkgconf", "--libs", "protobuf").chomp

inreplace "compiler/build.gradle" do |s|
# Avoid build errors on ARM macOS from old minimum macOS deployment
s.gsub! '"-mmacosx-version-min=10.7",', ""
# Avoid static linkage on Linux
s.gsub! '"-Wl,-Bstatic"', "\"-L#{Formula["protobuf"].opt_lib}\""
s.gsub! ', "-static-libgcc"', ""
end

# Fails with brew `gradle` due to animalsniffer 1.7.1
# Ref: https://github.com/xvik/gradle-animalsniffer-plugin/issues/100
system "./gradlew", "--no-daemon", "--project-dir=compiler", "-PskipAndroid=true", "java_pluginExecutable"
bin.install "compiler/build/exe/java_plugin/protoc-gen-grpc-java"

pkgshare.install "examples/src/main/proto/helloworld.proto"
end

test do
system Formula["protobuf"].bin/"protoc", "--grpc-java_out=.", "--proto_path=#{pkgshare}", "helloworld.proto"
output_file = testpath/"io/grpc/examples/helloworld/GreeterGrpc.java"
assert_path_exists output_file
assert_match "public io.grpc.examples.helloworld.HelloReply sayHello(", output_file.read
end
end
Loading