}
private File addRepository(String id)
throws Exception
{
final ApplicationConfiguration applicationConfiguration = lookup(ApplicationConfiguration.class);
final File repoRoot = getRepoRoot(id);
final File repoContent = new File("src/test/resources/" + id);
if (repoContent.isDirectory()) {
FileUtils.copyDirectory(repoContent, repoRoot);
}
// ading one hosted only
M2Repository repo = (M2Repository) lookup(Repository.class, "maven2");
CRepository repoConf = new DefaultCRepository();
repoConf.setProviderRole(Repository.class.getName());
repoConf.setProviderHint("maven2");
repoConf.setId(id);
repoConf.setLocalStorage(new CLocalStorage());
repoConf.getLocalStorage().setProvider("file");
repoConf.getLocalStorage().setUrl(repoRoot.toURI().toURL().toString());
Xpp3Dom exRepo = new Xpp3Dom("externalConfiguration");
repoConf.setExternalConfiguration(exRepo);
M2RepositoryConfiguration exRepoConf = new M2RepositoryConfiguration(exRepo);
exRepoConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
exRepoConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
repo.configure(repoConf);
applicationConfiguration.getConfigurationModel().addRepository(repoConf);
lookup(RepositoryRegistry.class).addRepository(repo);
return repoRoot;
}