From d1cc0f8b1c7bcc53c968a359d71d31afa5ac9f5b Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Fri, 1 Sep 2023 11:18:31 -0500 Subject: [PATCH] Improve code generation in connect-kotlin (#86) --- .gitignore | 7 - Makefile | 11 +- crosstests/buf.gen.yaml | 12 +- crosstests/google-java/build.gradle.kts | 9 +- crosstests/google-javalite/build.gradle.kts | 44 + examples/buf.gen.yaml | 8 +- .../generated-google-java/build.gradle.kts | 6 +- .../build.gradle.kts | 6 +- extensions/buf.gen.yaml | 6 +- extensions/google-java/build.gradle.kts | 6 +- .../java/build/buf/google/rpc/Status.java | 1179 ----------------- .../build/buf/google/rpc/StatusOrBuilder.java | 109 -- .../build/buf/google/rpc/StatusProto.java | 70 - extensions/google-javalite/build.gradle.kts | 8 + .../java/build/buf/google/rpc/Status.java | 550 -------- .../build/buf/google/rpc/StatusOrBuilder.java | 55 - .../build/buf/google/rpc/StatusProto.java | 30 - protoc-gen-connect-kotlin/buf.gen.yaml | 4 +- protoc-gen-connect-kotlin/build.gradle.kts | 8 + 19 files changed, 95 insertions(+), 2033 deletions(-) create mode 100644 crosstests/google-javalite/build.gradle.kts delete mode 100644 extensions/google-java/src/main/java/build/buf/google/rpc/Status.java delete mode 100644 extensions/google-java/src/main/java/build/buf/google/rpc/StatusOrBuilder.java delete mode 100644 extensions/google-java/src/main/java/build/buf/google/rpc/StatusProto.java delete mode 100644 extensions/google-javalite/src/main/java/build/buf/google/rpc/Status.java delete mode 100644 extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusOrBuilder.java delete mode 100644 extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusProto.java diff --git a/.gitignore b/.gitignore index a831177c..ee55310e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,14 +3,7 @@ !/**/src/**/build/* # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar -/examples/generated-google-java/src/main/ -/examples/generated-google-javalite/src/main/ -/crosstests/google-java/src/main/kotlin/generated/ -/crosstests/google-java/src/main/java/generated/ -/crosstests/google-javalite/src/main/kotlin/generated/ -/crosstests/google-javalite/src/main/java/generated/ /local.properties -/protoc-gen-connect-kotlin/src/test/java/ /.gradle /.idea /.tmp diff --git a/Makefile b/Makefile index 93d00aed..9c29e2a7 100644 --- a/Makefile +++ b/Makefile @@ -34,21 +34,12 @@ buildplugin: ## Build the connect-kotlin protoc plugin. .PHONY: clean clean: ## Cleans the underlying build. ./gradlew $(GRADLE_ARGS) clean - rm -rf examples/generated-google-java/src/main - rm -rf examples/generated-google-javalite/src/main - - rm -rf crosstests/google-java/src/main/java/generated - rm -rf crosstests/google-java/src/main/kotlin/generated - rm -rf crosstests/google-javalite/src/main/java/generated - rm -rf crosstests/google-javalite/src/main/kotlin/generated - - rm -rf protoc-gen-connect-kotlin/src/test/java/ .PHONY: crosstestsrun crosstestsrun: crosstestsrunjava ## Run the cross tests. .PHONY: crosstestsrunjava -crosstestsrunjava: ## Run the cross tests for protoc-gen-java integration. +crosstestsrunjava: generate ## Run the cross tests for protoc-gen-java integration. ./gradlew $(GRADLE_ARGS) crosstest:google-java:test ifeq ($(UNAME_OS),Darwin) diff --git a/crosstests/buf.gen.yaml b/crosstests/buf.gen.yaml index 75a66f61..587db050 100644 --- a/crosstests/buf.gen.yaml +++ b/crosstests/buf.gen.yaml @@ -4,27 +4,27 @@ managed: plugins: # Java crosstests. - plugin: connect-kotlin - out: google-java/src/main/kotlin/generated + out: google-java/build/generated/sources/bufgen path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin opt: - generateCallbackMethods=true - generateCoroutineMethods=true - generateBlockingUnaryMethods=true - plugin: java - out: google-java/src/main/java/generated + out: google-java/build/generated/sources/bufgen protoc_path: .tmp/bin/protoc - plugin: kotlin - out: google-java/src/main/kotlin/generated + out: google-java/build/generated/sources/bufgen protoc_path: .tmp/bin/protoc # Javalite crosstests. - plugin: connect-kotlin - out: google-javalite/src/main/kotlin/generated + out: google-javalite/build/generated/sources/bufgen path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin - plugin: java - out: google-javalite/src/main/java/generated + out: google-javalite/build/generated/sources/bufgen protoc_path: .tmp/bin/protoc opt: lite - plugin: kotlin - out: google-javalite/src/main/kotlin/generated + out: google-javalite/build/generated/sources/bufgen protoc_path: .tmp/bin/protoc opt: lite diff --git a/crosstests/google-java/build.gradle.kts b/crosstests/google-java/build.gradle.kts index cbd5a807..902edd65 100644 --- a/crosstests/google-java/build.gradle.kts +++ b/crosstests/google-java/build.gradle.kts @@ -15,13 +15,14 @@ tasks { } sourceSets { - java.sourceSets["main"].java { - srcDir("src/main/java/generated") + main { + java { + srcDir("build/generated/sources/bufgen") + } } } dependencies { - implementation(libs.kotlin.coroutines.core) implementation(libs.protobuf.kotlin) implementation(project(":crosstests:common")) @@ -38,6 +39,6 @@ dependencies { configure { kotlin { - targetExclude("**/generated/**/*.kt") + targetExclude("build/generated/sources/bufgen/**/*.kt") } } diff --git a/crosstests/google-javalite/build.gradle.kts b/crosstests/google-javalite/build.gradle.kts new file mode 100644 index 00000000..902edd65 --- /dev/null +++ b/crosstests/google-javalite/build.gradle.kts @@ -0,0 +1,44 @@ +import com.diffplug.gradle.spotless.SpotlessExtension + +plugins { + application + java + kotlin("jvm") +} + +tasks { + compileKotlin { + kotlinOptions { + freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" + } + } +} + +sourceSets { + main { + java { + srcDir("build/generated/sources/bufgen") + } + } +} + +dependencies { + implementation(libs.kotlin.coroutines.core) + implementation(libs.protobuf.kotlin) + implementation(project(":crosstests:common")) + implementation(project(":extensions:google-java")) + implementation(project(":okhttp")) + + testImplementation(libs.okhttp.core) + testImplementation(libs.junit) + testImplementation(libs.assertj) + testImplementation(libs.mockito) + testImplementation(libs.kotlin.coroutines.core) + testImplementation(libs.testcontainers) +} + +configure { + kotlin { + targetExclude("build/generated/sources/bufgen/**/*.kt") + } +} diff --git a/examples/buf.gen.yaml b/examples/buf.gen.yaml index 0f06e4ff..8c2704d6 100644 --- a/examples/buf.gen.yaml +++ b/examples/buf.gen.yaml @@ -4,15 +4,15 @@ managed: java_package_prefix: "build" plugins: - plugin: connect-kotlin - out: generated-google-java/src/main/kotlin + out: generated-google-java/build/generated/sources/bufgen path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin - plugin: java - out: generated-google-java/src/main/java + out: generated-google-java/build/generated/sources/bufgen protoc_path: .tmp/bin/protoc - plugin: connect-kotlin - out: generated-google-javalite/src/main/kotlin + out: generated-google-javalite/build/generated/sources/bufgen path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin - plugin: java - out: generated-google-javalite/src/main/java + out: generated-google-javalite/build/generated/sources/bufgen protoc_path: .tmp/bin/protoc opt: lite diff --git a/examples/generated-google-java/build.gradle.kts b/examples/generated-google-java/build.gradle.kts index 15ace848..106c0004 100644 --- a/examples/generated-google-java/build.gradle.kts +++ b/examples/generated-google-java/build.gradle.kts @@ -12,8 +12,10 @@ tasks { } sourceSets { - java.sourceSets["main"].java { - srcDir("src/main/java/") + main { + java { + srcDir("build/generated/sources/bufgen") + } } } diff --git a/examples/generated-google-javalite/build.gradle.kts b/examples/generated-google-javalite/build.gradle.kts index 76f5d529..267ff1b6 100644 --- a/examples/generated-google-javalite/build.gradle.kts +++ b/examples/generated-google-javalite/build.gradle.kts @@ -12,8 +12,10 @@ tasks { } sourceSets { - java.sourceSets["main"].java { - srcDir("src/main/java/") + main { + java { + srcDir("build/generated/sources/bufgen") + } } } diff --git a/extensions/buf.gen.yaml b/extensions/buf.gen.yaml index f9e4d6d4..c5a37ed9 100644 --- a/extensions/buf.gen.yaml +++ b/extensions/buf.gen.yaml @@ -7,5 +7,9 @@ types: - google.rpc.Status plugins: - plugin: java - out: google-java/src/main/java + out: google-java/build/generated/sources/bufgen protoc_path: .tmp/bin/protoc + - plugin: java + out: google-javalite/build/generated/sources/bufgen + protoc_path: .tmp/bin/protoc + opt: lite diff --git a/extensions/google-java/build.gradle.kts b/extensions/google-java/build.gradle.kts index d3f5bebd..b2519b2e 100644 --- a/extensions/google-java/build.gradle.kts +++ b/extensions/google-java/build.gradle.kts @@ -10,8 +10,10 @@ plugins { } sourceSets { - java.sourceSets["main"].java { - srcDir("src/main/java/generated") + main { + java { + srcDir("build/generated/sources/bufgen") + } } } diff --git a/extensions/google-java/src/main/java/build/buf/google/rpc/Status.java b/extensions/google-java/src/main/java/build/buf/google/rpc/Status.java deleted file mode 100644 index c0593b4c..00000000 --- a/extensions/google-java/src/main/java/build/buf/google/rpc/Status.java +++ /dev/null @@ -1,1179 +0,0 @@ -// Copyright 2022-2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package build.buf.google.rpc; - -/** - *
- * The `Status` type defines a logical error model that is suitable for
- * different programming environments, including REST APIs and RPC APIs. It is
- * used by [gRPC](https://github.com/grpc). Each `Status` message contains
- * three pieces of data: error code, error message, and error details.
- *
- * You can find out more about this error model and how to work with it in the
- * [API Design Guide](https://cloud.google.com/apis/design/errors).
- * 
- * - * Protobuf type {@code google.rpc.Status} - */ -public final class Status extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:google.rpc.Status) - StatusOrBuilder { -private static final long serialVersionUID = 0L; - // Use Status.newBuilder() to construct. - private Status(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Status() { - message_ = ""; - details_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new Status(); - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return build.buf.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return build.buf.google.rpc.StatusProto.internal_static_google_rpc_Status_fieldAccessorTable - .ensureFieldAccessorsInitialized( - build.buf.google.rpc.Status.class, build.buf.google.rpc.Status.Builder.class); - } - - public static final int CODE_FIELD_NUMBER = 1; - private int code_ = 0; - /** - *
-   * The status code, which should be an enum value of
-   * [google.rpc.Code][google.rpc.Code].
-   * 
- * - * int32 code = 1 [json_name = "code"]; - * @return The code. - */ - @java.lang.Override - public int getCode() { - return code_; - } - - public static final int MESSAGE_FIELD_NUMBER = 2; - @SuppressWarnings("serial") - private volatile java.lang.Object message_ = ""; - /** - *
-   * A developer-facing error message, which should be in English. Any
-   * user-facing error message should be localized and sent in the
-   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-   * by the client.
-   * 
- * - * string message = 2 [json_name = "message"]; - * @return The message. - */ - @java.lang.Override - public java.lang.String getMessage() { - java.lang.Object ref = message_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - message_ = s; - return s; - } - } - /** - *
-   * A developer-facing error message, which should be in English. Any
-   * user-facing error message should be localized and sent in the
-   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-   * by the client.
-   * 
- * - * string message = 2 [json_name = "message"]; - * @return The bytes for message. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getMessageBytes() { - java.lang.Object ref = message_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - message_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DETAILS_FIELD_NUMBER = 3; - @SuppressWarnings("serial") - private java.util.List details_; - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public java.util.List getDetailsList() { - return details_; - } - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public java.util.List - getDetailsOrBuilderList() { - return details_; - } - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public int getDetailsCount() { - return details_.size(); - } - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public com.google.protobuf.Any getDetails(int index) { - return details_.get(index); - } - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( - int index) { - return details_.get(index); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (code_ != 0) { - output.writeInt32(1, code_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(message_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, message_); - } - for (int i = 0; i < details_.size(); i++) { - output.writeMessage(3, details_.get(i)); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (code_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, code_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(message_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, message_); - } - for (int i = 0; i < details_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, details_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof build.buf.google.rpc.Status)) { - return super.equals(obj); - } - build.buf.google.rpc.Status other = (build.buf.google.rpc.Status) obj; - - if (getCode() - != other.getCode()) return false; - if (!getMessage() - .equals(other.getMessage())) return false; - if (!getDetailsList() - .equals(other.getDetailsList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + CODE_FIELD_NUMBER; - hash = (53 * hash) + getCode(); - hash = (37 * hash) + MESSAGE_FIELD_NUMBER; - hash = (53 * hash) + getMessage().hashCode(); - if (getDetailsCount() > 0) { - hash = (37 * hash) + DETAILS_FIELD_NUMBER; - hash = (53 * hash) + getDetailsList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static build.buf.google.rpc.Status parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static build.buf.google.rpc.Status parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static build.buf.google.rpc.Status parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static build.buf.google.rpc.Status parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public static build.buf.google.rpc.Status parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - - public static build.buf.google.rpc.Status parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(build.buf.google.rpc.Status prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-   * The `Status` type defines a logical error model that is suitable for
-   * different programming environments, including REST APIs and RPC APIs. It is
-   * used by [gRPC](https://github.com/grpc). Each `Status` message contains
-   * three pieces of data: error code, error message, and error details.
-   *
-   * You can find out more about this error model and how to work with it in the
-   * [API Design Guide](https://cloud.google.com/apis/design/errors).
-   * 
- * - * Protobuf type {@code google.rpc.Status} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.Status) - build.buf.google.rpc.StatusOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return build.buf.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return build.buf.google.rpc.StatusProto.internal_static_google_rpc_Status_fieldAccessorTable - .ensureFieldAccessorsInitialized( - build.buf.google.rpc.Status.class, build.buf.google.rpc.Status.Builder.class); - } - - // Construct using build.buf.google.rpc.Status.newBuilder() - private Builder() { - - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - - } - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - code_ = 0; - message_ = ""; - if (detailsBuilder_ == null) { - details_ = java.util.Collections.emptyList(); - } else { - details_ = null; - detailsBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return build.buf.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; - } - - @java.lang.Override - public build.buf.google.rpc.Status getDefaultInstanceForType() { - return build.buf.google.rpc.Status.getDefaultInstance(); - } - - @java.lang.Override - public build.buf.google.rpc.Status build() { - build.buf.google.rpc.Status result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public build.buf.google.rpc.Status buildPartial() { - build.buf.google.rpc.Status result = new build.buf.google.rpc.Status(this); - buildPartialRepeatedFields(result); - if (bitField0_ != 0) { buildPartial0(result); } - onBuilt(); - return result; - } - - private void buildPartialRepeatedFields(build.buf.google.rpc.Status result) { - if (detailsBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0)) { - details_ = java.util.Collections.unmodifiableList(details_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.details_ = details_; - } else { - result.details_ = detailsBuilder_.build(); - } - } - - private void buildPartial0(build.buf.google.rpc.Status result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.code_ = code_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.message_ = message_; - } - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof build.buf.google.rpc.Status) { - return mergeFrom((build.buf.google.rpc.Status)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(build.buf.google.rpc.Status other) { - if (other == build.buf.google.rpc.Status.getDefaultInstance()) return this; - if (other.getCode() != 0) { - setCode(other.getCode()); - } - if (!other.getMessage().isEmpty()) { - message_ = other.message_; - bitField0_ |= 0x00000002; - onChanged(); - } - if (detailsBuilder_ == null) { - if (!other.details_.isEmpty()) { - if (details_.isEmpty()) { - details_ = other.details_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureDetailsIsMutable(); - details_.addAll(other.details_); - } - onChanged(); - } - } else { - if (!other.details_.isEmpty()) { - if (detailsBuilder_.isEmpty()) { - detailsBuilder_.dispose(); - detailsBuilder_ = null; - details_ = other.details_; - bitField0_ = (bitField0_ & ~0x00000004); - detailsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getDetailsFieldBuilder() : null; - } else { - detailsBuilder_.addAllMessages(other.details_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: { - code_ = input.readInt32(); - bitField0_ |= 0x00000001; - break; - } // case 8 - case 18: { - message_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000002; - break; - } // case 18 - case 26: { - com.google.protobuf.Any m = - input.readMessage( - com.google.protobuf.Any.parser(), - extensionRegistry); - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(m); - } else { - detailsBuilder_.addMessage(m); - } - break; - } // case 26 - default: { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - private int bitField0_; - - private int code_ ; - /** - *
-     * The status code, which should be an enum value of
-     * [google.rpc.Code][google.rpc.Code].
-     * 
- * - * int32 code = 1 [json_name = "code"]; - * @return The code. - */ - @java.lang.Override - public int getCode() { - return code_; - } - /** - *
-     * The status code, which should be an enum value of
-     * [google.rpc.Code][google.rpc.Code].
-     * 
- * - * int32 code = 1 [json_name = "code"]; - * @param value The code to set. - * @return This builder for chaining. - */ - public Builder setCode(int value) { - - code_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - /** - *
-     * The status code, which should be an enum value of
-     * [google.rpc.Code][google.rpc.Code].
-     * 
- * - * int32 code = 1 [json_name = "code"]; - * @return This builder for chaining. - */ - public Builder clearCode() { - bitField0_ = (bitField0_ & ~0x00000001); - code_ = 0; - onChanged(); - return this; - } - - private java.lang.Object message_ = ""; - /** - *
-     * A developer-facing error message, which should be in English. Any
-     * user-facing error message should be localized and sent in the
-     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-     * by the client.
-     * 
- * - * string message = 2 [json_name = "message"]; - * @return The message. - */ - public java.lang.String getMessage() { - java.lang.Object ref = message_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - message_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * A developer-facing error message, which should be in English. Any
-     * user-facing error message should be localized and sent in the
-     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-     * by the client.
-     * 
- * - * string message = 2 [json_name = "message"]; - * @return The bytes for message. - */ - public com.google.protobuf.ByteString - getMessageBytes() { - java.lang.Object ref = message_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - message_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * A developer-facing error message, which should be in English. Any
-     * user-facing error message should be localized and sent in the
-     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-     * by the client.
-     * 
- * - * string message = 2 [json_name = "message"]; - * @param value The message to set. - * @return This builder for chaining. - */ - public Builder setMessage( - java.lang.String value) { - if (value == null) { throw new NullPointerException(); } - message_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - /** - *
-     * A developer-facing error message, which should be in English. Any
-     * user-facing error message should be localized and sent in the
-     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-     * by the client.
-     * 
- * - * string message = 2 [json_name = "message"]; - * @return This builder for chaining. - */ - public Builder clearMessage() { - message_ = getDefaultInstance().getMessage(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - *
-     * A developer-facing error message, which should be in English. Any
-     * user-facing error message should be localized and sent in the
-     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-     * by the client.
-     * 
- * - * string message = 2 [json_name = "message"]; - * @param value The bytes for message to set. - * @return This builder for chaining. - */ - public Builder setMessageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { throw new NullPointerException(); } - checkByteStringIsUtf8(value); - message_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - - private java.util.List details_ = - java.util.Collections.emptyList(); - private void ensureDetailsIsMutable() { - if (!((bitField0_ & 0x00000004) != 0)) { - details_ = new java.util.ArrayList(details_); - bitField0_ |= 0x00000004; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> detailsBuilder_; - - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public java.util.List getDetailsList() { - if (detailsBuilder_ == null) { - return java.util.Collections.unmodifiableList(details_); - } else { - return detailsBuilder_.getMessageList(); - } - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public int getDetailsCount() { - if (detailsBuilder_ == null) { - return details_.size(); - } else { - return detailsBuilder_.getCount(); - } - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public com.google.protobuf.Any getDetails(int index) { - if (detailsBuilder_ == null) { - return details_.get(index); - } else { - return detailsBuilder_.getMessage(index); - } - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder setDetails( - int index, com.google.protobuf.Any value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.set(index, value); - onChanged(); - } else { - detailsBuilder_.setMessage(index, value); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder setDetails( - int index, com.google.protobuf.Any.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.set(index, builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails(com.google.protobuf.Any value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.add(value); - onChanged(); - } else { - detailsBuilder_.addMessage(value); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails( - int index, com.google.protobuf.Any value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.add(index, value); - onChanged(); - } else { - detailsBuilder_.addMessage(index, value); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails( - com.google.protobuf.Any.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails( - int index, com.google.protobuf.Any.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(index, builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addAllDetails( - java.lang.Iterable values) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, details_); - onChanged(); - } else { - detailsBuilder_.addAllMessages(values); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder clearDetails() { - if (detailsBuilder_ == null) { - details_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - detailsBuilder_.clear(); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder removeDetails(int index) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.remove(index); - onChanged(); - } else { - detailsBuilder_.remove(index); - } - return this; - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public com.google.protobuf.Any.Builder getDetailsBuilder( - int index) { - return getDetailsFieldBuilder().getBuilder(index); - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( - int index) { - if (detailsBuilder_ == null) { - return details_.get(index); } else { - return detailsBuilder_.getMessageOrBuilder(index); - } - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public java.util.List - getDetailsOrBuilderList() { - if (detailsBuilder_ != null) { - return detailsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(details_); - } - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public com.google.protobuf.Any.Builder addDetailsBuilder() { - return getDetailsFieldBuilder().addBuilder( - com.google.protobuf.Any.getDefaultInstance()); - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public com.google.protobuf.Any.Builder addDetailsBuilder( - int index) { - return getDetailsFieldBuilder().addBuilder( - index, com.google.protobuf.Any.getDefaultInstance()); - } - /** - *
-     * A list of messages that carry the error details.  There is a common set of
-     * message types for APIs to use.
-     * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public java.util.List - getDetailsBuilderList() { - return getDetailsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> - getDetailsFieldBuilder() { - if (detailsBuilder_ == null) { - detailsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( - details_, - ((bitField0_ & 0x00000004) != 0), - getParentForChildren(), - isClean()); - details_ = null; - } - return detailsBuilder_; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.Status) - } - - // @@protoc_insertion_point(class_scope:google.rpc.Status) - private static final build.buf.google.rpc.Status DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new build.buf.google.rpc.Status(); - } - - public static build.buf.google.rpc.Status getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public Status parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public build.buf.google.rpc.Status getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/extensions/google-java/src/main/java/build/buf/google/rpc/StatusOrBuilder.java b/extensions/google-java/src/main/java/build/buf/google/rpc/StatusOrBuilder.java deleted file mode 100644 index 00af7f02..00000000 --- a/extensions/google-java/src/main/java/build/buf/google/rpc/StatusOrBuilder.java +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2022-2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package build.buf.google.rpc; - -public interface StatusOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.Status) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * The status code, which should be an enum value of
-   * [google.rpc.Code][google.rpc.Code].
-   * 
- * - * int32 code = 1 [json_name = "code"]; - * @return The code. - */ - int getCode(); - - /** - *
-   * A developer-facing error message, which should be in English. Any
-   * user-facing error message should be localized and sent in the
-   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-   * by the client.
-   * 
- * - * string message = 2 [json_name = "message"]; - * @return The message. - */ - java.lang.String getMessage(); - /** - *
-   * A developer-facing error message, which should be in English. Any
-   * user-facing error message should be localized and sent in the
-   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
-   * by the client.
-   * 
- * - * string message = 2 [json_name = "message"]; - * @return The bytes for message. - */ - com.google.protobuf.ByteString - getMessageBytes(); - - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - java.util.List - getDetailsList(); - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - com.google.protobuf.Any getDetails(int index); - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - int getDetailsCount(); - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - java.util.List - getDetailsOrBuilderList(); - /** - *
-   * A list of messages that carry the error details.  There is a common set of
-   * message types for APIs to use.
-   * 
- * - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( - int index); -} diff --git a/extensions/google-java/src/main/java/build/buf/google/rpc/StatusProto.java b/extensions/google-java/src/main/java/build/buf/google/rpc/StatusProto.java deleted file mode 100644 index 875f5de6..00000000 --- a/extensions/google-java/src/main/java/build/buf/google/rpc/StatusProto.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022-2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package build.buf.google.rpc; - -public final class StatusProto { - private StatusProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_Status_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_rpc_Status_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\027google/rpc/status.proto\022\ngoogle.rpc\032\031g" + - "oogle/protobuf/any.proto\"f\n\006Status\022\022\n\004co" + - "de\030\001 \001(\005R\004code\022\030\n\007message\030\002 \001(\tR\007message" + - "\022.\n\007details\030\003 \003(\0132\024.google.protobuf.AnyR" + - "\007detailsB\250\001\n\024build.buf.google.rpcB\013Statu" + - "sProtoP\001Z7google.golang.org/genproto/goo" + - "gleapis/rpc/status;status\370\001\001\242\002\003GRX\252\002\nGoo" + - "gle.Rpc\312\002\nGoogle\\Rpc\342\002\026Google\\Rpc\\GPBMet" + - "adata\352\002\013Google::Rpcb\006proto3" - }; - descriptor = com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.AnyProto.getDescriptor(), - }); - internal_static_google_rpc_Status_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_rpc_Status_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_rpc_Status_descriptor, - new java.lang.String[] { "Code", "Message", "Details", }); - com.google.protobuf.AnyProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/extensions/google-javalite/build.gradle.kts b/extensions/google-javalite/build.gradle.kts index 90c7fc12..77fd44c4 100644 --- a/extensions/google-javalite/build.gradle.kts +++ b/extensions/google-javalite/build.gradle.kts @@ -19,6 +19,14 @@ dependencies { implementation(libs.kotlin.reflect) } +sourceSets { + main { + java { + srcDir("build/generated/sources/bufgen") + } + } +} + configure { configure( KotlinJvm(javadocJar = Dokka("dokkaGfm")) diff --git a/extensions/google-javalite/src/main/java/build/buf/google/rpc/Status.java b/extensions/google-javalite/src/main/java/build/buf/google/rpc/Status.java deleted file mode 100644 index 937aa5a3..00000000 --- a/extensions/google-javalite/src/main/java/build/buf/google/rpc/Status.java +++ /dev/null @@ -1,550 +0,0 @@ -// Copyright 2022-2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package build.buf.google.rpc; - -/** - * Protobuf type {@code google.rpc.Status} - */ -public final class Status extends - com.google.protobuf.GeneratedMessageLite< - Status, Status.Builder> implements - // @@protoc_insertion_point(message_implements:google.rpc.Status) - StatusOrBuilder { - private Status() { - message_ = ""; - details_ = emptyProtobufList(); - } - public static final int CODE_FIELD_NUMBER = 1; - private int code_; - /** - * int32 code = 1 [json_name = "code"]; - * @return The code. - */ - @java.lang.Override - public int getCode() { - return code_; - } - /** - * int32 code = 1 [json_name = "code"]; - * @param value The code to set. - */ - private void setCode(int value) { - - code_ = value; - } - /** - * int32 code = 1 [json_name = "code"]; - */ - private void clearCode() { - - code_ = 0; - } - - public static final int MESSAGE_FIELD_NUMBER = 2; - private java.lang.String message_; - /** - * string message = 2 [json_name = "message"]; - * @return The message. - */ - @java.lang.Override - public java.lang.String getMessage() { - return message_; - } - /** - * string message = 2 [json_name = "message"]; - * @return The bytes for message. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getMessageBytes() { - return com.google.protobuf.ByteString.copyFromUtf8(message_); - } - /** - * string message = 2 [json_name = "message"]; - * @param value The message to set. - */ - private void setMessage( - java.lang.String value) { - java.lang.Class valueClass = value.getClass(); - - message_ = value; - } - /** - * string message = 2 [json_name = "message"]; - */ - private void clearMessage() { - - message_ = getDefaultInstance().getMessage(); - } - /** - * string message = 2 [json_name = "message"]; - * @param value The bytes for message to set. - */ - private void setMessageBytes( - com.google.protobuf.ByteString value) { - checkByteStringIsUtf8(value); - message_ = value.toStringUtf8(); - - } - - public static final int DETAILS_FIELD_NUMBER = 3; - private com.google.protobuf.Internal.ProtobufList details_; - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public java.util.List getDetailsList() { - return details_; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public java.util.List - getDetailsOrBuilderList() { - return details_; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public int getDetailsCount() { - return details_.size(); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public com.google.protobuf.Any getDetails(int index) { - return details_.get(index); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( - int index) { - return details_.get(index); - } - private void ensureDetailsIsMutable() { - com.google.protobuf.Internal.ProtobufList tmp = details_; - if (!tmp.isModifiable()) { - details_ = - com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp); - } - } - - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - private void setDetails( - int index, com.google.protobuf.Any value) { - value.getClass(); - ensureDetailsIsMutable(); - details_.set(index, value); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - private void addDetails(com.google.protobuf.Any value) { - value.getClass(); - ensureDetailsIsMutable(); - details_.add(value); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - private void addDetails( - int index, com.google.protobuf.Any value) { - value.getClass(); - ensureDetailsIsMutable(); - details_.add(index, value); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - private void addAllDetails( - java.lang.Iterable values) { - ensureDetailsIsMutable(); - com.google.protobuf.AbstractMessageLite.addAll( - values, details_); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - private void clearDetails() { - details_ = emptyProtobufList(); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - private void removeDetails(int index) { - ensureDetailsIsMutable(); - details_.remove(index); - } - - public static build.buf.google.rpc.Status parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); - } - public static build.buf.google.rpc.Status parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data); - } - public static build.buf.google.rpc.Status parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, data, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input); - } - public static build.buf.google.rpc.Status parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input, extensionRegistry); - } - public static build.buf.google.rpc.Status parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return parseDelimitedFrom(DEFAULT_INSTANCE, input); - } - public static build.buf.google.rpc.Status parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input); - } - public static build.buf.google.rpc.Status parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageLite.parseFrom( - DEFAULT_INSTANCE, input, extensionRegistry); - } - - public static Builder newBuilder() { - return (Builder) DEFAULT_INSTANCE.createBuilder(); - } - public static Builder newBuilder(build.buf.google.rpc.Status prototype) { - return (Builder) DEFAULT_INSTANCE.createBuilder(prototype); - } - - /** - * Protobuf type {@code google.rpc.Status} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - build.buf.google.rpc.Status, Builder> implements - // @@protoc_insertion_point(builder_implements:google.rpc.Status) - build.buf.google.rpc.StatusOrBuilder { - // Construct using build.buf.google.rpc.Status.newBuilder() - private Builder() { - super(DEFAULT_INSTANCE); - } - - - /** - * int32 code = 1 [json_name = "code"]; - * @return The code. - */ - @java.lang.Override - public int getCode() { - return instance.getCode(); - } - /** - * int32 code = 1 [json_name = "code"]; - * @param value The code to set. - * @return This builder for chaining. - */ - public Builder setCode(int value) { - copyOnWrite(); - instance.setCode(value); - return this; - } - /** - * int32 code = 1 [json_name = "code"]; - * @return This builder for chaining. - */ - public Builder clearCode() { - copyOnWrite(); - instance.clearCode(); - return this; - } - - /** - * string message = 2 [json_name = "message"]; - * @return The message. - */ - @java.lang.Override - public java.lang.String getMessage() { - return instance.getMessage(); - } - /** - * string message = 2 [json_name = "message"]; - * @return The bytes for message. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getMessageBytes() { - return instance.getMessageBytes(); - } - /** - * string message = 2 [json_name = "message"]; - * @param value The message to set. - * @return This builder for chaining. - */ - public Builder setMessage( - java.lang.String value) { - copyOnWrite(); - instance.setMessage(value); - return this; - } - /** - * string message = 2 [json_name = "message"]; - * @return This builder for chaining. - */ - public Builder clearMessage() { - copyOnWrite(); - instance.clearMessage(); - return this; - } - /** - * string message = 2 [json_name = "message"]; - * @param value The bytes for message to set. - * @return This builder for chaining. - */ - public Builder setMessageBytes( - com.google.protobuf.ByteString value) { - copyOnWrite(); - instance.setMessageBytes(value); - return this; - } - - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public java.util.List getDetailsList() { - return java.util.Collections.unmodifiableList( - instance.getDetailsList()); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public int getDetailsCount() { - return instance.getDetailsCount(); - }/** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - @java.lang.Override - public com.google.protobuf.Any getDetails(int index) { - return instance.getDetails(index); - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder setDetails( - int index, com.google.protobuf.Any value) { - copyOnWrite(); - instance.setDetails(index, value); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder setDetails( - int index, com.google.protobuf.Any.Builder builderForValue) { - copyOnWrite(); - instance.setDetails(index, - builderForValue.build()); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails(com.google.protobuf.Any value) { - copyOnWrite(); - instance.addDetails(value); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails( - int index, com.google.protobuf.Any value) { - copyOnWrite(); - instance.addDetails(index, value); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails( - com.google.protobuf.Any.Builder builderForValue) { - copyOnWrite(); - instance.addDetails(builderForValue.build()); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addDetails( - int index, com.google.protobuf.Any.Builder builderForValue) { - copyOnWrite(); - instance.addDetails(index, - builderForValue.build()); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder addAllDetails( - java.lang.Iterable values) { - copyOnWrite(); - instance.addAllDetails(values); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder clearDetails() { - copyOnWrite(); - instance.clearDetails(); - return this; - } - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - public Builder removeDetails(int index) { - copyOnWrite(); - instance.removeDetails(index); - return this; - } - - // @@protoc_insertion_point(builder_scope:google.rpc.Status) - } - @java.lang.Override - @java.lang.SuppressWarnings({"unchecked", "fallthrough"}) - protected final java.lang.Object dynamicMethod( - com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, - java.lang.Object arg0, java.lang.Object arg1) { - switch (method) { - case NEW_MUTABLE_INSTANCE: { - return new build.buf.google.rpc.Status(); - } - case NEW_BUILDER: { - return new Builder(); - } - case BUILD_MESSAGE_INFO: { - java.lang.Object[] objects = new java.lang.Object[] { - "code_", - "message_", - "details_", - com.google.protobuf.Any.class, - }; - java.lang.String info = - "\u0000\u0003\u0000\u0000\u0001\u0003\u0003\u0000\u0001\u0000\u0001\u0004\u0002\u0208" + - "\u0003\u001b"; - return newMessageInfo(DEFAULT_INSTANCE, info, objects); - } - // fall through - case GET_DEFAULT_INSTANCE: { - return DEFAULT_INSTANCE; - } - case GET_PARSER: { - com.google.protobuf.Parser parser = PARSER; - if (parser == null) { - synchronized (build.buf.google.rpc.Status.class) { - parser = PARSER; - if (parser == null) { - parser = - new DefaultInstanceBasedParser( - DEFAULT_INSTANCE); - PARSER = parser; - } - } - } - return parser; - } - case GET_MEMOIZED_IS_INITIALIZED: { - return (byte) 1; - } - case SET_MEMOIZED_IS_INITIALIZED: { - return null; - } - } - throw new UnsupportedOperationException(); - } - - - // @@protoc_insertion_point(class_scope:google.rpc.Status) - private static final build.buf.google.rpc.Status DEFAULT_INSTANCE; - static { - Status defaultInstance = new Status(); - // New instances are implicitly immutable so no need to make - // immutable. - DEFAULT_INSTANCE = defaultInstance; - com.google.protobuf.GeneratedMessageLite.registerDefaultInstance( - Status.class, defaultInstance); - } - - public static build.buf.google.rpc.Status getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static volatile com.google.protobuf.Parser PARSER; - - public static com.google.protobuf.Parser parser() { - return DEFAULT_INSTANCE.getParserForType(); - } -} - diff --git a/extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusOrBuilder.java b/extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusOrBuilder.java deleted file mode 100644 index 882695ba..00000000 --- a/extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusOrBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022-2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package build.buf.google.rpc; - -public interface StatusOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.Status) - com.google.protobuf.MessageLiteOrBuilder { - - /** - * int32 code = 1 [json_name = "code"]; - * @return The code. - */ - int getCode(); - - /** - * string message = 2 [json_name = "message"]; - * @return The message. - */ - java.lang.String getMessage(); - /** - * string message = 2 [json_name = "message"]; - * @return The bytes for message. - */ - com.google.protobuf.ByteString - getMessageBytes(); - - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - java.util.List - getDetailsList(); - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - com.google.protobuf.Any getDetails(int index); - /** - * repeated .google.protobuf.Any details = 3 [json_name = "details"]; - */ - int getDetailsCount(); -} diff --git a/extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusProto.java b/extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusProto.java deleted file mode 100644 index e87cb5d6..00000000 --- a/extensions/google-javalite/src/main/java/build/buf/google/rpc/StatusProto.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2022-2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package build.buf.google.rpc; - -public final class StatusProto { - private StatusProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - static { - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/protoc-gen-connect-kotlin/buf.gen.yaml b/protoc-gen-connect-kotlin/buf.gen.yaml index ced4abe6..bd1c80de 100644 --- a/protoc-gen-connect-kotlin/buf.gen.yaml +++ b/protoc-gen-connect-kotlin/buf.gen.yaml @@ -1,12 +1,12 @@ version: v1 plugins: - plugin: connect-kotlin - out: src/test/java/ + out: build/generated/sources/bufgen path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin opt: - generateCallbackMethods=true - generateCoroutineMethods=true - plugin: java - out: src/test/java/ + out: build/generated/sources/bufgen protoc_path: .tmp/bin/protoc diff --git a/protoc-gen-connect-kotlin/build.gradle.kts b/protoc-gen-connect-kotlin/build.gradle.kts index 95845649..40945205 100644 --- a/protoc-gen-connect-kotlin/build.gradle.kts +++ b/protoc-gen-connect-kotlin/build.gradle.kts @@ -37,6 +37,14 @@ dependencies { testImplementation(libs.kotlin.coroutines.core) } +sourceSets { + test { + java { + srcDir(layout.buildDirectory.dir("generated/sources/bufgen")) + } + } +} + configure { configure( KotlinJvm(javadocJar = Dokka("dokkaGfm"))