use of org.apache.maven.model.DeploymentRepository 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();
}
use of org.apache.maven.model.DeploymentRepository in project maven-plugins by apache.
the class ProjectInfoReportUtilsTest method getMavenProjectStub.
private MavenProject getMavenProjectStub(boolean https) {
final DistributionManagement distributionManagement = new DistributionManagement();
DeploymentRepository repository = new DeploymentRepository();
repository.setId("localhost");
repository.setUrl((https ? "https" : "http") + "://localhost:" + port);
distributionManagement.setRepository(repository);
distributionManagement.setSnapshotRepository(repository);
return new MavenProjectStub() {
@Override
public DistributionManagement getDistributionManagement() {
return distributionManagement;
}
};
}
Aggregations