use of com.amazon.aws.iot.greengrass.component.common.PlatformSpecificManifest in project aws-greengrass-nucleus by aws-greengrass.
the class RecipeLoader method loadFromFile.
/**
* Converts from the recipe file with platform resolving.
*
* @param recipeFileContent recipe file content
* @return Optional package recipe
* @throws PackageLoadingException when failed to convert recipe file.
*/
public Optional<ComponentRecipe> loadFromFile(String recipeFileContent) throws PackageLoadingException {
com.amazon.aws.iot.greengrass.component.common.ComponentRecipe componentRecipe = parseRecipe(recipeFileContent, RecipeFormat.YAML);
if (componentRecipe.getManifests() == null || componentRecipe.getManifests().isEmpty()) {
throw new PackageLoadingException(String.format("Recipe file %s-%s.yaml is missing manifests", componentRecipe.getComponentName(), componentRecipe.getComponentVersion().toString()));
}
Optional<PlatformSpecificManifest> optionalPlatformSpecificManifest = platformResolver.findBestMatch(componentRecipe.getManifests());
if (!optionalPlatformSpecificManifest.isPresent()) {
return Optional.empty();
}
PlatformSpecificManifest platformSpecificManifest = optionalPlatformSpecificManifest.get();
Set<String> selectors = collectAllSelectors(componentRecipe.getManifests());
Map<String, DependencyProperties> dependencyPropertiesMap = new HashMap<>();
if (componentRecipe.getComponentDependencies() != null) {
dependencyPropertiesMap.putAll(componentRecipe.getComponentDependencies());
}
ComponentRecipe packageRecipe = ComponentRecipe.builder().componentName(componentRecipe.getComponentName()).version(componentRecipe.getComponentVersion()).publisher(componentRecipe.getComponentPublisher()).recipeTemplateVersion(componentRecipe.getRecipeFormatVersion()).componentType(componentRecipe.getComponentType()).dependencies(dependencyPropertiesMap).lifecycle(convertLifecycleFromFile(componentRecipe.getLifecycle(), platformSpecificManifest, selectors)).artifacts(convertArtifactsFromFile(platformSpecificManifest.getArtifacts())).componentConfiguration(componentRecipe.getComponentConfiguration()).build();
return Optional.of(packageRecipe);
}
Aggregations