use of org.eclipse.winery.repository.filebased.management.IRepositoryResolver in project winery by eclipse.
the class MultiRepository method createRepository.
/**
* This method clones a repository into the file system. If the cloned repository contains dependencies in the form
* of a repositories.json file, the dependencies will be cloned recursively if they are not already in the
* MultiRepository. The subrepositories are GitbasedRepositories and are added to the list of repositories to the
* MultiRepository. It the subrepositories have dependencies, they are initialized as MultiRepos
*
* @param url of the repository
* @param branch which should be cloned
*/
private void createRepository(String url, String branch) {
IRepositoryResolver resolver = null;
Optional<IRepositoryResolver> resolverOptional = RepositoryResolverFactory.getResolver(url, branch);
if (resolverOptional.isPresent()) {
resolver = resolverOptional.get();
}
if (resolver != null && !RepositoryUtils.checkRepositoryDuplicate(url, this)) {
try {
String ownerDirectory = URLEncoder.encode(resolver.getRepositoryMaintainerUrl(), "UTF-8");
Path ownerRoot = this.repositoryRoot.resolve(ownerDirectory);
if (!ownerRoot.toFile().exists()) {
Files.createDirectories(ownerRoot);
}
Path repositoryLocation = ownerRoot.resolve(resolver.getRepositoryName());
IRepository newSubRepository = resolver.createRepository(repositoryLocation.toFile());
this.addRepository(newSubRepository);
File configurationFile = newSubRepository.getRepositoryRoot().resolve(Filename.FILENAME_JSON_MUTLI_REPOSITORIES).toFile();
if (configurationFile.exists()) {
loadRepositoriesByList(loadConfiguration(configurationFile));
}
fixNamespaces(newSubRepository);
} catch (IOException | GitAPIException e) {
LOGGER.error("Error while creating the repository structure", e);
}
}
}
Aggregations