use of com.google.api.codegen.gapic.ProtocGapicWriter in project toolkit by googleapis.
the class ProtocGeneratorMain method generate.
@VisibleForTesting
public static // CodeGeneratorResponse.
CodeGeneratorResponse generate(CodeGeneratorRequest request) {
try {
ToolOptions toolOptions = parseOptions(request);
ProtocGapicWriter gapicWriter = new ProtocGapicWriter();
GapicGeneratorApp codeGen = new GapicGeneratorApp(toolOptions, DEFAULT_ARTIFACT_TYPE, gapicWriter);
codeGen.run();
CodeGeneratorResponse response = gapicWriter.getCodegenResponse();
if (response == null) {
throw new RuntimeException(collectDiags(codeGen));
}
return response;
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.flush();
return PluginProtos.CodeGeneratorResponse.newBuilder().setError(sw.toString()).build();
}
}
Aggregations