PR: MNG-613

reorganise in preparation for generalised repository metadata

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@264091 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-08-29 06:37:33 +00:00
parent 7a8c848b01
commit e0457b0204
32 changed files with 819 additions and 307 deletions

View File

@ -73,7 +73,7 @@ public class DefaultArtifactDeployer
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
metadata.storeInLocalRepository( localRepository );
// TODO: shouldn't need to calculate this
File f = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( metadata ) );
File f = new File( localRepository.getBasedir(), localRepository.pathOfArtifactMetadata( metadata ) );
wagonManager.putArtifactMetadata( f, metadata, deploymentRepository );
}
}

View File

@ -96,7 +96,7 @@ public class DefaultWagonManager
throws TransferFailedException
{
getLogger().info( "Uploading " + artifactMetadata );
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ), null );
putRemoteFile( repository, source, repository.pathOfArtifactMetadata( artifactMetadata ), null );
}
public void putRepositoryMetadata( File source, RepositoryMetadata metadata, ArtifactRepository repository )
@ -104,7 +104,7 @@ public class DefaultWagonManager
{
getLogger().info( "Uploading " + metadata );
putRemoteFile( repository, source, repository.formatAsFile( metadata.getRepositoryPath() ), null );
putRemoteFile( repository, source, repository.pathOfRepositoryMetadata( metadata ), null );
}
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath,
@ -257,7 +257,7 @@ public class DefaultWagonManager
String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException
{
String remotePath = repository.pathOfMetadata( metadata );
String remotePath = repository.pathOfArtifactMetadata( metadata );
getLogger().info( "Retrieving " + metadata );
getRemoteFile( repository, destination, remotePath, null, checksumPolicy );
@ -267,7 +267,7 @@ public class DefaultWagonManager
File destination )
throws TransferFailedException, ResourceDoesNotExistException
{
String remotePath = remoteRepository.formatAsFile( metadata.getRepositoryPath() );
String remotePath = remoteRepository.pathOfRepositoryMetadata( metadata );
getLogger().info( "Retrieving " + metadata );

View File

@ -48,7 +48,7 @@ public abstract class AbstractVersionArtifactMetadata
protected File getLocalRepositoryLocation( ArtifactRepository localRepository )
{
return new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
return new File( localRepository.getBasedir(), localRepository.pathOfArtifactMetadata( this ) );
}
private void readFromFile( File file )

View File

@ -19,6 +19,7 @@ package org.apache.maven.artifact.repository;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.wagon.repository.Repository;
/**
@ -76,19 +77,14 @@ public class DefaultArtifactRepository
return layout.pathOf( artifact );
}
public String pathOfMetadata( ArtifactMetadata artifactMetadata )
public String pathOfArtifactMetadata( ArtifactMetadata artifactMetadata )
{
return layout.pathOfMetadata( artifactMetadata );
return layout.pathOfArtifactMetadata( artifactMetadata );
}
public String formatAsDirectory( String directory )
public String pathOfRepositoryMetadata( RepositoryMetadata metadata )
{
return layout.formatAsDirectory( directory );
}
public String formatAsFile( String file )
{
return layout.formatAsFile( file );
return layout.pathOfRepositoryMetadata( metadata );
}
public ArtifactRepositoryLayout getLayout()

View File

@ -31,11 +31,14 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
/**
* @todo try to crop all, particularly plugin stuff
* @todo check caching?
*/
public class DefaultRepositoryMetadataManager
extends AbstractLogEnabled
implements RepositoryMetadataManager
{
// component requirement
private WagonManager wagonManager;
@ -105,8 +108,6 @@ public class DefaultRepositoryMetadataManager
cachedMetadata.put( metadata.getRepositoryPath(), metadataFile );
}
}
metadata.setFile( metadataFile );
}
private boolean verifyFileNotEmpty( File metadataFile )
@ -129,16 +130,12 @@ public class DefaultRepositoryMetadataManager
}
}
public void deploy( RepositoryMetadata metadata, ArtifactRepository remote )
public void deploy( File source, RepositoryMetadata metadata, ArtifactRepository remote )
throws RepositoryMetadataManagementException
{
File metadataFile = metadata.getFile();
try
{
wagonManager.putRepositoryMetadata( metadataFile, metadata, remote );
metadata.setFile( metadataFile );
wagonManager.putRepositoryMetadata( source, metadata, remote );
}
catch ( TransferFailedException e )
{
@ -147,7 +144,7 @@ public class DefaultRepositoryMetadataManager
}
public void install( RepositoryMetadata metadata, ArtifactRepository local )
public void install( File source, RepositoryMetadata metadata, ArtifactRepository local )
throws RepositoryMetadataManagementException
{
File metadataFile = constructLocalRepositoryFile( metadata, local );
@ -161,7 +158,7 @@ public class DefaultRepositoryMetadataManager
dir.mkdirs();
}
FileUtils.copyFile( metadata.getFile(), metadataFile );
FileUtils.copyFile( source, metadataFile );
}
catch ( IOException e )
{
@ -185,13 +182,9 @@ public class DefaultRepositoryMetadataManager
}
}
private File constructLocalRepositoryFile( RepositoryMetadata metadata, ArtifactRepository local )
private static File constructLocalRepositoryFile( RepositoryMetadata metadata, ArtifactRepository local )
{
String metadataPath = local.formatAsFile( metadata.getRepositoryPath() );
metadataPath = metadataPath.replace( File.separatorChar, '/' );
return new File( local.getBasedir(), metadataPath );
return new File( local.getBasedir(), local.pathOfRepositoryMetadata( metadata ) );
}
}

View File

@ -0,0 +1,48 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 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 java.io.File;
public class PluginMappingMetadata
implements RepositoryMetadata
{
private static final String PLUGIN_MAPPING_FILE = "plugins.xml";
private final String groupId;
/**
* @todo REMOVE!
*/
private File metadataFile;
public PluginMappingMetadata( String groupId )
{
this.groupId = groupId;
}
public String getRepositoryPath()
{
return groupId + "/" + PLUGIN_MAPPING_FILE;
}
public String toString()
{
return PLUGIN_MAPPING_FILE + " (plugin mappings) for group: \'" + groupId + "\'";
}
}

View File

@ -1,28 +0,0 @@
package org.apache.maven.artifact.repository.metadata;
public class RepositoryMetadataManagementException
extends Exception
{
private final RepositoryMetadata metadata;
public RepositoryMetadataManagementException( RepositoryMetadata metadata, String message, Throwable cause )
{
super( "Failed to resolve repository metadata: " + metadata + ".\n\nOriginal message: " + message + "\n\nError was: " + cause.getMessage(), cause );
this.metadata = metadata;
}
public RepositoryMetadataManagementException( RepositoryMetadata metadata, String message )
{
super( "Failed to resolve repository metadata: " + metadata + ".\n\nOriginal message: " + message );
this.metadata = metadata;
}
public RepositoryMetadata getMetadata()
{
return metadata;
}
}

View File

@ -1,23 +0,0 @@
package org.apache.maven.artifact.repository.metadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
public interface RepositoryMetadataManager
{
void resolveLocally( RepositoryMetadata repositoryMetadata, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void resolve( RepositoryMetadata repositoryMetadata, ArtifactRepository remote, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void deploy( RepositoryMetadata repositoryMetadata, ArtifactRepository remote )
throws RepositoryMetadataManagementException;
void install( RepositoryMetadata repositoryMetadata, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void purgeLocalCopy( RepositoryMetadata repositoryMetadata, ArtifactRepository local )
throws RepositoryMetadataManagementException;
}

View File

@ -36,7 +36,7 @@
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<role-hint>latest</role-hint>
@ -47,12 +47,12 @@
</requirement>
</requirements>
</component>
<!--
|
| ArtifactTransformationManager
|
-->
|
| ArtifactTransformationManager
|
-->
<component>
<role>org.apache.maven.artifact.transform.ArtifactTransformationManager</role>
<implementation>org.apache.maven.artifact.transform.DefaultArtifactTransformationManager</implementation>
@ -131,4 +131,15 @@
<implementation>org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory</implementation>
</component>
</components>
<component>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
</requirements>
</component>
</component-set>

View File

@ -17,8 +17,9 @@ package org.apache.maven.artifact.repository;
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* Specifies the repository used for artifact handling.
@ -28,14 +29,11 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata;
*/
public interface ArtifactRepository
{
String pathOf( Artifact artifact );
String pathOfMetadata( ArtifactMetadata artifactMetadata );
String formatAsDirectory( String directory );
String pathOfArtifactMetadata( ArtifactMetadata artifactMetadata );
String formatAsFile( String file );
String pathOfRepositoryMetadata( RepositoryMetadata metadata );
String getUrl();

View File

@ -18,6 +18,7 @@ package org.apache.maven.artifact.repository.layout;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* @author jdcasey
@ -29,9 +30,7 @@ public interface ArtifactRepositoryLayout
String pathOf( Artifact artifact );
String pathOfMetadata( ArtifactMetadata metadata );
String pathOfArtifactMetadata( ArtifactMetadata metadata );
String formatAsDirectory( String directory );
String formatAsFile( String file );
String pathOfRepositoryMetadata( RepositoryMetadata metadata );
}

View File

@ -19,6 +19,7 @@ package org.apache.maven.artifact.repository.layout;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* @author jdcasey
@ -26,6 +27,11 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata;
public class DefaultRepositoryLayout
implements ArtifactRepositoryLayout
{
private static final char PATH_SEPARATOR = '/';
private static final char GROUP_SEPARATOR = '.';
private static final char ARTIFACT_SEPARATOR = '-';
public String pathOf( Artifact artifact )
{
@ -33,33 +39,33 @@ public class DefaultRepositoryLayout
StringBuffer path = new StringBuffer();
path.append( formatAsDirectory( artifact.getGroupId() ) ).append( '/' );
path.append( artifact.getArtifactId() ).append( '/' );
path.append( artifact.getBaseVersion() ).append( '/' );
path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR );
path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR );
path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() );
if ( artifact.hasClassifier() )
{
path.append( '-' ).append( artifact.getClassifier() );
path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() );
}
if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
{
path.append( '.' ).append( artifactHandler.getExtension() );
path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() );
}
return path.toString();
}
public String pathOfMetadata( ArtifactMetadata metadata )
public String pathOfArtifactMetadata( ArtifactMetadata metadata )
{
StringBuffer path = new StringBuffer();
path.append( formatAsDirectory( metadata.getGroupId() ) ).append( '/' );
path.append( metadata.getArtifactId() ).append( '/' );
path.append( formatAsDirectory( metadata.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( metadata.getArtifactId() ).append( PATH_SEPARATOR );
if ( metadata.storedInArtifactDirectory() )
{
path.append( metadata.getBaseVersion() ).append( '/' );
path.append( metadata.getBaseVersion() ).append( PATH_SEPARATOR );
}
path.append( metadata.getFilename() );
@ -67,26 +73,31 @@ public class DefaultRepositoryLayout
return path.toString();
}
public String formatAsDirectory( String directory )
public String pathOfRepositoryMetadata( RepositoryMetadata metadata )
{
return directory.replace( '.', '/' );
}
public String formatAsFile( String file )
{
int lastSlash = file.lastIndexOf('/');
if( lastSlash > -1 )
String file = metadata.getRepositoryPath();
String result;
int lastSlash = file.lastIndexOf( PATH_SEPARATOR );
if ( lastSlash > -1 )
{
String filePart = file.substring( lastSlash );
String dirPart = file.substring( 0, lastSlash );
return dirPart.replace('.', '/') + filePart;
result = formatAsDirectory( dirPart ) + filePart;
}
else
{
return file;
result = file;
}
return result;
}
private String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
}
}

View File

@ -19,6 +19,7 @@ package org.apache.maven.artifact.repository.layout;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* @author jdcasey
@ -49,7 +50,7 @@ public class LegacyRepositoryLayout
return path.toString();
}
public String pathOfMetadata( ArtifactMetadata metadata )
public String pathOfArtifactMetadata( ArtifactMetadata metadata )
{
StringBuffer path = new StringBuffer();
@ -58,14 +59,10 @@ public class LegacyRepositoryLayout
return path.toString();
}
public String formatAsDirectory( String directory )
public String pathOfRepositoryMetadata( RepositoryMetadata metadata )
{
return directory;
}
public String formatAsFile( String file )
{
return file;
return metadata.getRepositoryPath();
}
}

View File

@ -16,15 +16,8 @@ package org.apache.maven.artifact.repository.metadata;
* limitations under the License.
*/
import java.io.File;
public interface RepositoryMetadata
{
String getRepositoryPath();
File getFile();
void setFile( File file );
}

View File

@ -0,0 +1,54 @@
package org.apache.maven.artifact.repository.metadata;/*
* 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.
*/
public class RepositoryMetadataManagementException
extends Exception
{
private final RepositoryMetadata metadata;
public RepositoryMetadataManagementException( RepositoryMetadata metadata, String message, Throwable cause )
{
super( "Failed to resolve repository metadata: " + metadata + ".\n\nOriginal message: " + message +
"\n\nError was: " + cause.getMessage(), cause );
this.metadata = metadata;
}
public RepositoryMetadataManagementException( RepositoryMetadata metadata, String message )
{
super( "Failed to resolve repository metadata: " + metadata + ".\n\nOriginal message: " + message );
this.metadata = metadata;
}
public RepositoryMetadataManagementException( String message )
{
super( message );
this.metadata = null;
}
public RepositoryMetadataManagementException( String message, Throwable cause )
{
super( message, cause );
this.metadata = null;
}
public RepositoryMetadata getMetadata()
{
return metadata;
}
}

View File

@ -0,0 +1,39 @@
package org.apache.maven.artifact.repository.metadata;
/*
* 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 java.io.File;
public interface RepositoryMetadataManager
{
void resolveLocally( RepositoryMetadata repositoryMetadata, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void resolve( RepositoryMetadata repositoryMetadata, ArtifactRepository remote, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void deploy( File source, RepositoryMetadata repositoryMetadata, ArtifactRepository remote )
throws RepositoryMetadataManagementException;
void install( File source, RepositoryMetadata repositoryMetadata, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void purgeLocalCopy( RepositoryMetadata repositoryMetadata, ArtifactRepository local )
throws RepositoryMetadataManagementException;
}

View File

@ -1,5 +1,5 @@
<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">
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>
@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-mapping</artifactId>
<artifactId>maven-repository-metadata</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
<dependency>
@ -114,7 +114,7 @@
<version>1.0-alpha-4</version>
<scope>runtime</scope>
</dependency>
<!-- used to prompt the user to add plugin versions to the plugin-registry. -->
<dependency>
<groupId>plexus</groupId>

View File

@ -18,7 +18,6 @@ package org.apache.maven.execution;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.plugin.mapping.PluginMappingManager;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@ -40,8 +39,6 @@ public class MavenSession
private EventDispatcher eventDispatcher;
private PluginMappingManager pluginMappingManager;
// TODO: make this the central one, get rid of build settings...
private final Settings settings;
@ -120,16 +117,6 @@ public class MavenSession
return settings;
}
public void setPluginMappingManager( PluginMappingManager pluginMappingManager )
{
this.pluginMappingManager = pluginMappingManager;
}
public PluginMappingManager getPluginMappingManager()
{
return pluginMappingManager;
}
public List getSortedProjects()
{
return rpm.getProjectsSortedByDependency();

View File

@ -97,7 +97,7 @@ public class DefaultLifecycleExecutor
* execution of a mojo.
*
* @param session
* @param project
* @param rm
* @param dispatcher
*/
public MavenExecutionResponse execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )

View File

@ -46,9 +46,6 @@ import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.mapping.MavenPluginMappingBuilder;
import org.apache.maven.plugin.mapping.PluginMappingManagementException;
import org.apache.maven.plugin.mapping.PluginMappingManager;
import org.apache.maven.plugin.version.PluginVersionManager;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject;
@ -117,11 +114,12 @@ public class DefaultPluginManager
protected ArtifactMetadataSource artifactMetadataSource;
protected MavenPluginMappingBuilder pluginMappingBuilder;
protected RuntimeInformation runtimeInformation;
protected MavenProjectBuilder mavenProjectBuilder;
protected PluginMappingManager pluginMappingManager;
// END component requirements
public DefaultPluginManager()
@ -142,34 +140,18 @@ public class DefaultPluginManager
public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
throws PluginManagerException
{
PluginMappingManager mappingManager = getPluginMappingManager( session, project );
Plugin plugin = mappingManager.getByPrefix( prefix );
if ( plugin == null && !mappingManager.isRefreshed() )
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
// use for the mapping manager in here
try
{
getLogger().info(
"Refreshing plugin mapping metadata; looking for plugin with prefix: \'" + prefix + "\'." );
try
{
mappingManager = pluginMappingBuilder.refreshPluginMappingManager( session.getPluginMappingManager(),
project.getPluginArtifactRepositories(),
session.getLocalRepository() );
}
catch ( RepositoryMetadataManagementException e )
{
throw new PluginManagerException( "Error refreshing plugin mappings.", e );
}
catch ( PluginMappingManagementException e )
{
throw new PluginManagerException( "Error refreshing plugin mappings.", e );
}
plugin = mappingManager.getByPrefix( prefix );
return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(),
project.getPluginArtifactRepositories(),
session.getLocalRepository() );
}
catch ( RepositoryMetadataManagementException e )
{
throw new PluginManagerException( "Error getting plugin prefix", e );
}
return plugin;
}
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
@ -1138,7 +1120,7 @@ public class DefaultPluginManager
artifacts.add( "maven-monitor" );
artifacts.add( "maven-plugin-api" );
artifacts.add( "maven-plugin-descriptor" );
artifacts.add( "maven-plugin-mapping" );
artifacts.add( "maven-repository-metadata" );
artifacts.add( "maven-plugin-registry" );
artifacts.add( "maven-profile" );
artifacts.add( "maven-project" );
@ -1225,36 +1207,4 @@ public class DefaultPluginManager
return pluginContainer.lookupMap( role );
}
private PluginMappingManager getPluginMappingManager( MavenSession session, MavenProject project )
throws PluginManagerException
{
PluginMappingManager mappingManager = session.getPluginMappingManager();
// don't reassemble the plugin mappings if the session has already been configured with them.
if ( mappingManager == null )
{
try
{
List pluginGroupIds = session.getSettings().getPluginGroups();
List pluginRepositories = project.getPluginArtifactRepositories();
ArtifactRepository localRepository = session.getLocalRepository();
mappingManager = pluginMappingBuilder.loadPluginMappings( pluginGroupIds, pluginRepositories,
localRepository );
// lazily configure this on the session.
session.setPluginMappingManager( mappingManager );
}
catch ( RepositoryMetadataManagementException e )
{
throw new PluginManagerException( "Cannot load plugin mappings.", e );
}
catch ( PluginMappingManagementException e )
{
throw new PluginManagerException( "Cannot load plugin mappings.", e );
}
}
return mappingManager;
}
}

View File

@ -0,0 +1,267 @@
package org.apache.maven.plugin;
/*
* 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.Metadata;
import org.apache.maven.artifact.repository.metadata.Plugin;
import org.apache.maven.artifact.repository.metadata.PluginMappingMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
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.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Manage plugin prefix to artifact ID mapping associations.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class DefaultPluginMappingManager
extends AbstractLogEnabled
implements PluginMappingManager
{
protected RepositoryMetadataManager repositoryMetadataManager;
private List mappings = new ArrayList();
private boolean refreshed;
private Map pluginDefinitionsByPrefix;
public void clear()
{
this.mappings = null;
clearCache();
}
private void clearCache()
{
this.pluginDefinitionsByPrefix = null;
}
public org.apache.maven.model.Plugin getByPrefix( String pluginPrefix, List groupIds, List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException
{
if ( pluginDefinitionsByPrefix == null )
{
// firstly, search the local repository
loadPluginMappings( groupIds, pluginRepositories, localRepository );
calculatePluginDefinitionsByPrefix();
// if not found, try from the remote repository
if ( !pluginDefinitionsByPrefix.containsKey( pluginPrefix ) && !refreshed )
{
getLogger().info(
"Refreshing plugin mapping metadata; looking for plugin with prefix: \'" + pluginPrefix + "\'." );
refreshPluginMappingManager( pluginRepositories, localRepository );
refreshed = true;
}
calculatePluginDefinitionsByPrefix();
}
return (org.apache.maven.model.Plugin) pluginDefinitionsByPrefix.get( pluginPrefix );
}
private void calculatePluginDefinitionsByPrefix()
{
pluginDefinitionsByPrefix = new HashMap();
for ( Iterator it = mappings.iterator(); it.hasNext(); )
{
Metadata pluginMap = (Metadata) it.next();
String groupId = pluginMap.getGroupId();
for ( Iterator pluginIterator = pluginMap.getPlugins().iterator(); pluginIterator.hasNext(); )
{
Plugin mapping = (Plugin) pluginIterator.next();
String prefix = mapping.getPrefix();
String artifactId = mapping.getArtifactId();
org.apache.maven.model.Plugin plugin = new org.apache.maven.model.Plugin();
plugin.setGroupId( groupId );
plugin.setArtifactId( artifactId );
pluginDefinitionsByPrefix.put( prefix, plugin );
}
}
}
private void refreshPluginMappingManager( List pluginRepositories, ArtifactRepository localRepository )
throws RepositoryMetadataManagementException
{
List groupIds = new ArrayList();
for ( Iterator it = mappings.iterator(); it.hasNext(); )
{
Metadata map = (Metadata) it.next();
String groupId = map.getGroupId();
groupIds.add( groupId );
repositoryMetadataManager.purgeLocalCopy( new PluginMappingMetadata( groupId ), localRepository );
}
loadPluginMappings( groupIds, pluginRepositories, localRepository );
}
private void loadPluginMappings( List groupIds, List pluginRepositories, ArtifactRepository localRepository )
{
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( repositoryMetadataManager, groupId, pluginRepositories,
localRepository );
Metadata pluginMap = readPluginMap( mappingFile );
if ( pluginMap != null )
{
mappings.add( 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 );
}
clearCache();
}
}
private static Metadata readPluginMap( File mappingFile )
throws RepositoryMetadataManagementException
{
Metadata result = null;
if ( mappingFile.exists() )
{
Reader fileReader = null;
try
{
fileReader = new FileReader( mappingFile );
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
result = mappingReader.read( fileReader );
}
catch ( FileNotFoundException e )
{
throw new RepositoryMetadataManagementException( "Cannot read plugin mappings from: " + mappingFile,
e );
}
catch ( IOException e )
{
throw new RepositoryMetadataManagementException( "Cannot read plugin mappings from: " + mappingFile,
e );
}
catch ( XmlPullParserException e )
{
throw new RepositoryMetadataManagementException( "Cannot parse plugin mappings from: " + mappingFile,
e );
}
finally
{
IOUtil.close( fileReader );
}
}
return result;
}
private static File resolveMappingMetadata( RepositoryMetadataManager repositoryMetadataManager, 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 = new File( localRepository.getBasedir(),
localRepository.pathOfRepositoryMetadata( metadata ) );
if ( metadataFile.exists() )
{
return metadataFile;
}
}
catch ( InvalidRepositoryMetadataException e )
{
repositoryMetadataManager.purgeLocalCopy( metadata, localRepository );
}
catch ( RepositoryMetadataManagementException e )
{
repositoryException = e;
}
}
if ( repositoryException != null )
{
throw repositoryException;
}
throw new RepositoryMetadataManagementException( "No repository metadata found" );
}
}

View File

@ -0,0 +1,36 @@
package org.apache.maven.plugin;
/*
* 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 org.apache.maven.model.Plugin;
import java.util.List;
/**
* Manage plugin prefix to artifact ID mapping associations.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public interface PluginMappingManager
{
Plugin getByPrefix( String pluginPrefix, List groupIds, List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException;
}

View File

@ -23,7 +23,7 @@
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
</requirement>
<requirement>
<role>org.apache.maven.plugin.mapping.MavenPluginMappingBuilder</role>
<role>org.apache.maven.plugin.PluginMappingManager</role>
</requirement>
<requirement>
<role>org.apache.maven.execution.RuntimeInformation</role>
@ -47,6 +47,16 @@
</requirements>
</component>
<component>
<role>org.apache.maven.plugin.PluginMappingManager</role>
<implementation>org.apache.maven.plugin.DefaultPluginMappingManager</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
</requirements>
</component>
<!-- Duplicated from Maven core as it is used in the plugin manager -->
<component>
<role>org.apache.maven.project.path.PathTranslator</role>

View File

@ -39,29 +39,30 @@ public class MBoot
{
String[] builds = new String[]{"maven-model", "maven-settings", "maven-monitor", "maven-plugin-api",
"maven-artifact", "maven-plugin-descriptor", "maven-artifact-manager", "maven-artifact-test",
"maven-plugin-mapping",
"maven-script/maven-script-beanshell", "maven-script/maven-script-marmalade", "maven-profile", "maven-project",
"maven-plugin-registry", "maven-reporting/maven-reporting-api", "maven-reporting/maven-reporting-impl", "maven-core", "maven-archiver",
"maven-repository-metadata", "maven-script/maven-script-beanshell", "maven-script/maven-script-marmalade",
"maven-profile", "maven-project", "maven-plugin-registry", "maven-reporting/maven-reporting-api",
"maven-reporting/maven-reporting-impl", "maven-core", "maven-archiver",
"maven-plugin-tools/maven-plugin-tools-api", "maven-plugin-tools/maven-plugin-tools-java",
"maven-plugin-tools/maven-plugin-tools-beanshell", "maven-plugin-tools/maven-plugin-tools-pluggy",
"maven-plugin-tools/maven-plugin-tools-marmalade", "maven-core-it-verifier"};
String[] pluginBuilds = new String[]{"maven-plugins/maven-clean-plugin", "maven-plugins/maven-compiler-plugin",
"maven-plugins/maven-install-plugin", "maven-plugins/maven-jar-plugin", "maven-plugins/maven-plugin-plugin",
"maven-plugins/maven-install-plugin", "maven-plugins/maven-jar-plugin", "maven-plugins/maven-plugin-plugin",
"maven-plugins/maven-resources-plugin", "maven-plugins/maven-surefire-plugin"};
private static final Map MODELLO_TARGET_VERSIONS;
private static final Map MODELLO_MODEL_FILES;
static {
static
{
Map targetVersions = new TreeMap();
targetVersions.put( "maven-model", "4.0.0" );
targetVersions.put( "maven-settings", "1.0.0" );
targetVersions.put( "maven-profile", "1.0.0" );
targetVersions.put( "maven-plugin-registry", "1.0.0" );
targetVersions.put( "maven-plugin-descriptor", "1.0.0" );
targetVersions.put( "maven-plugin-mapping", "1.0.0" );
targetVersions.put( "maven-repository-metadata", "1.0.0" );
MODELLO_TARGET_VERSIONS = Collections.unmodifiableMap( targetVersions );
@ -71,7 +72,7 @@ public class MBoot
modelFiles.put( "maven-profile", "profiles.mdo" );
modelFiles.put( "maven-plugin-registry", "plugin-registry.mdo" );
modelFiles.put( "maven-plugin-descriptor", "src/main/mdo/lifecycle.mdo" );
modelFiles.put( "maven-plugin-mapping", "src/main/mdo/plugins.mdo" );
modelFiles.put( "maven-repository-metadata", "src/main/mdo/metadata.mdo" );
MODELLO_MODEL_FILES = Collections.unmodifiableMap( modelFiles );
}
@ -186,9 +187,8 @@ public class MBoot
System.out.println();
System.out.println(
"HOWEVER, since you did not specify a repository path, maven will use: " + repoDir.getAbsolutePath() +
" to store artifacts locally." );
System.out.println( "HOWEVER, since you did not specify a repository path, maven will use: " +
repoDir.getAbsolutePath() + " to store artifacts locally." );
}
File repoLocalFile = new File( mavenRepoLocal );
@ -271,7 +271,8 @@ public class MBoot
Mirror m = (Mirror) j.next();
if ( m.getMirrorOf().equals( repo.getId() ) )
{
newRemoteRepos.add( new Repository( m.getId(), m.getUrl(), repo.getLayout(), repo.isSnapshots(), repo.isReleases() ) );
newRemoteRepos.add( new Repository( m.getId(), m.getUrl(), repo.getLayout(), repo.isSnapshots(),
repo.isReleases() ) );
foundMirror = true;
}
}
@ -760,7 +761,7 @@ public class MBoot
p.store( os, "Generated by Maven" );
os.close(); // stream is flushed but not closed by Properties.store()
FileUtils.copyFile( pomFile, new File( pomPropertiesDir, "pom.xml" ) );
jarMojo.execute( new File( classes ), buildDir, artifactId + "-" + version );

View File

@ -1,5 +1,5 @@
<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">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>maven-plugin-parent</artifactId>
<groupId>org.apache.maven.plugins</groupId>
@ -57,7 +57,7 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-mapping</artifactId>
<artifactId>maven-repository-metadata</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@ -17,19 +17,16 @@ package org.apache.maven.plugin.plugin.metadata;
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Plugin;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.mapping.MappedPlugin;
import org.apache.maven.plugin.mapping.PluginMap;
import org.apache.maven.plugin.mapping.io.xpp3.PluginMappingXpp3Reader;
import org.apache.maven.plugin.mapping.io.xpp3.PluginMappingXpp3Writer;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.discovery.ComponentDiscovererManager;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@ -41,7 +38,6 @@ import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
public abstract class AbstractPluginMappingMojo
extends AbstractMojo
@ -86,31 +82,33 @@ public abstract class AbstractPluginMappingMojo
* @readonly
*/
private RepositoryMetadataManager repositoryMetadataManager;
protected RepositoryMetadataManager getRepositoryMetadataManager()
{
return repositoryMetadataManager;
}
protected ArtifactRepository getLocalRepository()
{
return localRepository;
}
protected MavenProject getProject()
{
return project;
}
protected boolean updatePluginMap( RepositoryMetadata metadata ) throws MojoExecutionException
protected File updatePluginMap( RepositoryMetadata metadata )
throws MojoExecutionException
{
PluginMappingXpp3Reader mappingReader = new PluginMappingXpp3Reader();
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
PluginMap pluginMap = null;
Metadata pluginMap = null;
File metadataFile = metadata.getFile();
File metadataFile = new File( localRepository.getBasedir(),
localRepository.pathOfRepositoryMetadata( metadata ) );
if ( metadataFile != null && metadataFile.exists() )
if ( metadataFile.exists() )
{
Reader reader = null;
@ -130,77 +128,71 @@ public abstract class AbstractPluginMappingMojo
}
catch ( XmlPullParserException e )
{
throw new MojoExecutionException( "Cannot parse plugin-mapping metadata from file: " + metadataFile, e );
throw new MojoExecutionException( "Cannot parse plugin-mapping metadata from file: " + metadataFile,
e );
}
finally
{
IOUtil.close( reader );
}
}
if ( pluginMap == null )
{
pluginMap = new PluginMap();
pluginMap = new Metadata();
pluginMap.setGroupId( project.getGroupId() );
}
boolean shouldUpdate = true;
for ( Iterator it = pluginMap.getPlugins().iterator(); it.hasNext(); )
{
MappedPlugin preExisting = (MappedPlugin) it.next();
Plugin preExisting = (Plugin) it.next();
if ( preExisting.getArtifactId().equals( project.getArtifactId() ) )
{
getLog().info( "Plugin-mapping metadata for prefix: " + project.getArtifactId() + " already exists. Skipping." );
shouldUpdate = false;
break;
getLog().info(
"Plugin-mapping metadata for prefix: " + project.getArtifactId() + " already exists. Skipping." );
return null;
}
}
if ( shouldUpdate )
Plugin mappedPlugin = new Plugin();
mappedPlugin.setArtifactId( project.getArtifactId() );
mappedPlugin.setPrefix( getGoalPrefix() );
pluginMap.addPlugin( mappedPlugin );
Writer writer = null;
try
{
MappedPlugin mappedPlugin = new MappedPlugin();
File generatedMetadataFile = new File( metadataOutputDirectory, metadata.getRepositoryPath() );
mappedPlugin.setArtifactId( project.getArtifactId() );
File dir = generatedMetadataFile.getParentFile();
mappedPlugin.setPrefix( getGoalPrefix() );
pluginMap.addPlugin( mappedPlugin );
Writer writer = null;
try
if ( !dir.exists() )
{
File generatedMetadataFile = new File( metadataOutputDirectory, metadata.getRepositoryPath() );
File dir = generatedMetadataFile.getParentFile();
if ( !dir.exists() )
{
dir.mkdirs();
}
writer = new FileWriter( generatedMetadataFile );
PluginMappingXpp3Writer mappingWriter = new PluginMappingXpp3Writer();
mappingWriter.write( writer, pluginMap );
metadata.setFile( generatedMetadataFile );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Error writing repository metadata to build directory.", e );
}
finally
{
IOUtil.close( writer );
dir.mkdirs();
}
writer = new FileWriter( generatedMetadataFile );
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
mappingWriter.write( writer, pluginMap );
return generatedMetadataFile;
}
catch ( IOException e )
{
throw new MojoExecutionException( "Error writing repository metadata to build directory.", e );
}
finally
{
IOUtil.close( writer );
}
return shouldUpdate;
}
private String getGoalPrefix()

View File

@ -17,10 +17,12 @@ package org.apache.maven.plugin.plugin.metadata;
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.PluginMappingMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.mapping.metadata.PluginMappingMetadata;
import java.io.File;
/**
* @goal deployMapping
@ -47,9 +49,12 @@ public class PluginMappingDeployMojo
{
getRepositoryMetadataManager().resolve( metadata, distributionRepository, getLocalRepository() );
updatePluginMap( metadata );
File metadataFile = updatePluginMap( metadata );
getRepositoryMetadataManager().deploy( metadata, distributionRepository );
if ( metadataFile != null )
{
getRepositoryMetadataManager().deploy( metadataFile, metadata, distributionRepository );
}
}
catch ( RepositoryMetadataManagementException e )
{

View File

@ -1,10 +1,28 @@
package org.apache.maven.plugin.plugin.metadata;
/*
* 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.metadata.InvalidRepositoryMetadataException;
import org.apache.maven.artifact.repository.metadata.PluginMappingMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.mapping.metadata.PluginMappingMetadata;
import java.io.File;
/**
* @goal installMapping
@ -18,7 +36,7 @@ public class PluginMappingInstallMojo
throws MojoExecutionException
{
RepositoryMetadata metadata = new PluginMappingMetadata( getProject().getGroupId() );
try
{
try
@ -29,12 +47,12 @@ public class PluginMappingInstallMojo
{
getRepositoryMetadataManager().purgeLocalCopy( metadata, getLocalRepository() );
}
boolean shouldUpdate = updatePluginMap( metadata );
if ( shouldUpdate )
File metadataFile = updatePluginMap( metadata );
if ( metadataFile != null )
{
getRepositoryMetadataManager().install( metadata, getLocalRepository() );
getRepositoryMetadataManager().install( metadataFile, metadata, getLocalRepository() );
}
}
catch ( RepositoryMetadataManagementException e )

View File

@ -64,7 +64,7 @@ public class ProjectArtifactMetadata
public void storeInLocalRepository( ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
File destination = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
File destination = new File( localRepository.getBasedir(), localRepository.pathOfArtifactMetadata( this ) );
destination.getParentFile().mkdirs();

View File

@ -0,0 +1,43 @@
<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-repository-metadata</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
<name>Maven Repository Metadata Model</name>
<description>Maven Plugin Mapping</description>
<dependencies>
<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/metadata.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

@ -0,0 +1,56 @@
<model>
<id>repository-metadata</id>
<name>Metadata</name>
<description>Per-directory repository metadata.</description>
<defaults>
<default>
<key>package</key>
<value>org.apache.maven.artifact.repository.metadata</value>
</default>
</defaults>
<classes>
<class rootElement="true">
<name>Metadata</name>
<version>1.0.0</version>
<fields>
<field>
<name>groupId</name>
<version>1.0.0</version>
<type>String</type>
<description>The groupId that is directory represents, if any.</description>
</field>
<field>
<name>plugins</name>
<version>1.0.0</version>
<description>The set of plugin mappings for the group</description>
<association>
<type>Plugin</type>
<multiplicity>*</multiplicity>
</association>
</field>
</fields>
</class>
<class>
<name>Plugin</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

@ -0,0 +1,59 @@
<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>