Search in sources :

Example 6 with ToolOptions

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();
}
Also used : ToolOptions(com.google.api.tools.framework.tools.ToolOptions) TargetLanguage(com.google.api.codegen.TargetLanguage)

Example 7 with ToolOptions

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();
}
Also used : ToolOptions(com.google.api.tools.framework.tools.ToolOptions)

Example 8 with ToolOptions

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();
}
Also used : Synchronizer(com.google.api.codegen.sync.Synchronizer) ToolOptions(com.google.api.tools.framework.tools.ToolOptions)

Example 9 with ToolOptions

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;
}
Also used : ConfigGeneratorApi(com.google.api.codegen.configgen.ConfigGeneratorApi) ToolOptions(com.google.api.tools.framework.tools.ToolOptions)

Aggregations

ToolOptions (com.google.api.tools.framework.tools.ToolOptions)9 TargetLanguage (com.google.api.codegen.TargetLanguage)1 ConfigGeneratorApi (com.google.api.codegen.configgen.ConfigGeneratorApi)1 DiscoConfigGeneratorApi (com.google.api.codegen.configgen.DiscoConfigGeneratorApi)1 Synchronizer (com.google.api.codegen.sync.Synchronizer)1 Doc (com.google.api.tools.framework.snippet.Doc)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Nullable (javax.annotation.Nullable)1