use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class GrpcMetadataGeneratorTool method generate.
private static void generate(String descriptorSet, String[] configs, String inputDir, String outputDir, String languageString, String metadataConfig, String artifactType) {
TargetLanguage language = TargetLanguage.fromString(languageString);
ToolOptions options = ToolOptions.create();
options.set(GrpcMetadataGenerator.INPUT_DIR, inputDir);
options.set(GrpcMetadataGenerator.OUTPUT_DIR, outputDir);
options.set(ToolOptions.DESCRIPTOR_SET, descriptorSet);
if (configs != null) {
options.set(ToolOptions.CONFIG_FILES, Lists.newArrayList(configs));
}
options.set(GrpcMetadataGenerator.METADATA_CONFIG_FILE, metadataConfig);
options.set(GrpcMetadataGenerator.LANGUAGE, languageString);
if (artifactType != null) {
options.set(GrpcMetadataGenerator.ARTIFACT_TYPE, ArtifactType.of(artifactType));
}
GrpcMetadataGenerator generator = new GrpcMetadataGenerator(options);
generator.run();
}
use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class CodeGeneratorTool method generate.
private static int generate(String descriptorSet, String[] configs, String[] generatorConfigs, String packageConfig, String outputDirectory, String[] enabledArtifacts) {
ToolOptions options = ToolOptions.create();
options.set(ToolOptions.DESCRIPTOR_SET, descriptorSet);
options.set(ToolOptions.CONFIG_FILES, Lists.newArrayList(configs));
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));
}
CodeGeneratorApi codeGen = new CodeGeneratorApi(options);
return codeGen.run();
}
use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class SynchronizerTool method synchronize.
private static void synchronize(String sourcePath, String generatedPath, String baselinePath, boolean autoMerge, boolean autoResolve, boolean ignoreBase) {
ToolOptions options = ToolOptions.create();
options.set(Synchronizer.SOURCE_PATH, sourcePath);
options.set(Synchronizer.GENERATED_PATH, generatedPath);
options.set(Synchronizer.BASELINE_PATH, baselinePath);
options.set(Synchronizer.AUTO_MERGE, autoMerge);
options.set(Synchronizer.AUTO_RESOLUTION, autoResolve);
options.set(Synchronizer.IGNORE_BASE, ignoreBase);
Synchronizer synchronizer = new Synchronizer(options);
synchronizer.run();
}
use of com.google.api.tools.framework.tools.ToolOptions in project toolkit by googleapis.
the class ConfigGenerationTest method run.
@Override
public Object run() throws Exception {
String outFile = tempDir.getRoot().getPath() + File.separator + baselineFileName();
String serviceConfigPath = getTestDataLocator().findTestData(testName.getMethodName() + ".yaml").getPath();
ToolOptions options = ToolOptions.create();
options.set(ConfigGeneratorApi.OUTPUT_FILE, outFile);
options.set(ToolOptions.DESCRIPTOR_SET, testConfig.getDescriptorFile().toString());
options.set(ToolOptions.CONFIG_FILES, Lists.newArrayList(serviceConfigPath));
new ConfigGeneratorApi(options).run();
String outputContent = new String(Files.readAllBytes(Paths.get(outFile)), StandardCharsets.UTF_8);
return outputContent;
}
Aggregations