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.metadata.ArtifactMetadata;
26 import org.apache.maven.artifact.repository.ArtifactRepository;
27 import org.apache.maven.artifact.repository.RepositoryRequest;
28 import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
29 import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
30 import org.apache.maven.artifact.repository.metadata.Versioning;
31 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
32 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
33
34
35
36
37
38 @Named("release")
39 @Singleton
40 @Deprecated
41 public class ReleaseArtifactTransformation extends AbstractVersionTransformation {
42
43 @Override
44 public void transformForResolve(Artifact artifact, RepositoryRequest request)
45 throws ArtifactResolutionException, ArtifactNotFoundException {
46 if (Artifact.RELEASE_VERSION.equals(artifact.getVersion())) {
47 try {
48 String version = resolveVersion(artifact, request);
49
50 if (Artifact.RELEASE_VERSION.equals(version)) {
51 throw new ArtifactNotFoundException("Unable to determine the release version", artifact);
52 }
53
54 artifact.setBaseVersion(version);
55 artifact.updateVersion(version, request.getLocalRepository());
56 } catch (RepositoryMetadataResolutionException e) {
57 throw new ArtifactResolutionException(e.getMessage(), artifact, e);
58 }
59 }
60 }
61
62 @Override
63 public void transformForInstall(Artifact artifact, ArtifactRepository localRepository) {
64 ArtifactMetadata metadata = createMetadata(artifact);
65
66 artifact.addMetadata(metadata);
67 }
68
69 @Override
70 public void transformForDeployment(
71 Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository) {
72 ArtifactMetadata metadata = createMetadata(artifact);
73
74 artifact.addMetadata(metadata);
75 }
76
77 private ArtifactMetadata createMetadata(Artifact artifact) {
78 Versioning versioning = new Versioning();
79
80 versioning.updateTimestamp();
81 versioning.addVersion(artifact.getVersion());
82
83 if (artifact.isRelease()) {
84 versioning.setRelease(artifact.getVersion());
85 }
86
87 return new ArtifactRepositoryMetadata(artifact, versioning);
88 }
89
90 @Override
91 protected String constructVersion(Versioning versioning, String baseVersion) {
92 return versioning.getRelease();
93 }
94 }