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