Java Code Examples for org.apache.maven.model.Repository#setLayout()

The following examples show how to use org.apache.maven.model.Repository#setLayout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YamlFileRepositoryLoader.java    From yaks with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: JsonFileRepositoryLoader.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Repository> load(Path filePath, Logger logger) throws LifecycleExecutionException {
    List<Repository> repositoryList = new ArrayList<>();

    ObjectMapper mapper = new ObjectMapper();
    try {
        JsonNode root = mapper.readTree(new StringReader(new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8)));
        ArrayNode repositories = (ArrayNode) root.get("repositories");
        for (Object o : repositories) {
            ObjectNode model = (ObjectNode) o;
            Repository repository = new Repository();

            repository.setId(model.get("id").textValue());
            repository.setUrl(model.get("url").textValue());

            if (model.get("name") != null) {
                repository.setName(model.get("name").textValue());
            }

            if (model.get("layout") != null) {
                repository.setLayout(model.get("layout").textValue());
            }

            if (model.get("releases") != null) {
                repository.setReleases(getRepositoryPolicy((ObjectNode) model.get("releases")));
            }

            if (model.get("snapshots") != null) {
                repository.setReleases(getRepositoryPolicy((ObjectNode) model.get("snapshots")));
            }

            logger.info(String.format("Add Repository %s=%s", repository.getId(), repository.getUrl()));
            repositoryList.add(repository);
        }
    } catch (IOException e) {
        throw new LifecycleExecutionException("Failed to read json repository config file", e);
    }

    return repositoryList;
}
 
Example 3
Source File: BuildManager.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private Repository createRepo(String id, String url, String layout) {
	Repository repo = new Repository();
	repo.setId(id);
	repo.setUrl(url);
	repo.setLayout(layout);
	return repo;
}