mirror of https://github.com/apache/maven.git
o Fixed plugin version&prefix resolution
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@785565 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d344f6e37f
commit
114cbf2d4a
|
@ -617,91 +617,90 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
injectPluginDeclarationFromProject( plugin, project );
|
||||
|
||||
// If there is no version to be found then we need to look in the repository metadata for
|
||||
// this plugin and see what's specified as the latest release.
|
||||
//
|
||||
if ( plugin.getVersion() == null )
|
||||
{
|
||||
// If there is no version to be found then we need to look in the repository metadata for
|
||||
// this plugin and see what's specified as the latest release.
|
||||
File artifactMetadataFile;
|
||||
|
||||
String localPath;
|
||||
|
||||
// Search in the local repositiory for a version
|
||||
//
|
||||
if ( plugin.getVersion() == null )
|
||||
// maven-metadata-local.xml
|
||||
//
|
||||
localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-" + session.getLocalRepository().getId() + ".xml";
|
||||
|
||||
artifactMetadataFile = new File( session.getLocalRepository().getBasedir(), localPath );
|
||||
|
||||
if ( !artifactMetadataFile.exists() /* || user requests snapshot updates */ )
|
||||
{
|
||||
File artifactMetadataFile;
|
||||
|
||||
String localPath;
|
||||
|
||||
// Search in the local repositiory for a version
|
||||
// Search in remote repositories for a version.
|
||||
//
|
||||
// maven-metadata-local.xml
|
||||
// maven-metadata-{central|nexus|...}.xml
|
||||
//
|
||||
localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-" + session.getLocalRepository().getId() + ".xml";
|
||||
|
||||
artifactMetadataFile = new File( session.getLocalRepository().getBasedir(), localPath );
|
||||
|
||||
if ( !artifactMetadataFile.exists() /* || user requests snapshot updates */ )
|
||||
//TODO: we should cycle through the repositories but take the repository which actually
|
||||
// satisfied the prefix.
|
||||
for ( ArtifactRepository repository : project.getPluginArtifactRepositories() )
|
||||
{
|
||||
// Search in remote repositories for a version.
|
||||
//
|
||||
// maven-metadata-{central|nexus|...}.xml
|
||||
//
|
||||
//TODO: we should cycle through the repositories but take the repository which actually
|
||||
// satisfied the prefix.
|
||||
for ( ArtifactRepository repository : project.getPluginArtifactRepositories() )
|
||||
localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-" + repository.getId() + ".xml";
|
||||
|
||||
artifactMetadataFile = new File( session.getLocalRepository().getBasedir(), localPath );
|
||||
|
||||
if ( !artifactMetadataFile.exists() )
|
||||
{
|
||||
localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-" + repository.getId() + ".xml";
|
||||
|
||||
artifactMetadataFile = new File( session.getLocalRepository().getBasedir(), localPath );
|
||||
|
||||
if ( !artifactMetadataFile.exists() )
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
String remotePath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata.xml";
|
||||
String remotePath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata.xml";
|
||||
|
||||
repositorySystem.retrieve( repository, artifactMetadataFile, remotePath, session.getRequest().getTransferListener() );
|
||||
}
|
||||
catch ( TransferFailedException e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
repositorySystem.retrieve( repository, artifactMetadataFile, remotePath, session.getRequest().getTransferListener() );
|
||||
}
|
||||
catch ( TransferFailedException e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( artifactMetadataFile.exists() )
|
||||
{
|
||||
try
|
||||
{
|
||||
Metadata pluginMetadata = readMetadata( artifactMetadataFile );
|
||||
|
||||
String release = pluginMetadata.getVersioning().getRelease();
|
||||
|
||||
if ( release != null )
|
||||
{
|
||||
plugin.setVersion( release );
|
||||
}
|
||||
else
|
||||
{
|
||||
String latest = pluginMetadata.getVersioning().getLatest();
|
||||
|
||||
if ( latest != null )
|
||||
{
|
||||
plugin.setVersion( latest );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( artifactMetadataFile.exists() )
|
||||
catch ( RepositoryMetadataReadException e )
|
||||
{
|
||||
try
|
||||
{
|
||||
Metadata pluginMetadata = readMetadata( artifactMetadataFile );
|
||||
|
||||
String release = pluginMetadata.getVersioning().getRelease();
|
||||
|
||||
if ( release != null )
|
||||
{
|
||||
plugin.setVersion( release );
|
||||
}
|
||||
else
|
||||
{
|
||||
String latest = pluginMetadata.getVersioning().getLatest();
|
||||
|
||||
if ( latest != null )
|
||||
{
|
||||
plugin.setVersion( latest );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( RepositoryMetadataReadException e )
|
||||
{
|
||||
logger.warn( "Error reading plugin metadata: ", e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PluginNotFoundException( plugin, null );
|
||||
logger.warn( "Error reading plugin metadata: ", e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PluginNotFoundException( plugin, null );
|
||||
}
|
||||
}
|
||||
|
||||
return pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(), project.getPluginArtifactRepositories() );
|
||||
|
@ -951,6 +950,34 @@ public class DefaultLifecycleExecutor
|
|||
return plugin;
|
||||
}
|
||||
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
if ( project != null )
|
||||
{
|
||||
for ( Plugin buildPlugin : project.getBuildPlugins() )
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginDescriptor pluginDescriptor =
|
||||
pluginManager.loadPlugin( buildPlugin, session.getLocalRepository(),
|
||||
project.getPluginArtifactRepositories() );
|
||||
|
||||
if ( prefix.equals( pluginDescriptor.getGoalPrefix() ) )
|
||||
{
|
||||
Plugin p = new Plugin();
|
||||
p.setGroupId( buildPlugin.getGroupId() );
|
||||
p.setArtifactId( buildPlugin.getArtifactId() );
|
||||
pluginPrefixes.put( prefix, p );
|
||||
return p;
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
logger.debug( "Failed to retrieve plugin descriptor for " + buildPlugin, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process all plugin groups in the local repository first to see if we get a hit. A developer may have been
|
||||
// developing a plugin locally and installing.
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue