1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.legacy.resolver.transform;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.inject.Singleton;
24
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Objects;
28 import java.util.stream.Collectors;
29 import java.util.stream.Stream;
30
31 import org.apache.maven.artifact.Artifact;
32 import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
33 import org.apache.maven.artifact.installer.ArtifactInstallationException;
34 import org.apache.maven.artifact.repository.ArtifactRepository;
35 import org.apache.maven.artifact.repository.RepositoryRequest;
36 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
37 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
38
39
40
41 @Named
42 @Singleton
43 @Deprecated
44 public class DefaultArtifactTransformationManager implements ArtifactTransformationManager {
45
46 private List<ArtifactTransformation> artifactTransformations;
47
48 @Inject
49 public DefaultArtifactTransformationManager(Map<String, ArtifactTransformation> artifactTransformations) {
50 this.artifactTransformations = Stream.of("release", "latest", "snapshot")
51 .map(artifactTransformations::get)
52 .filter(Objects::nonNull)
53 .collect(Collectors.toList());
54 }
55
56 public void transformForResolve(Artifact artifact, RepositoryRequest request)
57 throws ArtifactResolutionException, ArtifactNotFoundException {
58 for (ArtifactTransformation transform : artifactTransformations) {
59 transform.transformForResolve(artifact, request);
60 }
61 }
62
63 public void transformForResolve(
64 Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository)
65 throws ArtifactResolutionException, ArtifactNotFoundException {
66 for (ArtifactTransformation transform : artifactTransformations) {
67 transform.transformForResolve(artifact, remoteRepositories, localRepository);
68 }
69 }
70
71 public void transformForInstall(Artifact artifact, ArtifactRepository localRepository)
72 throws ArtifactInstallationException {
73 for (ArtifactTransformation transform : artifactTransformations) {
74 transform.transformForInstall(artifact, localRepository);
75 }
76 }
77
78 public void transformForDeployment(
79 Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository)
80 throws ArtifactDeploymentException {
81 for (ArtifactTransformation transform : artifactTransformations) {
82 transform.transformForDeployment(artifact, remoteRepository, localRepository);
83 }
84 }
85
86 public List<ArtifactTransformation> getArtifactTransformations() {
87 return artifactTransformations;
88 }
89 }