1 package org.apache.maven.project;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.sonatype.aether.RepositorySystemSession;
25 import org.sonatype.aether.artifact.Artifact;
26 import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
27 import org.sonatype.aether.repository.LocalArtifactRequest;
28 import org.sonatype.aether.repository.LocalArtifactResult;
29
30
31
32
33 public class LegacyLocalRepositoryManager
34 extends SimpleLocalRepositoryManager
35 {
36
37 public LegacyLocalRepositoryManager( File basedir )
38 {
39 super( basedir );
40 }
41
42 public String getPathForLocalArtifact( Artifact artifact )
43 {
44 StringBuilder path = new StringBuilder( 128 );
45
46 path.append( artifact.getGroupId() ).append( '/' );
47
48 path.append( artifact.getExtension() ).append( 's' ).append( '/' );
49
50 path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
51
52 if ( artifact.getClassifier().length() > 0 )
53 {
54 path.append( '-' ).append( artifact.getClassifier() );
55 }
56
57 path.append( '.' ).append( artifact.getExtension() );
58
59 return path.toString();
60 }
61
62 public LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request )
63 {
64 String path = getPathForLocalArtifact( request.getArtifact() );
65 File file = new File( getRepository().getBasedir(), path );
66 LocalArtifactResult result = new LocalArtifactResult( request );
67 if ( file.isFile() )
68 {
69 result.setFile( file );
70 result.setAvailable( true );
71 }
72 return result;
73 }
74
75 }