Skip to content

Commit

Permalink
fix: Fix mixin mock service and gradle build generation (#1010)
Browse files Browse the repository at this point in the history
1) The generated mixin mock service classes must be in the same package as the service itself (not of the mixed-in service) - this is a regression of migrating to microgenerator. For example the PR when this happened for KMS: https://github.com/googleapis/java-kms/pull/502/files#diff-59a3127359a0458dedfaa9b6bdfc658e88a2491a6d907f32e17fac462b1a3c27L16

2) In case there is a location mixin, we also need to include grpc-google-common-protos dependency for output to compile
  • Loading branch information
vam-google committed Jun 27, 2022
1 parent 9dcc470 commit d896e6e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions rules_java_gapic/java_gapic_pkg.bzl
Expand Up @@ -131,6 +131,7 @@ def _construct_extra_deps(scope_to_deps, versions_map):
"iam_java_proto": "maven.com_google_api_grpc_proto_google_iam_v1",
"iam_java_grpc": "maven.com_google_api_grpc_grpc_google_iam_v1",
"iam_policy_java_grpc": "maven.com_google_api_grpc_grpc_google_iam_v1",
"location_java_grpc": "maven.com_google_api_grpc_grpc_google_common_protos",
}
extra_deps = {}
for scope, deps in scope_to_deps.items():
Expand Down
Expand Up @@ -203,7 +203,12 @@ public static GapicContext parse(CodeGeneratorRequest request) {

return GapicContext.builder()
.setServices(services)
.setMixinServices(mixinServices)
.setMixinServices(
// Mixin classes must share the package with the service they are mixed in, instead of
// their original package
mixinServices.stream()
.map(s -> s.toBuilder().setPakkage(services.get(0).pakkage()).build())
.collect(Collectors.toList()))
.setMessages(messages)
.setResourceNames(resourceNames)
.setHelperResourceNames(outputArgResourceNames)
Expand Down
Expand Up @@ -34,12 +34,10 @@
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.cloud.location.MockLocations;
import com.google.common.collect.Lists;
import com.google.iam.v1.Binding;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.GetPolicyOptions;
import com.google.iam.v1.MockIAMPolicy;
import com.google.iam.v1.Policy;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.iam.v1;
package com.google.cloud.kms.v1;

import com.google.api.core.BetaApi;
import com.google.api.gax.grpc.testing.MockGrpcService;
Expand Down
Expand Up @@ -14,10 +14,14 @@
* limitations under the License.
*/

package com.google.iam.v1;
package com.google.cloud.kms.v1;

import com.google.api.core.BetaApi;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.IAMPolicyGrpc.IAMPolicyImplBase;
import com.google.iam.v1.Policy;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.protobuf.AbstractMessage;
import io.grpc.stub.StreamObserver;
import java.util.ArrayList;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.cloud.location;
package com.google.cloud.kms.v1;

import com.google.api.core.BetaApi;
import com.google.api.gax.grpc.testing.MockGrpcService;
Expand Down
Expand Up @@ -14,9 +14,13 @@
* limitations under the License.
*/

package com.google.cloud.location;
package com.google.cloud.kms.v1;

import com.google.api.core.BetaApi;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.cloud.location.LocationsGrpc.LocationsImplBase;
import com.google.protobuf.AbstractMessage;
import io.grpc.stub.StreamObserver;
Expand Down

0 comments on commit d896e6e

Please sign in to comment.