001package org.apache.maven.plugin.plugin.metadata;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Iterator;
023import java.util.List;
024
025import org.apache.maven.artifact.repository.ArtifactRepository;
026import org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata;
027import org.apache.maven.artifact.repository.metadata.Metadata;
028import org.apache.maven.artifact.repository.metadata.Plugin;
029
030/**
031 * Metadata for the group directory of the repository.
032 *
033 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
034 */
035public class GroupRepositoryMetadata
036    extends AbstractRepositoryMetadata
037{
038    private final String groupId;
039
040    public GroupRepositoryMetadata( String groupId )
041    {
042        super( new Metadata() );
043        this.groupId = groupId;
044    }
045
046    public boolean storedInGroupDirectory()
047    {
048        return true;
049    }
050
051    public boolean storedInArtifactVersionDirectory()
052    {
053        return false;
054    }
055
056    public String getGroupId()
057    {
058        return groupId;
059    }
060
061    public String getArtifactId()
062    {
063        return null;
064    }
065
066    public String getBaseVersion()
067    {
068        return null;
069    }
070
071    public void addPluginMapping( String goalPrefix,
072                                  String artifactId )
073    {
074        addPluginMapping( goalPrefix, artifactId, artifactId );
075    }
076
077    public void addPluginMapping( String goalPrefix,
078                                  String artifactId,
079                                  String name )
080    {
081        List<Plugin> plugins = getMetadata().getPlugins();
082        boolean found = false;
083        for ( Iterator<Plugin> i = plugins.iterator(); i.hasNext() && !found; )
084        {
085            Plugin plugin = i.next();
086            if ( plugin.getPrefix().equals( goalPrefix ) )
087            {
088                found = true;
089            }
090        }
091        if ( !found )
092        {
093            Plugin plugin = new Plugin();
094            plugin.setPrefix( goalPrefix );
095            plugin.setArtifactId( artifactId );
096            plugin.setName( name );
097
098
099            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}