use of com.google.api.codegen.viewmodel.metadata.PackageDependencyView in project toolkit by googleapis.
the class PackageMetadataTransformer method getDependencies.
private List<PackageDependencyView> getDependencies(PackageMetadataNamer namer, Map<String, VersionBound> dependencies, Set<String> whitelistedDependencies) {
List<PackageDependencyView> protoPackageDependencies = new ArrayList<>();
if (dependencies != null) {
Map<String, VersionBound> dependenciesCopy = new HashMap<>(dependencies);
if (whitelistedDependencies != null) {
dependenciesCopy.keySet().retainAll(whitelistedDependencies);
}
for (Map.Entry<String, VersionBound> entry : dependenciesCopy.entrySet()) {
PackageDependencyView packageDependency = PackageDependencyView.newBuilder().group(namer.getProtoPackageGroup()).name(entry.getKey()).versionBound(entry.getValue()).build();
protoPackageDependencies.add(packageDependency);
}
// Ensures deterministic test results.
Collections.sort(protoPackageDependencies);
}
return protoPackageDependencies;
}
use of com.google.api.codegen.viewmodel.metadata.PackageDependencyView in project toolkit by googleapis.
the class JavaPackageMetadataTransformer method generateMetadataViewBuilders.
/**
* Creates a partially initialized builders that can be used to build PackageMetadataViews later.
*/
protected final List<PackageMetadataView.Builder> generateMetadataViewBuilders(ApiModel model, PackageMetadataConfig config, ArtifactType artifactType) {
JavaPackageMetadataNamer namer = new JavaPackageMetadataNamer(config.packageName(TargetLanguage.JAVA), artifactType);
List<PackageDependencyView> additionalDependencies = new ArrayList<>();
if (!SERVICES_WITH_NO_RESOURCE_NAMES.contains(config.shortName())) {
PackageDependencyView packageDependency = PackageDependencyView.newBuilder().group("com.google.api").name("api-common").versionBound(config.apiCommonVersionBound(TargetLanguage.JAVA)).build();
additionalDependencies.add(packageDependency);
}
ArrayList<PackageMetadataView.Builder> viewBuilders = new ArrayList<>();
for (Map.Entry<String, String> entry : getSnippetsOutput().entrySet()) {
PackageMetadataView.Builder viewBuilder = metadataTransformer.generateMetadataView(namer, config, model, entry.getKey(), entry.getValue(), TargetLanguage.JAVA).additionalDependencies(additionalDependencies).identifier(namer.getMetadataIdentifier()).protoPackageName(namer.getProtoPackageName()).grpcPackageName(namer.getGrpcPackageName()).publishProtos(artifactType == ArtifactType.PROTOBUF);
viewBuilders.add(viewBuilder);
}
return viewBuilders;
}
use of com.google.api.codegen.viewmodel.metadata.PackageDependencyView in project toolkit by googleapis.
the class JavaGapicSamplesPackageTransformer method additionalSampleDependencies.
private List<PackageDependencyView> additionalSampleDependencies() {
PackageDependencyView apiCommonDep = PackageDependencyView.newBuilder().group("com.google.api").name("api-common").versionBound(packageConfig.apiCommonVersionBound(TargetLanguage.JAVA)).build();
PackageDependencyView commonsCliDep = PackageDependencyView.newBuilder().group("commons-cli").name("commons-cli").versionBound(packageConfig.commonsCliVersionBound(TargetLanguage.JAVA)).build();
return ImmutableList.<PackageDependencyView>of(apiCommonDep, commonsCliDep);
}
use of com.google.api.codegen.viewmodel.metadata.PackageDependencyView in project toolkit by googleapis.
the class NodeJSSamplePackageMetadataTransformer method additionalDependencies.
private List<PackageDependencyView> additionalDependencies(NodeJSPackageMetadataNamer gapicPackageNamer) {
PackageDependencyView yargsDep = PackageDependencyView.create("yargs", packageConfig.commonsCliVersionBound(TargetLanguage.NODEJS));
PackageDependencyView gapicDep = PackageDependencyView.create(gapicPackageNamer.getMetadataIdentifier(), VersionBound.create("file:..", "file:.."));
return ImmutableList.of(yargsDep, gapicDep);
}
use of com.google.api.codegen.viewmodel.metadata.PackageDependencyView in project toolkit by googleapis.
the class JavaPackageTransformer method generateMetadataViewBuilders.
/**
* Creates a partially initialized builders that can be used to build PackageMetadataViews later.
*/
protected final List<PackageMetadataView.Builder> generateMetadataViewBuilders(ApiModel model, PackageMetadataConfig config, PackagingArtifactType artifactType) {
String packageName = config.packageName();
JavaPackageMetadataNamer namer = new JavaPackageMetadataNamer(packageName, artifactType);
List<PackageDependencyView> additionalDependencies = new ArrayList<>();
if (!SERVICES_WITH_NO_RESOURCE_NAMES.contains(config.shortName())) {
PackageDependencyView packageDependency = PackageDependencyView.newBuilder().group("com.google.api").name("api-common").versionBound(config.apiCommonVersionBound(TargetLanguage.JAVA)).build();
additionalDependencies.add(packageDependency);
}
ArrayList<PackageMetadataView.Builder> viewBuilders = new ArrayList<>();
for (Map.Entry<String, String> entry : getSnippetsOutput().entrySet()) {
PackageMetadataView.Builder viewBuilder = metadataTransformer.generateMetadataView(namer, config, model, entry.getKey(), entry.getValue(), TargetLanguage.JAVA).additionalDependencies(additionalDependencies).packageName(packageName).identifier(namer.getMetadataIdentifier()).protoPackageName(namer.getProtoPackageName()).grpcPackageName(namer.getGrpcPackageName()).publishProtos(artifactType == PackagingArtifactType.PROTOBUF);
viewBuilders.add(viewBuilder);
}
return viewBuilders;
}
Aggregations