View Javadoc

1   package org.apache.maven.artifact.repository.metadata;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.artifact.repository.ArtifactRepository;
23  
24  import java.util.Iterator;
25  import java.util.List;
26  
27  /**
28   * Metadata for the group directory of the repository.
29   *
30   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
31   * @version $Id: GroupRepositoryMetadata.java 640549 2008-03-24 20:05:11Z bentmann $
32   */
33  public class GroupRepositoryMetadata
34      extends AbstractRepositoryMetadata
35  {
36      private final String groupId;
37  
38      public GroupRepositoryMetadata( String groupId )
39      {
40          super( new Metadata() );
41          this.groupId = groupId;
42      }
43  
44      public boolean storedInGroupDirectory()
45      {
46          return true;
47      }
48  
49      public boolean storedInArtifactVersionDirectory()
50      {
51          return false;
52      }
53  
54      public String getGroupId()
55      {
56          return groupId;
57      }
58  
59      public String getArtifactId()
60      {
61          return null;
62      }
63  
64      public String getBaseVersion()
65      {
66          return null;
67      }
68  
69      public void addPluginMapping( String goalPrefix, String artifactId )
70      {
71          addPluginMapping( goalPrefix, artifactId, artifactId );    
72      }
73  
74      public void addPluginMapping( String goalPrefix, String artifactId, String name )
75      {
76          List plugins = getMetadata().getPlugins();
77          boolean found = false;
78          for ( Iterator i = plugins.iterator(); i.hasNext() && !found; )
79          {
80              Plugin plugin = (Plugin) i.next();
81              if ( plugin.getPrefix().equals( goalPrefix ) )
82              {
83                  found = true;
84              }
85          }
86          if ( !found )
87          {
88              Plugin plugin = new Plugin();
89              plugin.setPrefix( goalPrefix );
90              plugin.setArtifactId( artifactId );
91              plugin.setName( name );
92  
93  
94              getMetadata().addPlugin( plugin );
95          }
96      }
97  
98      public Object getKey()
99      {
100         return groupId;
101     }
102 
103     public boolean isSnapshot()
104     {
105         return false;
106     }
107 
108     public void setRepository( ArtifactRepository remoteRepository )
109     {
110         // intentionally blank
111     }
112 }