File tree 6 files changed +9
-27
lines changed
main/java/com/google/api/generator
test/java/com/google/api/generator/gapic/protoparser
6 files changed +9
-27
lines changed Original file line number Diff line number Diff line change 15
15
package com .google .api .generator ;
16
16
17
17
import com .google .api .generator .gapic .Generator ;
18
- import com .google .api .generator .gapic .protoparser .NoServicesFoundException ;
19
18
import com .google .protobuf .ExtensionRegistry ;
20
19
import com .google .protobuf .compiler .PluginProtos .CodeGeneratorRequest ;
21
20
import com .google .protobuf .compiler .PluginProtos .CodeGeneratorResponse ;
@@ -26,12 +25,7 @@ public static void main(String[] args) throws IOException {
26
25
ExtensionRegistry registry = ExtensionRegistry .newInstance ();
27
26
ProtoRegistry .registerAllExtensions (registry );
28
27
CodeGeneratorRequest request = CodeGeneratorRequest .parseFrom (System .in , registry );
29
- try {
30
- CodeGeneratorResponse response = Generator .generateGapic (request );
31
- response .writeTo (System .out );
32
- } catch (NoServicesFoundException ex ) {
33
- // If no services are found in the protos we will no-op
34
- System .err .println ("No services found to generate" );
35
- }
28
+ CodeGeneratorResponse response = Generator .generateGapic (request );
29
+ response .writeTo (System .out );
36
30
}
37
31
}
Original file line number Diff line number Diff line change 14
14
15
15
package com .google .api .generator .gapic ;
16
16
17
- import com .google .api .gax .rpc .StatusCode .Code ;
18
17
import com .google .api .generator .gapic .composer .Composer ;
19
18
import com .google .api .generator .gapic .model .GapicClass ;
20
19
import com .google .api .generator .gapic .model .GapicContext ;
21
20
import com .google .api .generator .gapic .model .GapicPackageInfo ;
22
21
import com .google .api .generator .gapic .model .ReflectConfig ;
23
- import com .google .api .generator .gapic .protoparser .NoServicesFoundException ;
24
22
import com .google .api .generator .gapic .protoparser .Parser ;
25
23
import com .google .api .generator .gapic .protowriter .Writer ;
26
24
import com .google .protobuf .compiler .PluginProtos .CodeGeneratorRequest ;
27
25
import com .google .protobuf .compiler .PluginProtos .CodeGeneratorResponse ;
28
26
import java .util .List ;
29
27
30
28
public class Generator {
31
- public static CodeGeneratorResponse generateGapic (CodeGeneratorRequest request )
32
- throws NoServicesFoundException {
29
+ public static CodeGeneratorResponse generateGapic (CodeGeneratorRequest request ) {
33
30
GapicContext context = Parser .parse (request );
34
31
List <GapicClass > clazzes = Composer .composeServiceClasses (context );
35
32
GapicPackageInfo packageInfo = Composer .composePackageInfo (context );
Original file line number Diff line number Diff line change 29
29
import com .google .api .generator .gapic .model .GapicPackageInfo ;
30
30
import com .google .api .generator .gapic .model .Sample ;
31
31
import com .google .api .generator .gapic .model .Service ;
32
- import com .google .api . generator . gapic . protoparser . NoServicesFoundException ;
32
+ import com .google .common . base . Preconditions ;
33
33
import com .google .common .base .Strings ;
34
34
import javax .annotation .Generated ;
35
35
@@ -44,9 +44,8 @@ public class ClientLibraryPackageInfoComposer {
44
44
private static final String SERVICE_DESCRIPTION_HEADER_PATTERN = "Service Description: %s" ;
45
45
46
46
public static GapicPackageInfo generatePackageInfo (GapicContext context ) {
47
- if (context .services ().isEmpty ()) {
48
- throw new NoServicesFoundException ("No services found to generate" );
49
- }
47
+ Preconditions .checkState (!context .services ().isEmpty (), "No services found to generate" );
48
+
50
49
// Pick some service's package, as we assume they are all the same.
51
50
String libraryPakkage = context .services ().get (0 ).pakkage ();
52
51
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public GapicParserException(String errorMessage) {
115
115
}
116
116
}
117
117
118
- public static GapicContext parse (CodeGeneratorRequest request ) throws NoServicesFoundException {
118
+ public static GapicContext parse (CodeGeneratorRequest request ) {
119
119
Optional <String > gapicYamlConfigPathOpt =
120
120
PluginArgumentParser .parseGapicYamlConfigPath (request );
121
121
Optional <List <GapicBatchingSettings >> batchingSettingsOpt =
@@ -176,7 +176,7 @@ public static GapicContext parse(CodeGeneratorRequest request) throws NoServices
176
176
transport );
177
177
178
178
if (services .isEmpty ()) {
179
- throw new NoServicesFoundException ();
179
+ // throw new NoServicesFoundException();
180
180
}
181
181
182
182
// TODO(vam-google): Figure out whether we should keep this allowlist or bring
Original file line number Diff line number Diff line change 42
42
import com .google .protobuf .Descriptors .FileDescriptor ;
43
43
import com .google .protobuf .Descriptors .MethodDescriptor ;
44
44
import com .google .protobuf .Descriptors .ServiceDescriptor ;
45
+ import com .google .protobuf .compiler .PluginProtos .CodeGeneratorRequest ;
45
46
import com .google .showcase .v1beta1 .EchoOuterClass ;
46
47
import com .google .showcase .v1beta1 .TestingOuterClass ;
47
48
import com .google .testgapic .v1beta1 .LockerProto ;
You can’t perform that action at this time.
0 commit comments