KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > artifact > repository > layout > LegacyRepositoryLayout


1 package org.apache.maven.artifact.repository.layout;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.maven.artifact.Artifact;
20 import org.apache.maven.artifact.handler.ArtifactHandler;
21 import org.apache.maven.artifact.metadata.ArtifactMetadata;
22 import org.apache.maven.artifact.repository.ArtifactRepository;
23
24 /**
25  * @author jdcasey
26  */

27 public class LegacyRepositoryLayout
28     implements ArtifactRepositoryLayout
29 {
30     private static final String JavaDoc PATH_SEPARATOR = "/";
31
32     public String JavaDoc pathOf( Artifact artifact )
33     {
34         ArtifactHandler artifactHandler = artifact.getArtifactHandler();
35
36         StringBuffer JavaDoc path = new StringBuffer JavaDoc();
37
38         path.append( artifact.getGroupId() ).append( '/' );
39         path.append( artifactHandler.getDirectory() ).append( '/' );
40         path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
41
42         if ( artifact.hasClassifier() )
43         {
44             path.append( '-' ).append( artifact.getClassifier() );
45         }
46
47         if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
48         {
49             path.append( '.' ).append( artifactHandler.getExtension() );
50         }
51
52         return path.toString();
53     }
54
55     public String JavaDoc pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
56     {
57         return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) );
58     }
59
60     private String JavaDoc pathOfRepositoryMetadata( ArtifactMetadata metadata, String JavaDoc filename )
61     {
62         StringBuffer JavaDoc path = new StringBuffer JavaDoc();
63
64         path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR );
65
66         path.append( filename );
67
68         return path.toString();
69     }
70
71     public String JavaDoc pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
72     {
73         return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() );
74     }
75
76 }
77
Popular Tags