You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/08/19 22:24:36 UTC
svn commit: r805962 - in /maven/components/trunk/maven-core/src:
main/java/org/apache/maven/lifecycle/ main/java/org/apache/maven/plugin/
main/java/org/apache/maven/plugin/internal/
main/java/org/apache/maven/plugin/version/ main/java/org/apache/maven/...
Author: bentmann
Date: Wed Aug 19 20:24:35 2009
New Revision: 805962
URL: http://svn.apache.org/viewvc?rev=805962&view=rev
Log:
o Renamed new plugin manager to make room for the legacy impl that will provide backward-compat with existing plugins
o Extracted plugin version resolution into a dedicated component
Added:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java
- copied, changed from r805826, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java
- copied, changed from r805826, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
- copied, changed from r801771, maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java
- copied, changed from r805688, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionNotFoundException.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java
- copied, changed from r805688, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionResolutionException.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolver.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/ (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java (with props)
Removed:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionNotFoundException.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionResolutionException.java
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginLoaderException.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java
maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Wed Aug 19 20:24:35 2009
@@ -54,7 +54,7 @@
import org.apache.maven.plugin.MojoNotFoundException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginDescriptorParsingException;
-import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginResolutionException;
@@ -63,6 +63,10 @@
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.lifecycle.Execution;
import org.apache.maven.plugin.lifecycle.Phase;
+import org.apache.maven.plugin.version.DefaultPluginVersionRequest;
+import org.apache.maven.plugin.version.PluginVersionRequest;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
+import org.apache.maven.plugin.version.PluginVersionResolver;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.wagon.ResourceDoesNotExistException;
@@ -92,13 +96,16 @@
private Logger logger;
@Requirement
- private PluginManager pluginManager;
+ private BuildPluginManager pluginManager;
@Requirement
protected RepositorySystem repositorySystem;
@Requirement
private ProjectDependenciesResolver projectDependenciesResolver;
+
+ @Requirement
+ private PluginVersionResolver pluginVersionResolver;
// @Configuration(source="org/apache/maven/lifecycle/lifecycles.xml")
private List<Lifecycle> lifecycles;
@@ -379,7 +386,7 @@
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException,
InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException,
- LifecycleNotFoundException
+ LifecycleNotFoundException, PluginVersionResolutionException
{
MavenProject project = session.getCurrentProject();
@@ -464,7 +471,7 @@
}
private void calculateExecutionForIndividualGoal( MavenSession session, List<MojoExecution> lifecyclePlan, String goal )
- throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException
+ throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException
{
// If this is a goal like "mvn modello:java" and the POM looks like the following:
//
@@ -623,7 +630,7 @@
Collection<MojoDescriptor> alreadyForkedExecutions )
throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
PluginDescriptorParsingException, CycleDetectedInPluginGraphException, NoPluginFoundForPrefixException,
- InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException
+ InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
{
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
@@ -889,7 +896,7 @@
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
MojoDescriptor getMojoDescriptor( String task, MavenSession session )
- throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException
+ throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException
{
MavenProject project = session.getCurrentProject();
@@ -971,98 +978,11 @@
return pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
}
- public void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
- throws PluginNotFoundException
+ private void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
+ throws PluginVersionResolutionException
{
- ArtifactRepository localRepository = repositoryRequest.getLocalRepository();
-
- File artifactMetadataFile = null;
-
- String localPath;
-
- // Search in remote repositories for a (released) 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 : repositoryRequest.getRemoteRepositories() )
- {
- localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-" + repository.getId() + ".xml";
-
- artifactMetadataFile = new File( localRepository.getBasedir(), localPath );
-
- if ( !artifactMetadataFile.exists() /* || user requests snapshot updates */)
- {
- try
- {
- String remotePath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata.xml";
-
- repositorySystem.retrieve( repository, artifactMetadataFile, remotePath, null );
- }
- catch ( TransferFailedException e )
- {
- continue;
- }
- catch ( ResourceDoesNotExistException e )
- {
- continue;
- }
- }
-
- break;
- }
-
- // Search in the local repositiory for a (development) version
- //
- // maven-metadata-local.xml
- //
- if ( artifactMetadataFile == null || !artifactMetadataFile.exists() )
- {
- localPath =
- plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId() + "/maven-metadata-"
- + localRepository.getId() + ".xml";
-
- artifactMetadataFile = new File( localRepository.getBasedir(), localPath );
- }
-
- if ( artifactMetadataFile.exists() )
- {
- logger.debug( "Extracting version for plugin " + plugin.getKey() + " from " + artifactMetadataFile );
-
- try
- {
- Metadata pluginMetadata = readMetadata( artifactMetadataFile );
-
- if ( pluginMetadata.getVersioning() != null )
- {
- String release = pluginMetadata.getVersioning().getRelease();
-
- if ( StringUtils.isNotEmpty( release ) )
- {
- plugin.setVersion( release );
- }
- else
- {
- String latest = pluginMetadata.getVersioning().getLatest();
-
- if ( StringUtils.isNotEmpty( latest ) )
- {
- plugin.setVersion( latest );
- }
- }
- }
- }
- catch ( RepositoryMetadataReadException e )
- {
- logger.warn( "Error reading plugin metadata: ", e );
- }
- }
-
- if ( StringUtils.isEmpty( plugin.getVersion() ) )
- {
- throw new PluginNotFoundException( plugin, repositoryRequest.getRemoteRepositories() );
- }
+ PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, repositoryRequest );
+ plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() );
}
private void injectPluginDeclarationFromProject( Plugin plugin, MavenProject project )
@@ -1221,7 +1141,7 @@
{
resolvePluginVersion( plugin, repositoryRequest );
}
- catch ( PluginNotFoundException e )
+ catch ( PluginVersionResolutionException e )
{
throw new LifecycleExecutionException( "Error resolving version for plugin " + plugin.getKey(), e );
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java Wed Aug 19 20:24:35 2009
@@ -32,6 +32,7 @@
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginResolutionException;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
/**
* @author Jason van Zyl
@@ -51,7 +52,7 @@
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException,
InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException,
- LifecycleNotFoundException;
+ LifecycleNotFoundException, PluginVersionResolutionException;
// For a given project packaging find all the plugins that are bound to any registered
// lifecycles. The project builder needs to now what default plugin information needs to be
@@ -73,9 +74,6 @@
//
void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest repositoryRequest )
throws LifecycleExecutionException;
-
- void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
- throws PluginNotFoundException;
void execute( MavenSession session );
}
Copied: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java (from r805826, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java?p2=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java&p1=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java&r1=805826&r2=805962&rev=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java Wed Aug 19 20:24:35 2009
@@ -25,7 +25,7 @@
/**
* @author Jason van Zyl
*/
-public interface PluginManager
+public interface BuildPluginManager
{
// igorf: Way too many declared exceptions!
PluginDescriptor loadPlugin( Plugin plugin, RepositoryRequest repositoryRequest )
Copied: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java (from r805826, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java?p2=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java&p1=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java&r1=805826&r2=805962&rev=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java Wed Aug 19 20:24:35 2009
@@ -38,9 +38,9 @@
// TODO: the antrun plugin has its own configurator, the only plugin that does. might need to think about how that works
// TODO: remove the coreArtifactFilterManager
-@Component(role = PluginManager.class)
-public class DefaultPluginManager
- implements PluginManager
+@Component(role = BuildPluginManager.class)
+public class DefaultBuildPluginManager
+ implements BuildPluginManager
{
@Requirement
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginLoaderException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginLoaderException.java?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginLoaderException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginLoaderException.java Wed Aug 19 20:24:35 2009
@@ -24,6 +24,8 @@
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.plugin.version.PluginVersionNotFoundException;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
/**
* Signifies a failure to load a plugin. This is used to abstract the specific errors which may be
Copied: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (from r801771, maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?p2=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java&p1=maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java&r1=801771&r2=805962&rev=805962&view=diff
==============================================================================
--- maven/maven-2/branches/maven-2.2.x/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java Wed Aug 19 20:24:35 2009
@@ -25,13 +25,11 @@
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
-import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.reporting.MavenReport;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -41,6 +39,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id$
*/
+@Deprecated
public interface PluginManager
{
String ROLE = PluginManager.class.getName();
@@ -49,28 +48,16 @@
throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException,
InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException;
- MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
- throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException,
- ArtifactResolutionException;
-
PluginDescriptor getPluginDescriptorForPrefix( String prefix );
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project );
- /**
- * @deprecated Use {@link PluginManager#loadPluginDescriptor(Plugin, MavenProject, MavenSession)} instead.
- */
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
ArtifactRepository localRepository )
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
PluginVersionNotFoundException;
- PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
- throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
- InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
- PluginVersionNotFoundException;
-
Object getPluginComponent( Plugin plugin, String role, String roleHint )
throws PluginManagerException, ComponentLookupException;
@@ -93,4 +80,4 @@
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
PluginVersionNotFoundException;
-}
\ No newline at end of file
+}
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java?rev=805962&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java Wed Aug 19 20:24:35 2009
@@ -0,0 +1,121 @@
+package org.apache.maven.plugin.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.util.Map;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.BuildPluginManager;
+import org.apache.maven.plugin.InvalidPluginException;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.PluginConfigurationException;
+import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.PluginManagerException;
+import org.apache.maven.plugin.PluginNotFoundException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.version.PluginVersionNotFoundException;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Component( role = PluginManager.class )
+public class DefaultPluginManager
+ implements PluginManager
+{
+
+ @Requirement
+ private BuildPluginManager pluginManager;
+
+ public void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
+ throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException,
+ InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getPluginComponent( Plugin plugin, String role, String roleHint )
+ throws PluginManagerException, ComponentLookupException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Map getPluginComponents( Plugin plugin, String role )
+ throws ComponentLookupException, PluginManagerException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PluginDescriptor getPluginDescriptorForPrefix( String prefix )
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session )
+ throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
+ InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
+ PluginVersionNotFoundException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PluginDescriptor loadPluginFully( Plugin plugin, MavenProject project, MavenSession session )
+ throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
+ InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
+ PluginVersionNotFoundException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
+ ArtifactRepository localRepository )
+ throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
+ InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
+ PluginVersionNotFoundException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java?rev=805962&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java Wed Aug 19 20:24:35 2009
@@ -0,0 +1,134 @@
+package org.apache.maven.plugin.version;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.util.List;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
+import org.apache.maven.artifact.repository.RepositoryCache;
+import org.apache.maven.artifact.repository.RepositoryRequest;
+import org.apache.maven.model.Plugin;
+
+/**
+ * Collects settings required to resolve the version for a plugin.
+ *
+ * @author Benjamin Bentmann
+ */
+public class DefaultPluginVersionRequest
+ implements PluginVersionRequest
+{
+
+ private String groupId;
+
+ private String artifactId;
+
+ private RepositoryRequest repositoryRequest;
+
+ public DefaultPluginVersionRequest()
+ {
+ repositoryRequest = new DefaultRepositoryRequest();
+ }
+
+ public DefaultPluginVersionRequest( RepositoryRequest repositoryRequest )
+ {
+ this.repositoryRequest = new DefaultRepositoryRequest( repositoryRequest );
+ }
+
+ public DefaultPluginVersionRequest( Plugin plugin, RepositoryRequest repositoryRequest )
+ {
+ this.groupId = plugin.getGroupId();
+ this.artifactId = plugin.getArtifactId();
+ this.repositoryRequest = new DefaultRepositoryRequest( repositoryRequest );
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public DefaultPluginVersionRequest setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+
+ return this;
+ }
+
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ public DefaultPluginVersionRequest setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+
+ return this;
+ }
+
+ public RepositoryCache getCache()
+ {
+ return repositoryRequest.getCache();
+ }
+
+ public DefaultPluginVersionRequest setCache( RepositoryCache cache )
+ {
+ repositoryRequest.setCache( cache );
+
+ return this;
+ }
+
+ public ArtifactRepository getLocalRepository()
+ {
+ return repositoryRequest.getLocalRepository();
+ }
+
+ public DefaultPluginVersionRequest setLocalRepository( ArtifactRepository localRepository )
+ {
+ repositoryRequest.setLocalRepository( localRepository );
+
+ return this;
+ }
+
+ public List<ArtifactRepository> getRemoteRepositories()
+ {
+ return repositoryRequest.getRemoteRepositories();
+ }
+
+ public DefaultPluginVersionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
+ {
+ repositoryRequest.setRemoteRepositories( remoteRepositories );
+
+ return this;
+ }
+
+ public boolean isOffline()
+ {
+ return repositoryRequest.isOffline();
+ }
+
+ public DefaultPluginVersionRequest setOffline( boolean offline )
+ {
+ repositoryRequest.setOffline( offline );
+
+ return this;
+ }
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java (from r805688, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionNotFoundException.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java?p2=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java&p1=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionNotFoundException.java&r1=805688&r2=805962&rev=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionNotFoundException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.java Wed Aug 19 20:24:35 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin;
+package org.apache.maven.plugin.version;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java?rev=805962&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java Wed Aug 19 20:24:35 2009
@@ -0,0 +1,127 @@
+package org.apache.maven.plugin.version;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.util.List;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryCache;
+import org.apache.maven.artifact.repository.RepositoryRequest;
+
+/**
+ * Collects settings required to resolve the version for a plugin.
+ *
+ * @author Benjamin Bentmann
+ */
+public interface PluginVersionRequest
+ extends RepositoryRequest
+{
+
+ /**
+ * Gets the group id of the plugin.
+ *
+ * @return The group id of the plugin.
+ */
+ String getGroupId();
+
+ /**
+ * Sets the group id of the plugin.
+ *
+ * @param groupId The group id of the plugin.
+ * @return This request, never {@code null}.
+ */
+ PluginVersionRequest setGroupId( String groupId );
+
+ /**
+ * Gets the artifact id of the plugin.
+ *
+ * @return The artifact id of the plugin.
+ */
+ String getArtifactId();
+
+ /**
+ * Sets the artifact id of the plugin.
+ *
+ * @param artifactId The artifact id of the plugin.
+ * @return This request, never {@code null}.
+ */
+ PluginVersionRequest setArtifactId( String artifactId );
+
+ /**
+ * Indicates whether network access to remote repositories has been disabled.
+ *
+ * @return {@code true} if remote access has been disabled, {@code false} otherwise.
+ */
+ boolean isOffline();
+
+ /**
+ * Enables/disables network access to remote repositories.
+ *
+ * @param offline {@code true} to disable remote access, {@code false} to allow network access.
+ * @return This request, never {@code null}.
+ */
+ PluginVersionRequest setOffline( boolean offline );
+
+ /**
+ * Gets the local repository to use.
+ *
+ * @return The local repository to use or {@code null} if not set.
+ */
+ ArtifactRepository getLocalRepository();
+
+ /**
+ * Sets the local repository to use.
+ *
+ * @param localRepository The local repository to use.
+ * @return This request, never {@code null}.
+ */
+ PluginVersionRequest setLocalRepository( ArtifactRepository localRepository );
+
+ /**
+ * Gets the remote repositories to use.
+ *
+ * @return The remote repositories to use, never {@code null}.
+ */
+ List<ArtifactRepository> getRemoteRepositories();
+
+ /**
+ * Sets the remote repositories to use.
+ *
+ * @param remoteRepositories The remote repositories to use.
+ * @return This request, never {@code null}.
+ */
+ PluginVersionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories );
+
+ /**
+ * Gets the repository cache to use.
+ *
+ * @return The repository cache to use or {@code null} if none.
+ */
+ RepositoryCache getCache();
+
+ /**
+ * Sets the repository cache to use.
+ *
+ * @param cache The repository cache to use, may be {@code null}.
+ * @return This request, never {@code null}.
+ */
+ PluginVersionRequest setCache( RepositoryCache cache );
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionRequest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java (from r805688, maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionResolutionException.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java?p2=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java&p1=maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionResolutionException.java&r1=805688&r2=805962&rev=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionResolutionException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.java Wed Aug 19 20:24:35 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin;
+package org.apache.maven.plugin.version;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -31,6 +31,15 @@
private final String baseMessage;
+ public PluginVersionResolutionException( String groupId, String artifactId, String baseMessage, Throwable cause )
+ {
+ super( "Error resolving version for \'" + groupId + ":" + artifactId + "\': " + baseMessage, cause );
+
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.baseMessage = baseMessage;
+ }
+
public PluginVersionResolutionException( String groupId, String artifactId, String baseMessage, ArtifactMetadataRetrievalException cause )
{
super( "Error resolving version for \'" + groupId + ":" + artifactId + "\': " + baseMessage, cause );
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolver.java?rev=805962&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolver.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolver.java Wed Aug 19 20:24:35 2009
@@ -0,0 +1,41 @@
+package org.apache.maven.plugin.version;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * Resolves a version for a plugin.
+ *
+ * @author Benjamin Bentmann
+ */
+public interface PluginVersionResolver
+{
+
+ /**
+ * Resolves the version for the specified request.
+ *
+ * @param request The request that holds the details about the plugin and the repositories to consult, must not be
+ * {@code null}.
+ * @return The result of the version resolutioh, never {@code null}.
+ * @throws PluginVersionResolutionException If the plugin version could not be resolved.
+ */
+ PluginVersionResult resolve( PluginVersionRequest request )
+ throws PluginVersionResolutionException;
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolver.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java?rev=805962&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java Wed Aug 19 20:24:35 2009
@@ -0,0 +1,46 @@
+package org.apache.maven.plugin.version;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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;
+
+/**
+ * Describes the result of a plugin version resolution request.
+ *
+ * @author Benjamin Bentmann
+ */
+public interface PluginVersionResult
+{
+
+ /**
+ * The resolved plugin version.
+ *
+ * @return The resolved plugin version, never {@code null}.
+ */
+ String getVersion();
+
+ /**
+ * The repository from which the plugin version was resolved.
+ *
+ * @return The repository from which the plugin version was resolved, never {@code null}.
+ */
+ ArtifactRepository getRepository();
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/
------------------------------------------------------------------------------
bugtraq:label = Enter issue ID:
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/
------------------------------------------------------------------------------
bugtraq:message = Issue id: %BUGID%
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/
------------------------------------------------------------------------------
bugtraq:number = false
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java?rev=805962&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java Wed Aug 19 20:24:35 2009
@@ -0,0 +1,217 @@
+package org.apache.maven.plugin.version.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Reader;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadataReadException;
+import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.apache.maven.plugin.version.PluginVersionRequest;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
+import org.apache.maven.plugin.version.PluginVersionResolver;
+import org.apache.maven.plugin.version.PluginVersionResult;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * Resolves a version for a plugin.
+ *
+ * @author Benjamin Bentmann
+ */
+@Component( role = PluginVersionResolver.class )
+public class DefaultPluginVersionResolver
+ implements PluginVersionResolver
+{
+
+ @Requirement
+ private Logger logger;
+
+ @Requirement
+ private RepositorySystem repositorySystem;
+
+ public PluginVersionResult resolve( PluginVersionRequest request )
+ throws PluginVersionResolutionException
+ {
+ DefaultPluginVersionResult result = new DefaultPluginVersionResult();
+
+ Throwable error = null;
+
+ ArtifactRepository localRepository = request.getLocalRepository();
+
+ File artifactMetadataFile = null;
+
+ String localPath;
+
+ // Search in remote repositories for a (released) 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 : request.getRemoteRepositories() )
+ {
+ localPath =
+ request.getGroupId().replace( '.', '/' ) + "/" + request.getArtifactId() + "/maven-metadata-"
+ + repository.getId() + ".xml";
+
+ artifactMetadataFile = new File( localRepository.getBasedir(), localPath );
+
+ if ( !artifactMetadataFile.exists() /* || user requests snapshot updates */)
+ {
+ String remotePath =
+ request.getGroupId().replace( '.', '/' ) + "/" + request.getArtifactId() + "/maven-metadata.xml";
+
+ try
+ {
+ repositorySystem.retrieve( repository, artifactMetadataFile, remotePath, null );
+ }
+ catch ( TransferFailedException e )
+ {
+ error = e;
+
+ logger.debug( "Failed to retrieve " + remotePath, e );
+
+ continue;
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ continue;
+ }
+ }
+
+ result.setRepository( repository );
+
+ break;
+ }
+
+ // Search in the local repositiory for a (development) version
+ //
+ // maven-metadata-local.xml
+ //
+ if ( artifactMetadataFile == null || !artifactMetadataFile.exists() )
+ {
+ localPath =
+ request.getGroupId().replace( '.', '/' ) + "/" + request.getArtifactId() + "/maven-metadata-"
+ + localRepository.getId() + ".xml";
+
+ artifactMetadataFile = new File( localRepository.getBasedir(), localPath );
+
+ result.setRepository( localRepository );
+ }
+
+ if ( artifactMetadataFile.exists() )
+ {
+ logger.debug( "Extracting version for plugin " + request.getGroupId() + ':' + request.getArtifactId()
+ + " from " + artifactMetadataFile );
+
+ try
+ {
+ Metadata pluginMetadata = readMetadata( artifactMetadataFile );
+
+ if ( pluginMetadata.getVersioning() != null )
+ {
+ String release = pluginMetadata.getVersioning().getRelease();
+
+ if ( StringUtils.isNotEmpty( release ) )
+ {
+ result.setVersion( release );
+ }
+ else
+ {
+ String latest = pluginMetadata.getVersioning().getLatest();
+
+ if ( StringUtils.isNotEmpty( latest ) )
+ {
+ result.setVersion( latest );
+ }
+ }
+ }
+ }
+ catch ( RepositoryMetadataReadException e )
+ {
+ throw new PluginVersionResolutionException( request.getGroupId(), request.getArtifactId(),
+ e.getMessage(), e );
+ }
+ }
+ else if ( error != null )
+ {
+ throw new PluginVersionResolutionException( request.getGroupId(), request.getArtifactId(),
+ error.getMessage(), error );
+ }
+
+ if ( StringUtils.isEmpty( result.getVersion() ) )
+ {
+ throw new PluginVersionResolutionException( request.getGroupId(), request.getArtifactId(),
+ "Plugin not found in any repository" );
+ }
+
+ return result;
+ }
+
+ private Metadata readMetadata( File mappingFile )
+ throws RepositoryMetadataReadException
+ {
+ Metadata result;
+
+ Reader reader = null;
+ try
+ {
+ reader = ReaderFactory.newXmlReader( mappingFile );
+
+ MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
+
+ result = mappingReader.read( reader, false );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "'", e );
+ }
+ catch ( IOException e )
+ {
+ throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': "
+ + e.getMessage(), e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': "
+ + e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( reader );
+ }
+
+ return result;
+ }
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java?rev=805962&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java Wed Aug 19 20:24:35 2009
@@ -0,0 +1,58 @@
+package org.apache.maven.plugin.version.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.plugin.version.PluginVersionResult;
+
+/**
+ * Describes the result of a plugin version resolution request.
+ *
+ * @author Benjamin Bentmann
+ */
+class DefaultPluginVersionResult
+ implements PluginVersionResult
+{
+
+ private String version;
+
+ private ArtifactRepository repository;
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+ public ArtifactRepository getRepository()
+ {
+ return repository;
+ }
+
+ public void setRepository( ArtifactRepository repository )
+ {
+ this.repository = repository;
+ }
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java Wed Aug 19 20:24:35 2009
@@ -24,10 +24,11 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
import org.apache.maven.artifact.repository.RepositoryRequest;
-import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.AbstractModelBuildingListener;
import org.apache.maven.model.building.ModelBuildingEvent;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
/**
@@ -142,7 +143,11 @@
projectRealm = projectBuildingHelper.createProjectRealm( model, repositoryRequest );
}
- catch ( AbstractArtifactResolutionException e )
+ catch ( ArtifactResolutionException e )
+ {
+ event.getProblems().addError( "Unresolveable build extensions: " + e.getMessage(), e );
+ }
+ catch ( PluginVersionResolutionException e )
{
event.getProblems().addError( "Unresolveable build extensions: " + e.getMessage(), e );
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java Wed Aug 19 20:24:35 2009
@@ -36,14 +36,16 @@
import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.classrealm.ClassRealmManager;
-import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Extension;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository;
-import org.apache.maven.plugin.PluginNotFoundException;
+import org.apache.maven.plugin.version.DefaultPluginVersionRequest;
+import org.apache.maven.plugin.version.PluginVersionRequest;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
+import org.apache.maven.plugin.version.PluginVersionResolver;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
@@ -82,7 +84,7 @@
private ArtifactFilterManager artifactFilterManager;
@Requirement
- private LifecycleExecutor lifecycleExecutor;
+ private PluginVersionResolver pluginVersionResolver;
public List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories,
List<ArtifactRepository> externalRepositories )
@@ -108,7 +110,7 @@
}
public ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest )
- throws ArtifactResolutionException, PluginNotFoundException
+ throws ArtifactResolutionException, PluginVersionResolutionException
{
ClassRealm projectRealm = null;
@@ -149,7 +151,8 @@
{
if ( plugin.getVersion() == null )
{
- lifecycleExecutor.resolvePluginVersion( plugin, repositoryRequest );
+ PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, repositoryRequest );
+ plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() );
}
Artifact artifact = repositorySystem.createPluginArtifact( plugin );
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java Wed Aug 19 20:24:35 2009
@@ -27,7 +27,7 @@
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
-import org.apache.maven.plugin.PluginNotFoundException;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
/**
@@ -62,6 +62,6 @@
* @throws ArtifactResolutionException If any build extension could not be resolved.
*/
ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest )
- throws ArtifactResolutionException, PluginNotFoundException;
+ throws ArtifactResolutionException, PluginVersionResolutionException;
}
Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml Wed Aug 19 20:24:35 2009
@@ -12,7 +12,7 @@
<!--
There is currently only one component descriptor that cannot be generated from annotations because of the
- accompanying configurationl. Our options are to embed this information programatically or use a configuration source
+ accompanying configuration. Our options are to embed this information programatically or use a configuration source
to pull in the lifecycle information.
-->
<component-set>
@@ -33,7 +33,7 @@
<field-name>logger</field-name>
</requirement>
<requirement>
- <role>org.apache.maven.plugin.PluginManager</role>
+ <role>org.apache.maven.plugin.BuildPluginManager</role>
</requirement>
<requirement>
<role>org.apache.maven.ProjectDependenciesResolver</role>
@@ -45,6 +45,9 @@
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<field-name>lifecycleMappings</field-name>
</requirement>
+ <requirement>
+ <role>org.apache.maven.plugin.version.PluginVersionResolver</role>
+ </requirement>
</requirements>
<configuration>
<lifecycles>
Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java?rev=805962&r1=805961&r2=805962&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java (original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java Wed Aug 19 20:24:35 2009
@@ -17,7 +17,7 @@
extends AbstractCoreMavenComponentTestCase
{
@Requirement
- private DefaultPluginManager pluginManager;
+ private DefaultBuildPluginManager pluginManager;
private String plexusVersion = "1.0-beta-3.0.7";
@@ -25,7 +25,7 @@
throws Exception
{
super.setUp();
- pluginManager = (DefaultPluginManager) lookup( PluginManager.class );
+ pluginManager = (DefaultBuildPluginManager) lookup( BuildPluginManager.class );
}
@Override