CRepository repoConf = new DefaultCRepository();
repoConf.setProviderRole(Repository.class.getName());
repoConf.setProviderHint("maven2");
repoConf.setId(HOSTED1_REPO_ID);
repoConf.setName(HOSTED1_REPO_ID);
repoConf.setLocalStorage(new CLocalStorage());
repoConf.getLocalStorage().setProvider("file");
repoConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + HOSTED1_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);
}
{
// 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(HOSTED2_REPO_ID);
repoConf.setName(HOSTED2_REPO_ID);
repoConf.setLocalStorage(new CLocalStorage());
repoConf.getLocalStorage().setProvider("file");
repoConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + HOSTED2_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(GROUP1_REPO_ID);
repoGroupConf.setName(GROUP1_REPO_ID);
repoGroupConf.setLocalStorage(new CLocalStorage());
repoGroupConf.getLocalStorage().setProvider("file");
repoGroupConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + GROUP1_REPO_ID).toURI().toURL()
.toString());
Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
repoGroupConf.setExternalConfiguration(exGroupRepo);
M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
exGroupRepoConf.setMemberRepositoryIds(reposes);
exGroupRepoConf.setMergeMetadata(true);
group.configure(repoGroupConf);
env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
env.getRepositoryRegistry().addRepository(group);
}
{
// add 2nd group
final M2GroupRepository group =
(M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
CRepository repoGroupConf = new DefaultCRepository();
repoGroupConf.setProviderRole(GroupRepository.class.getName());
repoGroupConf.setProviderHint("maven2");
repoGroupConf.setId(GROUP2_REPO_ID);
repoGroupConf.setName(GROUP2_REPO_ID);
repoGroupConf.setLocalStorage(new CLocalStorage());
repoGroupConf.getLocalStorage().setProvider("file");
repoGroupConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + GROUP2_REPO_ID).toURI().toURL()
.toString());
Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");