Search in sources :

Example 1 with DeploymentRepository

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();
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Server(org.apache.maven.settings.Server) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) MavenEmbedder(org.kie.maven.integration.embedder.MavenEmbedder) Authentication(org.eclipse.aether.repository.Authentication) DeploymentRepository(org.apache.maven.model.DeploymentRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DistributionManagement(org.apache.maven.model.DistributionManagement)

Example 2 with DeploymentRepository

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;
        }
    };
}
Also used : MavenProjectStub(org.apache.maven.plugin.testing.stubs.MavenProjectStub) DeploymentRepository(org.apache.maven.model.DeploymentRepository) DistributionManagement(org.apache.maven.model.DistributionManagement)

Aggregations

DeploymentRepository (org.apache.maven.model.DeploymentRepository)2 DistributionManagement (org.apache.maven.model.DistributionManagement)2 MavenProjectStub (org.apache.maven.plugin.testing.stubs.MavenProjectStub)1 MavenProject (org.apache.maven.project.MavenProject)1 Server (org.apache.maven.settings.Server)1 Authentication (org.eclipse.aether.repository.Authentication)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 RepositoryPolicy (org.eclipse.aether.repository.RepositoryPolicy)1 MavenEmbedder (org.kie.maven.integration.embedder.MavenEmbedder)1