repoConf.setProviderRole(Repository.class.getName());
repoConf.setProviderHint("maven2");
repoConf.setId(PROXY_REPO_ID);
repoConf.setName(PROXY_REPO_ID);
repoConf.setNotFoundCacheActive(true);
repoConf.setLocalStorage(new CLocalStorage());
repoConf.getLocalStorage().setProvider("file");
repoConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY_REPO_ID).toURI().toURL()
.toString());
Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
repoConf.setExternalConfiguration(ex);
M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
repoConf.setRemoteStorage(new CRemoteStorage());
repoConf.getRemoteStorage().setProvider(
env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
repoConf.getRemoteStorage().setUrl("http://localhost:" + remoteServerPort + "/");
repo.configure(repoConf);
// repo.setCacheManager( env.getCacheManager() );
reposes.add(repo.getId());
env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
env.getRepositoryRegistry().addRepository(repo);
}
{
// adding one hosted
final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
CRepository repoConf = new DefaultCRepository();
repoConf.setProviderRole(Repository.class.getName());
repoConf.setProviderHint("maven2");
repoConf.setId(HOSTED_REPO_ID);
repoConf.setName(HOSTED_REPO_ID);
repoConf.setLocalStorage(new CLocalStorage());
repoConf.getLocalStorage().setProvider("file");
repoConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + HOSTED_REPO_ID).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);
reposes.add(repo.getId());
env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
env.getRepositoryRegistry().addRepository(repo);
}
{
// add a group
final M2GroupRepository group =
(M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
CRepository repoGroupConf = new DefaultCRepository();
repoGroupConf.setProviderRole(GroupRepository.class.getName());
repoGroupConf.setProviderHint("maven2");
repoGroupConf.setId(GROUP_REPO_ID);
repoGroupConf.setName(GROUP_REPO_ID);
repoGroupConf.setLocalStorage(new CLocalStorage());
repoGroupConf.getLocalStorage().setProvider("file");
repoGroupConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/test").toURI().toURL().toString());
Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
repoGroupConf.setExternalConfiguration(exGroupRepo);