1 | |
package org.apache.maven.artifact.transform; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.artifact.Artifact; |
23 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
24 | |
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; |
25 | |
import org.apache.maven.artifact.repository.metadata.Versioning; |
26 | |
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; |
27 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionException; |
28 | |
|
29 | |
import java.util.List; |
30 | |
|
31 | 13 | public class LatestArtifactTransformation |
32 | |
extends AbstractVersionTransformation |
33 | |
{ |
34 | |
public void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository ) |
35 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
36 | |
{ |
37 | 16 | if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) ) |
38 | |
{ |
39 | |
try |
40 | |
{ |
41 | 0 | String version = resolveVersion( artifact, localRepository, remoteRepositories ); |
42 | 0 | if ( Artifact.LATEST_VERSION.equals( version ) ) |
43 | |
{ |
44 | 0 | throw new ArtifactNotFoundException( "Unable to determine the latest version", artifact ); |
45 | |
} |
46 | |
|
47 | 0 | artifact.setBaseVersion( version ); |
48 | 0 | artifact.updateVersion( version, localRepository ); |
49 | |
} |
50 | 0 | catch ( RepositoryMetadataResolutionException e ) |
51 | |
{ |
52 | 0 | throw new ArtifactResolutionException( e.getMessage(), artifact, e ); |
53 | 0 | } |
54 | |
} |
55 | 16 | } |
56 | |
|
57 | |
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) |
58 | |
{ |
59 | |
|
60 | 1 | } |
61 | |
|
62 | |
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, |
63 | |
ArtifactRepository localRepository ) |
64 | |
{ |
65 | |
|
66 | 1 | } |
67 | |
|
68 | |
protected String constructVersion( Versioning versioning, String baseVersion ) |
69 | |
{ |
70 | 0 | return versioning.getLatest(); |
71 | |
} |
72 | |
} |