remove old module, replaced by maven-repository-metadata

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@265000 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-08-31 10:15:22 +00:00
parent 6731a0485b
commit fe69e3204b
8 changed files with 0 additions and 540 deletions

View File

@ -1,58 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>maven</artifactId>
<groupId>org.apache.maven</groupId>
<version>2.0-beta-1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-mapping</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
<name>Maven Plugin Mapping</name>
<description>Maven Plugin Mapping</description>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
<configuration>
<version>1.0.0</version>
<model>src/main/mdo/plugins.mdo</model>
</configuration>
<executions>
<execution>
<goals>
<goal>xpp3-writer</goal>
<goal>java</goal>
<goal>xpp3-reader</goal>
<goal>xsd</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,205 +0,0 @@
package org.apache.maven.plugin.mapping;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.InvalidRepositoryMetadataException;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.plugin.mapping.io.xpp3.PluginMappingXpp3Reader;
import org.apache.maven.plugin.mapping.metadata.PluginMappingMetadata;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class DefaultPluginMappingBuilder
extends AbstractLogEnabled
implements MavenPluginMappingBuilder
{
// component requirement
private RepositoryMetadataManager repositoryMetadataManager;
public PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException
{
return loadPluginMappings( groupIds, pluginRepositories, localRepository, new PluginMappingManager() );
}
public PluginMappingManager refreshPluginMappingManager( PluginMappingManager mappingManager,
List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException
{
// prevent performance drag from abuse of this method.
if ( mappingManager.isRefreshed() )
{
throw new PluginMappingManagementException(
"Plugin-mappings have already been refreshed. Cannot re-refresh." );
}
getLogger().info( "Refreshing plugin-mapping metadata..." );
List groupIds = new ArrayList();
for ( Iterator it = mappingManager.getPluginMaps().iterator(); it.hasNext(); )
{
PluginMap map = (PluginMap) it.next();
String groupId = map.getGroupId();
groupIds.add( groupId );
repositoryMetadataManager.purgeLocalCopy( new PluginMappingMetadata( groupId ), localRepository );
}
mappingManager.markRefreshed();
return loadPluginMappings( groupIds, pluginRepositories, localRepository, mappingManager );
}
private PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories,
ArtifactRepository localRepository,
PluginMappingManager mappingManager )
throws PluginMappingManagementException
{
List pluginGroupIds = new ArrayList( groupIds );
// TODO: use constant
if ( !pluginGroupIds.contains( "org.apache.maven.plugins" ) )
{
pluginGroupIds.add( "org.apache.maven.plugins" );
}
for ( Iterator it = pluginGroupIds.iterator(); it.hasNext(); )
{
String groupId = (String) it.next();
try
{
File mappingFile = resolveMappingMetadata( groupId, pluginRepositories, localRepository );
PluginMap pluginMap = readPluginMap( mappingFile );
if ( pluginMap != null )
{
mappingManager.addPluginMap( pluginMap );
}
}
catch ( RepositoryMetadataManagementException e )
{
getLogger()
.warn( "Cannot resolve plugin-mapping metadata for groupId: " + groupId + " - IGNORING." );
getLogger().debug( "Error resolving plugin-mapping metadata for groupId: " + groupId + ".", e );
}
}
return mappingManager;
}
private PluginMap readPluginMap( File mappingFile )
throws PluginMappingManagementException
{
PluginMap result = null;
if ( mappingFile.exists() )
{
Reader fileReader = null;
try
{
fileReader = new FileReader( mappingFile );
PluginMappingXpp3Reader mappingReader = new PluginMappingXpp3Reader();
result = mappingReader.read( fileReader );
}
catch ( FileNotFoundException e )
{
throw new PluginMappingManagementException( "Cannot read plugin mappings from: " + mappingFile, e );
}
catch ( IOException e )
{
throw new PluginMappingManagementException( "Cannot read plugin mappings from: " + mappingFile, e );
}
catch ( XmlPullParserException e )
{
throw new PluginMappingManagementException( "Cannot parse plugin mappings from: " + mappingFile, e );
}
finally
{
IOUtil.close( fileReader );
}
}
return result;
}
private File resolveMappingMetadata( String groupId, List pluginRepositories, ArtifactRepository localRepository )
throws RepositoryMetadataManagementException
{
PluginMappingMetadata metadata = new PluginMappingMetadata( groupId );
RepositoryMetadataManagementException repositoryException = null;
for ( Iterator repoIterator = pluginRepositories.iterator(); repoIterator.hasNext(); )
{
ArtifactRepository repository = (ArtifactRepository) repoIterator.next();
try
{
repositoryMetadataManager.resolve( metadata, repository, localRepository );
// reset this to keep it from getting in the way when we succeed but not on first repo...
repositoryException = null;
File metadataFile = metadata.getFile();
if ( metadataFile != null && metadataFile.exists() )
{
break;
}
}
catch ( InvalidRepositoryMetadataException e )
{
repositoryMetadataManager.purgeLocalCopy( metadata, localRepository );
}
catch ( RepositoryMetadataManagementException e )
{
repositoryException = e;
}
}
if ( repositoryException != null )
{
throw repositoryException;
}
return metadata.getFile();
}
}

View File

@ -1,35 +0,0 @@
package org.apache.maven.plugin.mapping;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import java.util.List;
public interface MavenPluginMappingBuilder
{
PluginMappingManager loadPluginMappings( List pluginGroupIds, List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException;
PluginMappingManager refreshPluginMappingManager( PluginMappingManager mappingManager, List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException;
}

View File

@ -1,17 +0,0 @@
package org.apache.maven.plugin.mapping;
public class PluginMappingManagementException
extends Exception
{
public PluginMappingManagementException( String message, Throwable cause )
{
super( message, cause );
}
public PluginMappingManagementException( String message )
{
super( message );
}
}

View File

@ -1,109 +0,0 @@
package org.apache.maven.plugin.mapping;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.model.Plugin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class PluginMappingManager
{
private List mappings = new ArrayList();
private boolean refreshed;
private Map pluginDefinitionsByPrefix = new HashMap();
public void addPluginMap( PluginMap pluginMap )
{
mappings.add( pluginMap );
clearCache();
}
public void markRefreshed()
{
this.refreshed = true;
}
public boolean isRefreshed()
{
return refreshed;
}
public List getPluginMaps()
{
return mappings;
}
public void clear()
{
this.mappings = null;
clearCache();
}
private void clearCache()
{
this.pluginDefinitionsByPrefix = null;
}
public Plugin getByPrefix( String pluginPrefix )
{
synchronized ( this ) {
if ( pluginDefinitionsByPrefix == null )
{
calculatePluginDefinitionsByPrefix();
}
}
return (Plugin) pluginDefinitionsByPrefix.get( pluginPrefix );
}
private void calculatePluginDefinitionsByPrefix()
{
pluginDefinitionsByPrefix = new HashMap();
for ( Iterator it = mappings.iterator(); it.hasNext(); )
{
PluginMap pluginMap = (PluginMap) it.next();
String groupId = pluginMap.getGroupId();
for ( Iterator pluginIterator = pluginMap.getPlugins().iterator(); pluginIterator.hasNext(); )
{
MappedPlugin mapping = (MappedPlugin) pluginIterator.next();
String prefix = mapping.getPrefix();
String artifactId = mapping.getArtifactId();
Plugin plugin = new Plugin();
plugin.setGroupId( groupId );
plugin.setArtifactId( artifactId );
pluginDefinitionsByPrefix.put( prefix, plugin );
}
}
}
}

View File

@ -1,41 +0,0 @@
package org.apache.maven.plugin.mapping.metadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import java.io.File;
public class PluginMappingMetadata
implements RepositoryMetadata
{
private static final String PLUGIN_MAPPING_FILE = "plugins.xml";
private final String groupId;
private File metadataFile;
public PluginMappingMetadata( String groupId )
{
this.groupId = groupId;
}
public String getRepositoryPath()
{
return groupId + "/" + PLUGIN_MAPPING_FILE;
}
public void setFile( File metadataFile )
{
this.metadataFile = metadataFile;
}
public File getFile()
{
return metadataFile;
}
public String toString()
{
return PLUGIN_MAPPING_FILE + " (plugin mappings) for group: \'" + groupId + "\'";
}
}

View File

@ -1,59 +0,0 @@
<model>
<id>plugin-map</id>
<name>PluginMapping</name>
<description>Mappings for searching for a plugin within a particular groupId.</description>
<defaults>
<default>
<key>package</key>
<value>org.apache.maven.plugin.mapping</value>
</default>
</defaults>
<classes>
<class rootElement="true" xml.tagName="mapping">
<name>PluginMap</name>
<version>1.0.0</version>
<description>Root model class, containing various mappings for plugins in this group.</description>
<fields>
<field>
<name>groupId</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>The groupId for plugins mapped in this file.</description>
</field>
<field>
<name>plugins</name>
<version>1.0.0</version>
<required>true</required>
<description>The set of plugin mappings</description>
<association>
<type>MappedPlugin</type>
<multiplicity>*</multiplicity>
</association>
</field>
</fields>
</class>
<class xml.tagName="plugin">
<name>MappedPlugin</name>
<version>1.0.0</version>
<description>Mapping information for a single plugin within this group</description>
<comment>NOTE: plugin version is _NOT_ included here, since it is resolved using a separate algorithm.</comment>
<fields>
<field>
<name>prefix</name>
<type>String</type>
<required>true</required>
<version>1.0.0</version>
<description>The plugin invocation prefix (i.e. eclipse for eclipse:eclipse)</description>
</field>
<field>
<name>artifactId</name>
<type>String</type>
<required>true</required>
<version>1.0.0</version>
<description>The plugin artifactId</description>
</field>
</fields>
</class>
</classes>
</model>

View File

@ -1,16 +0,0 @@
<component-set>
<components>
<component>
<role>org.apache.maven.plugin.mapping.MavenPluginMappingBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.plugin.mapping.DefaultPluginMappingBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
</requirements>
</component>
</components>
</component-set>