|
12 | 12 | import org.eclipse.aether.RepositorySystemSession; |
13 | 13 | import org.eclipse.aether.artifact.DefaultArtifact; |
14 | 14 | import org.eclipse.aether.impl.ArtifactResolver; |
| 15 | +import org.eclipse.aether.repository.Authentication; |
15 | 16 | import org.eclipse.aether.repository.LocalRepository; |
16 | 17 | import org.eclipse.aether.repository.RemoteRepository; |
17 | 18 | import org.eclipse.aether.resolution.ArtifactRequest; |
18 | 19 | import org.eclipse.aether.resolution.ArtifactResolutionException; |
19 | 20 | import org.eclipse.aether.resolution.ArtifactResult; |
| 21 | +import org.eclipse.aether.util.repository.AuthenticationBuilder; |
20 | 22 |
|
21 | 23 | import java.io.BufferedReader; |
22 | 24 | import java.io.File; |
@@ -114,11 +116,23 @@ private RemoteRepository getRepository(final String altRepository) throws MojoEx |
114 | 116 | String id = matcher.group(1).trim(); |
115 | 117 | String layout = matcher.group(2).trim(); |
116 | 118 | String url = matcher.group(3).trim(); |
117 | | - boolean unique = Boolean.parseBoolean(matcher.group(4).trim()); |
| 119 | + Authentication remoteRepoAuthentication = null; |
| 120 | + |
| 121 | + for (ArtifactRepository artifactRepository : project.getRemoteArtifactRepositories()) { |
| 122 | + if (artifactRepository.getId().equals(id)){ |
| 123 | + final org.apache.maven.artifact.repository.Authentication authentication = artifactRepository.getAuthentication(); |
| 124 | + AuthenticationBuilder authenticationBuilder = new AuthenticationBuilder(); |
| 125 | + authenticationBuilder |
| 126 | + .addUsername(authentication.getUsername()) |
| 127 | + .addPassword(authentication.getPassword()) |
| 128 | + .addPrivateKey(authentication.getPrivateKey(), authentication.getPassphrase()); |
| 129 | + remoteRepoAuthentication = authenticationBuilder.build(); |
| 130 | + |
| 131 | + } |
| 132 | + } |
118 | 133 |
|
119 | | - ArtifactRepositoryLayout repoLayout = getLayout(layout); |
120 | 134 |
|
121 | | - return new RemoteRepository.Builder(id, layout, url).build(); |
| 135 | + return new RemoteRepository.Builder(id, layout, url).setAuthentication(remoteRepoAuthentication).build(); |
122 | 136 | } |
123 | 137 |
|
124 | 138 | private String getCoordinates(ArtifactResult result) { |
|
0 commit comments