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.Named;
22 import javax.inject.Singleton;
23
24 import org.apache.maven.artifact.Artifact;
25 import org.apache.maven.artifact.repository.ArtifactRepository;
26 import org.apache.maven.artifact.repository.RepositoryRequest;
27 import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
28 import org.apache.maven.artifact.repository.metadata.Versioning;
29 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
30 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
31
32
33
34
35 @Named("latest")
36 @Singleton
37 @Deprecated
38 public class LatestArtifactTransformation extends AbstractVersionTransformation {
39
40 public void transformForResolve(Artifact artifact, RepositoryRequest request)
41 throws ArtifactResolutionException, ArtifactNotFoundException {
42 if (Artifact.LATEST_VERSION.equals(artifact.getVersion())) {
43 try {
44 String version = resolveVersion(artifact, request);
45 if (Artifact.LATEST_VERSION.equals(version)) {
46 throw new ArtifactNotFoundException("Unable to determine the latest version", artifact);
47 }
48
49 artifact.setBaseVersion(version);
50 artifact.updateVersion(version, request.getLocalRepository());
51 } catch (RepositoryMetadataResolutionException e) {
52 throw new ArtifactResolutionException(e.getMessage(), artifact, e);
53 }
54 }
55 }
56
57 public void transformForInstall(Artifact artifact, ArtifactRepository localRepository) {
58
59 }
60
61 public void transformForDeployment(
62 Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository) {
63
64 }
65
66 protected String constructVersion(Versioning versioning, String baseVersion) {
67 return versioning.getLatest();
68 }
69 }