o Fixed missing version resolution for extension plugins

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@803266 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-11 19:51:12 +00:00
parent 91d459309f
commit 9131de7039
6 changed files with 25 additions and 7 deletions

View File

@ -925,7 +925,7 @@ public class DefaultLifecycleExecutor
return pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest ); return pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
} }
private void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest ) public void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
throws PluginNotFoundException throws PluginNotFoundException
{ {
ArtifactRepository localRepository = repositoryRequest.getLocalRepository(); ArtifactRepository localRepository = repositoryRequest.getLocalRepository();

View File

@ -20,10 +20,8 @@ package org.apache.maven.lifecycle;
*/ */
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
@ -75,6 +73,9 @@ public interface LifecycleExecutor
// //
void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest repositoryRequest ) void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest repositoryRequest )
throws LifecycleExecutionException; throws LifecycleExecutionException;
void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
throws PluginNotFoundException;
void execute( MavenSession session ); void execute( MavenSession session );
} }

View File

@ -24,7 +24,7 @@ import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultRepositoryRequest; import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.building.AbstractModelBuildingListener; import org.apache.maven.model.building.AbstractModelBuildingListener;
import org.apache.maven.model.building.ModelBuildingEvent; import org.apache.maven.model.building.ModelBuildingEvent;
@ -142,7 +142,7 @@ class DefaultModelBuildingListener
projectRealm = projectBuildingHelper.createProjectRealm( model, repositoryRequest ); projectRealm = projectBuildingHelper.createProjectRealm( model, repositoryRequest );
} }
catch ( ArtifactResolutionException e ) catch ( AbstractArtifactResolutionException e )
{ {
event.getProblems().addError( "Unresolveable build extensions: " + e.getMessage(), e ); event.getProblems().addError( "Unresolveable build extensions: " + e.getMessage(), e );
} }

View File

@ -36,12 +36,14 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ResolutionErrorHandler; import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.classrealm.ClassRealmManager; import org.apache.maven.classrealm.ClassRealmManager;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.model.Build; import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Extension; import org.apache.maven.model.Extension;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.ClassRealm;
@ -79,6 +81,9 @@ public class DefaultProjectBuildingHelper
@Requirement @Requirement
private ArtifactFilterManager artifactFilterManager; private ArtifactFilterManager artifactFilterManager;
@Requirement
private LifecycleExecutor lifecycleExecutor;
public List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories, public List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories,
List<ArtifactRepository> externalRepositories ) List<ArtifactRepository> externalRepositories )
throws InvalidRepositoryException throws InvalidRepositoryException
@ -103,7 +108,7 @@ public class DefaultProjectBuildingHelper
} }
public ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest ) public ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest )
throws ArtifactResolutionException throws ArtifactResolutionException, PluginNotFoundException
{ {
ClassRealm projectRealm = null; ClassRealm projectRealm = null;
@ -142,6 +147,11 @@ public class DefaultProjectBuildingHelper
for ( Plugin plugin : extensionPlugins ) for ( Plugin plugin : extensionPlugins )
{ {
if ( plugin.getVersion() == null )
{
lifecycleExecutor.resolvePluginVersion( plugin, repositoryRequest );
}
Artifact artifact = repositorySystem.createPluginArtifact( plugin ); Artifact artifact = repositorySystem.createPluginArtifact( plugin );
Set<Artifact> dependencies = new LinkedHashSet<Artifact>(); Set<Artifact> dependencies = new LinkedHashSet<Artifact>();

View File

@ -27,6 +27,7 @@ import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.plugin.PluginNotFoundException;
import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.ClassRealm;
/** /**
@ -61,6 +62,6 @@ public interface ProjectBuildingHelper
* @throws ArtifactResolutionException If any build extension could not be resolved. * @throws ArtifactResolutionException If any build extension could not be resolved.
*/ */
ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest ) ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest )
throws ArtifactResolutionException; throws ArtifactResolutionException, PluginNotFoundException;
} }

View File

@ -80,4 +80,10 @@ public class EmptyLifecycleExecutor
throws LifecycleExecutionException throws LifecycleExecutionException
{ {
} }
public void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
throws PluginNotFoundException
{
}
} }