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

Remove explicit dependency on protobuf #221

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "rules_java", version = "6.3.0")
bazel_dep(name = "rules_jvm_external", version = "5.2")
bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# Maven artifacts required by Stardoc; keep consistent with deps.bzl
STARDOC_MAVEN_ARTIFACTS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ java_library(
deps = [
"//src/main/java/com/google/devtools/build/skydoc/rendering",
"//stardoc/proto:stardoc_output_java_proto",
"@com_google_protobuf//:protobuf_java",
"@stardoc_maven//:com_beust_jcommander",
"@stardoc_maven//:com_google_guava_guava",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.RepositoryRuleInfo;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.RuleInfo;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.StarlarkFunctionInfo;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.InvalidProtocolBufferException;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
Expand Down Expand Up @@ -81,9 +79,7 @@ public void println() {
write("\n");
}
}) {
ModuleInfo moduleInfo =
ModuleInfo.parseFrom(
new FileInputStream(inputPath), ExtensionRegistry.getEmptyRegistry());
ModuleInfo moduleInfo = ModuleInfo.parseFrom(new FileInputStream(inputPath));

MarkdownRenderer renderer =
new MarkdownRenderer(
Expand Down Expand Up @@ -161,8 +157,14 @@ public void println() {
printWriter.println(renderer.renderMarkdownFooter(moduleInfo));
}

} catch (InvalidProtocolBufferException e) {
throw new IllegalArgumentException("Input file is not a valid ModuleInfo proto.", e);
} catch (IOException e) {
// Avoid an explicit dependency on the Java protobuf runtime as it should be injected by the
// root module via a proto_lang_toolchain.
if (e.getClass().getName().equals("com.google.protobuf.InvalidProtocolBufferException")) {
throw new IllegalArgumentException("Input file is not a valid ModuleInfo proto.", e);
} else {
throw e;
}
}
}

Expand Down