Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public class Parser {
private static final String COLON = ":";
private static final String DEFAULT_PORT = "443";
private static final String DOT = ".";

private static final Set<String> DUPE_SERVICE_CODEGEN_BLOCKLIST =
new HashSet<>(Arrays.asList("google.longrunning", "google.iam.v1"));

// Allow other parsers to access this.
protected static final SourceCodeInfoParser SOURCE_CODE_INFO_PARSER = new SourceCodeInfoParser();

Expand Down Expand Up @@ -131,6 +135,26 @@ public static List<Service> parseServices(
outputArgResourceNames));
}

// Prevent codegen for IAM or LRO if there are other services present, since that is an
// indicator that we are not generating a GAPIC client for IAM or LRO.
Set<String> serviceProtoPackages =
services.stream().map(s -> s.protoPakkage()).collect(Collectors.toSet());
boolean servicesContainBlocklistedApi = false;
for (String blocklistedPackage : DUPE_SERVICE_CODEGEN_BLOCKLIST) {
// It's very unlikely the blocklisted APIs will contain the other, or any other service.
if (serviceProtoPackages.contains(blocklistedPackage) && serviceProtoPackages.size() > 1) {
servicesContainBlocklistedApi = true;
break;
}
}

if (servicesContainBlocklistedApi) {
services =
services.stream()
.filter(s -> !DUPE_SERVICE_CODEGEN_BLOCKLIST.contains(s.protoPakkage()))
.collect(Collectors.toList());
}

return services;
}

Expand Down