use of org.kie.maven.integration.embedder.MavenEmbedder in project drools by kiegroup.
the class MavenRepository method getRemoteRepositoryFromDistributionManagement.
protected RemoteRepository getRemoteRepositoryFromDistributionManagement(File pomfile) {
MavenProject mavenProject = parseMavenPom(pomfile);
DistributionManagement distMan = mavenProject.getDistributionManagement();
if (distMan == null) {
return null;
}
DeploymentRepository deployRepo = distMan.getSnapshotRepository() != null && mavenProject.getVersion().endsWith("SNAPSHOT") ? distMan.getSnapshotRepository() : distMan.getRepository();
if (deployRepo == null) {
return null;
}
RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(deployRepo.getId(), deployRepo.getLayout(), deployRepo.getUrl()).setSnapshotPolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)).setReleasePolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_WARN));
Server server = MavenSettings.getSettings().getServer(deployRepo.getId());
if (server != null) {
MavenEmbedder embedder = MavenProjectLoader.newMavenEmbedder(false);
try {
Authentication authentication = embedder.getMavenSession().getRepositorySession().getAuthenticationSelector().getAuthentication(remoteRepoBuilder.build());
remoteRepoBuilder.setAuthentication(authentication);
} finally {
embedder.dispose();
}
}
return remoteRepoBuilder.build();
}
Aggregations