View Javadoc
1   package org.apache.maven.plugin.plugin.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 java.util.Iterator;
23  import java.util.List;
24  
25  import org.apache.maven.artifact.repository.ArtifactRepository;
26  import org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata;
27  import org.apache.maven.artifact.repository.metadata.Metadata;
28  import org.apache.maven.artifact.repository.metadata.Plugin;
29  
30  /**
31   * Metadata for the group directory of the repository.
32   *
33   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
34   */
35  public class GroupRepositoryMetadata
36      extends AbstractRepositoryMetadata
37  {
38      private final String groupId;
39  
40      public GroupRepositoryMetadata( String groupId )
41      {
42          super( new Metadata() );
43          this.groupId = groupId;
44      }
45  
46      public boolean storedInGroupDirectory()
47      {
48          return true;
49      }
50  
51      public boolean storedInArtifactVersionDirectory()
52      {
53          return false;
54      }
55  
56      public String getGroupId()
57      {
58          return groupId;
59      }
60  
61      public String getArtifactId()
62      {
63          return null;
64      }
65  
66      public String getBaseVersion()
67      {
68          return null;
69      }
70  
71      public void addPluginMapping( String goalPrefix,
72                                    String artifactId )
73      {
74          addPluginMapping( goalPrefix, artifactId, artifactId );
75      }
76  
77      public void addPluginMapping( String goalPrefix,
78                                    String artifactId,
79                                    String name )
80      {
81          List<Plugin> plugins = getMetadata().getPlugins();
82          boolean found = false;
83          for ( Iterator<Plugin> i = plugins.iterator(); i.hasNext() && !found; )
84          {
85              Plugin plugin = i.next();
86              if ( plugin.getPrefix().equals( goalPrefix ) )
87              {
88                  found = true;
89              }
90          }
91          if ( !found )
92          {
93              Plugin plugin = new Plugin();
94              plugin.setPrefix( goalPrefix );
95              plugin.setArtifactId( artifactId );
96              plugin.setName( name );
97  
98  
99              getMetadata().addPlugin( plugin );
100         }
101     }
102 
103     public Object getKey()
104     {
105         return groupId;
106     }
107 
108     public boolean isSnapshot()
109     {
110         return false;
111     }
112 
113     public ArtifactRepository getRepository()
114     {
115         return null;
116     }
117 
118     public void setRepository( ArtifactRepository remoteRepository )
119     {
120         // intentionally blank
121     }
122 }