Search in sources :

Example 1 with YamlFile

use of org.commonjava.maven.ext.common.model.YamlFile in project pom-manipulation-ext by release-engineering.

the class ConfigIO method loadYamlFile.

private Properties loadYamlFile(final File configFile) throws ManipulationException {
    Properties result = new Properties();
    Representer representer = new Representer();
    representer.getPropertyUtils().setSkipMissingProperties(true);
    Yaml yaml = new Yaml(representer);
    try {
        YamlFile yf = yaml.loadAs(new FileInputStream(configFile), YamlFile.class);
        result.putAll(yf.getPme());
    } catch (FileNotFoundException e) {
        throw new ManipulationException("Unable to load yaml file.", e);
    }
    return result;
}
Also used : Representer(org.yaml.snakeyaml.representer.Representer) FileNotFoundException(java.io.FileNotFoundException) ManipulationException(org.commonjava.maven.ext.common.ManipulationException) YamlFile(org.commonjava.maven.ext.common.model.YamlFile) Properties(java.util.Properties) Yaml(org.yaml.snakeyaml.Yaml) FileInputStream(java.io.FileInputStream)

Aggregations

FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 Properties (java.util.Properties)1 ManipulationException (org.commonjava.maven.ext.common.ManipulationException)1 YamlFile (org.commonjava.maven.ext.common.model.YamlFile)1 Yaml (org.yaml.snakeyaml.Yaml)1 Representer (org.yaml.snakeyaml.representer.Representer)1