repoConf.setProviderHint("maven2");
repoConf.setId(remoteRepoId);
repoConf.setName(remoteRepoId);
repoConf.setNotFoundCacheActive(true);
repoConf.setLocalStorage(new CLocalStorage());
repoConf.getLocalStorage().setProvider("file");
repoConf.getLocalStorage().setUrl(
env
.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + remoteRepoId).toURI()
.toURL().toString()
);
Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
repoConf.setExternalConfiguration(ex);
M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
if (remoteRepoId.endsWith("-snapshot")) {
exConf.setRepositoryPolicy(RepositoryPolicy.SNAPSHOT);
}
else {
exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
}
exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
exConf.setRoutingDiscoveryEnabled(false);
repoConf.setRemoteStorage(new CRemoteStorage());
repoConf.getRemoteStorage().setProvider(env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
repoConf.getRemoteStorage().setUrl(server().getUrl() + "/" + remoteRepoId + "/");
repo.configure(repoConf);
// repo.setCacheManager( env.getCacheManager() );
reposes.add(repo.getId());
env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
env.getRepositoryRegistry().addRepository(repo);
}
// ading one hosted only
M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
CRepository repoConf = new DefaultCRepository();
repoConf.setProviderRole(Repository.class.getName());
repoConf.setProviderHint("maven2");
repoConf.setId("inhouse");
repoConf.setLocalStorage(new CLocalStorage());
repoConf.getLocalStorage().setProvider("file");
repoConf.getLocalStorage().setUrl(
env.getApplicationConfiguration().getWorkingDirectory("proxy/store/inhouse").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 hosted snapshot repo
M2Repository repoSnapshot = (M2Repository) env.lookup(Repository.class, "maven2");
CRepository repoSnapshotConf = new DefaultCRepository();
repoSnapshotConf.setProviderRole(Repository.class.getName());
repoSnapshotConf.setProviderHint("maven2");
repoSnapshotConf.setId("inhouse-snapshot");
repoSnapshotConf.setLocalStorage(new CLocalStorage());
repoSnapshotConf.getLocalStorage().setProvider("file");
repoSnapshotConf.getLocalStorage().setUrl(
env
.getApplicationConfiguration().getWorkingDirectory("proxy/store/inhouse-snapshot").toURI().toURL()
.toString()
);
Xpp3Dom exSnapRepo = new Xpp3Dom("externalConfiguration");
repoSnapshotConf.setExternalConfiguration(exSnapRepo);
M2RepositoryConfiguration exSnapRepoConf = new M2RepositoryConfiguration(exSnapRepo);
exSnapRepoConf.setRepositoryPolicy(RepositoryPolicy.SNAPSHOT);
exSnapRepoConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
repoSnapshot.configure(repoSnapshotConf);
reposes.add(repoSnapshot.getId());
env.getApplicationConfiguration().getConfigurationModel().addRepository(repoSnapshotConf);
env.getRepositoryRegistry().addRepository(repoSnapshot);
// add a group
M2GroupRepository group = (M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
CRepository repoGroupConf = new DefaultCRepository();
repoGroupConf.setProviderRole(GroupRepository.class.getName());
repoGroupConf.setProviderHint("maven2");
repoGroupConf.setId("test");
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");