Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] Authorization Problem when Deploying

Timo Rohrberg wrote:

I am doing the following:

final DeploymentRepository deploymentRepo =
mavenProject.getDistributionManagement().getRepository();
RemoteRepository repository = new
RemoteRepository.Builder(deploymentRepo.getId(),
deploymentRepo.getLayout(), deploymentRepo.getUrl()).build();
[...]
repoSystem.deploy(repoSession, deployRequest);

This means, I'm reading the repository from the injected MavenProject's
pom.xml. Do I have to do anything else to correctly configure the
credentials to use?

Yes, you need to call RemoteRepository.Builder.setAuthentication() with the desired credentials. One way of obtaining the proper credentials would be repoSession.getAuthenticationSelector().getAuthentication().

However, for deploying artifacts, it might be easier to employ the same code that the maven-deploy-plugin uses, i.e. the ArtifactDeployer and MavenProject.getDistributionManagementArtifactRepository(). I see no benefit in using Aether directly for this.


Benjamin



Back to the top