use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class ConfigGeneratorTool method generate.
private static int generate(String descriptorSet, String[] configs, String outputFile) {
ToolOptions options = ToolOptions.create();
options.set(ConfigGeneratorApi.OUTPUT_FILE, outputFile);
options.set(ToolOptions.DESCRIPTOR_SET, descriptorSet);
options.set(ToolOptions.CONFIG_FILES, Lists.newArrayList(configs));
ConfigGeneratorApi configGen = new ConfigGeneratorApi(options);
return configGen.run();
}
use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class DiscoConfigGeneratorTool method generate.
private static void generate(String discoveryFilepath, String outputFile) {
ToolOptions options = ToolOptions.create();
options.set(DiscoConfigGeneratorApi.OUTPUT_FILE, outputFile);
options.set(DiscoConfigGeneratorApi.DISCOVERY_DOC, discoveryFilepath);
DiscoConfigGeneratorApi configGen = new DiscoConfigGeneratorApi(options);
configGen.run();
}
use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class DiscoGapicGeneratorTool method generate.
private static void generate(String discoveryDoc, // String[] configs,
String[] generatorConfigs, String packageConfig, String outputDirectory, String[] enabledArtifacts) throws Exception {
ToolOptions options = ToolOptions.create();
// options.set(ToolOptions.CONFIG_FILES, Lists.newArrayList(configs));
options.set(DiscoGapicGeneratorApi.DISCOVERY_DOC, discoveryDoc);
options.set(CodeGeneratorApi.OUTPUT_FILE, outputDirectory);
options.set(CodeGeneratorApi.GENERATOR_CONFIG_FILES, Lists.newArrayList(generatorConfigs));
options.set(CodeGeneratorApi.PACKAGE_CONFIG_FILE, packageConfig);
if (enabledArtifacts != null) {
options.set(CodeGeneratorApi.ENABLED_ARTIFACTS, Lists.newArrayList(enabledArtifacts));
}
DiscoGapicGeneratorApi codeGen = new DiscoGapicGeneratorApi(options);
codeGen.run();
}
use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class DiscoConfigGenerationTest method run.
@Override
public String run() throws Exception {
String outFile = tempDir.getRoot().getPath() + File.separator + baselineFileName();
String discoveryFile = getTestDataLocator().findTestData(discoveryFileName).getFile();
ToolOptions options = ToolOptions.create();
options.set(DiscoConfigGeneratorApi.OUTPUT_FILE, outFile);
options.set(DiscoConfigGeneratorApi.DISCOVERY_DOC, discoveryFile);
new DiscoConfigGeneratorApi(options).run();
return new String(Files.readAllBytes(Paths.get(outFile)), StandardCharsets.UTF_8);
}
use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class PackageMetadataGeneratorTest method run.
@Override
@Nullable
protected Object run() throws Exception {
String outFile = tempDir.getRoot().getPath() + File.separator + baselineFileName();
String metadataConfigPath = getTestDataLocator().findTestData(packageConfig).getPath();
ToolOptions options = ToolOptions.create();
options.set(GrpcMetadataGenerator.OUTPUT_DIR, outFile);
options.set(GrpcMetadataGenerator.INPUT_DIR, getTestDataLocator().findTestData("fakeprotodir").getPath());
options.set(GrpcMetadataGenerator.METADATA_CONFIG_FILE, metadataConfigPath);
options.set(GrpcMetadataGenerator.LANGUAGE, language);
options.set(GrpcMetadataGenerator.ARTIFACT_TYPE, artifactType);
Map<String, Doc> generatedDocs = new GrpcMetadataGenerator(options).generate(model);
if (TargetLanguage.fromString(language) == TargetLanguage.PYTHON) {
OutputCollector collector = new OutputCollector(Paths.get(outFile));
Files.walkFileTree(Paths.get(outFile), collector);
return new ImmutableMap.Builder<String, Doc>().putAll(generatedDocs).putAll(collector.getResults()).build();
} else {
return new ImmutableMap.Builder<String, Doc>().putAll(generatedDocs).build();
}
}
Aggregations