@Test public void shouldLoadFromYaml() throws LifecycleExecutionException, URISyntaxException { List<Repository> repositoryList = loader.load(TestHelper.getClasspathResource("yaks.settings.yaml"), logger); TestHelper.verifyRepositories(repositoryList); }
@Override protected List<Repository> load(Path filePath, Logger logger) throws LifecycleExecutionException { try { List<Repository> repositoryList = new ArrayList<>(); Yaml yaml = new Yaml(); HashMap<String, List<Map<String, Object>>> root = yaml.load(new StringReader(new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8))); if (root.containsKey("repositories")) { for (Map<String, Object> model : root.get("repositories")) { Repository repository = new Repository(); repository.setId(Objects.toString(model.get("id"))); repository.setName(Objects.toString(model.getOrDefault("name", repository.getId()))); repository.setUrl(Objects.toString(model.get("url"))); repository.setLayout(Objects.toString(model.getOrDefault("layout", "default"))); if (model.containsKey("releases")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("releases"))); } if (model.containsKey("snapshots")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("snapshots"))); } logger.info(String.format("Add Repository %s=%s", repository.getId(), repository.getUrl())); repositoryList.add(repository); } } return repositoryList; } catch (IOException e) { throw new LifecycleExecutionException("Failed to read repository configuration file", e); } }
YamlFileRepositoryLoader extends AbstractConfigFileRepositoryLoader { @Override protected List<Repository> load(Path filePath, Logger logger) throws LifecycleExecutionException { try { List<Repository> repositoryList = new ArrayList<>(); Yaml yaml = new Yaml(); HashMap<String, List<Map<String, Object>>> root = yaml.load(new StringReader(new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8))); if (root.containsKey("repositories")) { for (Map<String, Object> model : root.get("repositories")) { Repository repository = new Repository(); repository.setId(Objects.toString(model.get("id"))); repository.setName(Objects.toString(model.getOrDefault("name", repository.getId()))); repository.setUrl(Objects.toString(model.get("url"))); repository.setLayout(Objects.toString(model.getOrDefault("layout", "default"))); if (model.containsKey("releases")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("releases"))); } if (model.containsKey("snapshots")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("snapshots"))); } logger.info(String.format("Add Repository %s=%s", repository.getId(), repository.getUrl())); repositoryList.add(repository); } } return repositoryList; } catch (IOException e) { throw new LifecycleExecutionException("Failed to read repository configuration file", e); } } }
YamlFileRepositoryLoader extends AbstractConfigFileRepositoryLoader { @Override protected List<Repository> load(Path filePath, Logger logger) throws LifecycleExecutionException { try { List<Repository> repositoryList = new ArrayList<>(); Yaml yaml = new Yaml(); HashMap<String, List<Map<String, Object>>> root = yaml.load(new StringReader(new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8))); if (root.containsKey("repositories")) { for (Map<String, Object> model : root.get("repositories")) { Repository repository = new Repository(); repository.setId(Objects.toString(model.get("id"))); repository.setName(Objects.toString(model.getOrDefault("name", repository.getId()))); repository.setUrl(Objects.toString(model.get("url"))); repository.setLayout(Objects.toString(model.getOrDefault("layout", "default"))); if (model.containsKey("releases")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("releases"))); } if (model.containsKey("snapshots")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("snapshots"))); } logger.info(String.format("Add Repository %s=%s", repository.getId(), repository.getUrl())); repositoryList.add(repository); } } return repositoryList; } catch (IOException e) { throw new LifecycleExecutionException("Failed to read repository configuration file", e); } }  }
YamlFileRepositoryLoader extends AbstractConfigFileRepositoryLoader { @Override protected List<Repository> load(Path filePath, Logger logger) throws LifecycleExecutionException { try { List<Repository> repositoryList = new ArrayList<>(); Yaml yaml = new Yaml(); HashMap<String, List<Map<String, Object>>> root = yaml.load(new StringReader(new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8))); if (root.containsKey("repositories")) { for (Map<String, Object> model : root.get("repositories")) { Repository repository = new Repository(); repository.setId(Objects.toString(model.get("id"))); repository.setName(Objects.toString(model.getOrDefault("name", repository.getId()))); repository.setUrl(Objects.toString(model.get("url"))); repository.setLayout(Objects.toString(model.getOrDefault("layout", "default"))); if (model.containsKey("releases")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("releases"))); } if (model.containsKey("snapshots")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("snapshots"))); } logger.info(String.format("Add Repository %s=%s", repository.getId(), repository.getUrl())); repositoryList.add(repository); } } return repositoryList; } catch (IOException e) { throw new LifecycleExecutionException("Failed to read repository configuration file", e); } }   }
YamlFileRepositoryLoader extends AbstractConfigFileRepositoryLoader { @Override protected List<Repository> load(Path filePath, Logger logger) throws LifecycleExecutionException { try { List<Repository> repositoryList = new ArrayList<>(); Yaml yaml = new Yaml(); HashMap<String, List<Map<String, Object>>> root = yaml.load(new StringReader(new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8))); if (root.containsKey("repositories")) { for (Map<String, Object> model : root.get("repositories")) { Repository repository = new Repository(); repository.setId(Objects.toString(model.get("id"))); repository.setName(Objects.toString(model.getOrDefault("name", repository.getId()))); repository.setUrl(Objects.toString(model.get("url"))); repository.setLayout(Objects.toString(model.getOrDefault("layout", "default"))); if (model.containsKey("releases")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("releases"))); } if (model.containsKey("snapshots")) { repository.setReleases(getRepositoryPolicy((Map<String, Object>) model.get("snapshots"))); } logger.info(String.format("Add Repository %s=%s", repository.getId(), repository.getUrl())); repositoryList.add(repository); } } return repositoryList; } catch (IOException e) { throw new LifecycleExecutionException("Failed to read repository configuration file", e); } }    }