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