Search in sources :

Example 1 with ToolOptions

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

Example 2 with ToolOptions

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

Example 3 with ToolOptions

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

Example 4 with ToolOptions

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

Example 5 with ToolOptions

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();
    }
}
Also used : Doc(com.google.api.tools.framework.snippet.Doc) ToolOptions(com.google.api.tools.framework.tools.ToolOptions) ImmutableMap(com.google.common.collect.ImmutableMap) Nullable(javax.annotation.Nullable)

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