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   * Class copied from maven-compat for to remove dependency but keep compatibility with Maven 3 (and Nexus Staging
29   * Plugin, see <a href="https://issues.apache.org/jira/browse/MPLUGIN-384">MPLUGIN-384</a>)
30   *
31   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
32   */
33  public class GroupRepositoryMetadata extends AbstractRepositoryMetadata {
34      private final String groupId;
35  
36      public GroupRepositoryMetadata(String groupId) {
37          super(new Metadata());
38          this.groupId = groupId;
39      }
40  
41      public boolean storedInGroupDirectory() {
42          return true;
43      }
44  
45      public boolean storedInArtifactVersionDirectory() {
46          return false;
47      }
48  
49      public String getGroupId() {
50          return groupId;
51      }
52  
53      public String getArtifactId() {
54          return null;
55      }
56  
57      public String getBaseVersion() {
58          return null;
59      }
60  
61      public void addPluginMapping(String goalPrefix, String artifactId) {
62          addPluginMapping(goalPrefix, artifactId, artifactId);
63      }
64  
65      public void addPluginMapping(String goalPrefix, String artifactId, String name) {
66          List<Plugin> plugins = getMetadata().getPlugins();
67          boolean found = false;
68          for (Iterator<Plugin> i = plugins.iterator(); i.hasNext() && !found; ) {
69              Plugin plugin = i.next();
70              if (plugin.getPrefix().equals(goalPrefix)) {
71                  found = true;
72              }
73          }
74          if (!found) {
75              Plugin plugin = new Plugin();
76              plugin.setPrefix(goalPrefix);
77              plugin.setArtifactId(artifactId);
78              plugin.setName(name);
79  
80              getMetadata().addPlugin(plugin);
81          }
82      }
83  
84      public Object getKey() {
85          return groupId;
86      }
87  
88      public boolean isSnapshot() {
89          return false;
90      }
91  
92      public ArtifactRepository getRepository() {
93          return null;
94      }
95  
96      public void setRepository(ArtifactRepository remoteRepository) {
97          // intentionally blank
98      }
99  }