Skip to content

Commit 4bc092a

Browse files
committed
try to use empty GapicPackageInfo
1 parent 96b357b commit 4bc092a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/ClientLibraryPackageInfoComposer.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public class ClientLibraryPackageInfoComposer {
4444
private static final String SERVICE_DESCRIPTION_HEADER_PATTERN = "Service Description: %s";
4545

4646
public static GapicPackageInfo generatePackageInfo(GapicContext context) {
47-
Preconditions.checkState(!context.services().isEmpty(), "No services found to generate");
47+
if (context.services().isEmpty()) {
48+
return GapicPackageInfo.empty();
49+
}
4850

4951
// Pick some service's package, as we assume they are all the same.
5052
String libraryPakkage = context.services().get(0).pakkage();

gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicPackageInfo.java

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public static GapicPackageInfo with(PackageInfoDefinition packageInfo) {
2626
return builder().setPackageInfo(packageInfo).build();
2727
}
2828

29+
public static GapicPackageInfo empty() {
30+
return builder().setPackageInfo(PackageInfoDefinition.builder().build()).build();
31+
}
32+
2933
static Builder builder() {
3034
return new AutoValue_GapicPackageInfo.Builder();
3135
}

gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ public static GapicContext parse(CodeGeneratorRequest request) {
176176
transport);
177177

178178
if (services.isEmpty()) {
179-
//throw new NoServicesFoundException();
179+
System.err.println("No services found. Will not generate Gapic clients");
180180
}
181181

182182
// TODO(vam-google): Figure out whether we should keep this allowlist or bring
183183
// back the unused resource names for all APIs.
184184
// Temporary workaround for Ads, who still need these resource names.
185-
if (services.get(0).protoPakkage().startsWith("google.ads.googleads.v")) {
185+
if (!services.isEmpty() && services.get(0).protoPakkage().startsWith("google.ads.googleads.v")) {
186186
Function<ResourceName, String> typeNameFn =
187187
r -> r.resourceTypeString().substring(r.resourceTypeString().indexOf("/") + 1);
188188
Function<Set<ResourceName>, Set<String>> typeStringSetFn =

0 commit comments

Comments
 (0)