Author: jvanzyl
Date: Sun Mar 22 00:13:42 2009
New Revision: 757109
URL: http://svn.apache.org/viewvc?rev=757109&view=rev
Log:
o more separation of plugins from reporting
o more sequencing of plugin resolution and execution
Modified:
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Modified:
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
URL:
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java?rev=757109&r1=757108&r2=757109&view=diff
==============================================================================
---
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
(original)
+++
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
Sun Mar 22 00:13:42 2009
@@ -86,7 +86,7 @@
this.eventDispatcher = Eventdispatcher;
}
- public Map getPluginContext( PluginDescriptor pluginDescriptor,
MavenProject project )
+ public Map<String,Object> getPluginContext( PluginDescriptor
pluginDescriptor, MavenProject project )
{
if ( reactorManager == null )
{
Modified:
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java
URL:
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java?rev=757109&r1=757108&r2=757109&view=diff
==============================================================================
---
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java
(original)
+++
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java
Sun Mar 22 00:13:42 2009
@@ -69,7 +69,7 @@
}
}
- public Map getPluginContext( PluginDescriptor plugin, MavenProject project
)
+ public Map<String,Object> getPluginContext( PluginDescriptor plugin,
MavenProject project )
{
Map pluginContextsByKey = (Map)
pluginContextsByProjectAndPluginKey.get( project.getId() );
Modified:
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL:
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=757109&r1=757108&r2=757109&view=diff
==============================================================================
---
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
(original)
+++
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
Sun Mar 22 00:13:42 2009
@@ -241,7 +241,7 @@
session.setCurrentProject( rootProject );
// only call once, with the top-level project (assumed
to be provided as a parameter)...
- for ( Iterator goalIterator =
segment.getTasks().iterator(); goalIterator.hasNext(); )
+ for ( Iterator<String> goalIterator =
segment.getTasks().iterator(); goalIterator.hasNext(); )
{
String task = (String) goalIterator.next();
@@ -1217,6 +1217,8 @@
return goals;
}
+ // all this logic should go to the plugin manager
+
MojoDescriptor getMojoDescriptor( String task, MavenSession session,
MavenProject project )
throws LifecycleExecutionException
{
@@ -1392,7 +1394,7 @@
tasks.add( task );
}
- List getTasks()
+ List<String> getTasks()
{
return tasks;
}
Modified:
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL:
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=757109&r1=757108&r2=757109&view=diff
==============================================================================
---
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
(original)
+++
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Sun Mar 22 00:13:42 2009
@@ -158,70 +158,68 @@
return getByPrefix( prefix, session.getPluginGroups(),
project.getRemoteArtifactRepositories(), session.getLocalRepository() );
}
- public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project,
MavenSession session )
- throws ArtifactResolutionException, PluginVersionResolutionException,
ArtifactNotFoundException, InvalidPluginException, PluginManagerException,
PluginNotFoundException, PluginVersionNotFoundException
+ public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project,
MavenSession session )
+ throws PluginLoaderException
{
- String pluginVersion = plugin.getVersion();
+ if ( plugin.getGroupId() == null )
+ {
+ plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
+ }
- // TODO: this should be possibly outside
- // All version-resolution logic has been moved to
DefaultPluginVersionManager.
- logger.debug( "Resolving plugin: " + plugin.getKey() + " with version:
" + pluginVersion );
-
- if ( ( pluginVersion == null ) || Artifact.LATEST_VERSION.equals(
pluginVersion ) || Artifact.RELEASE_VERSION.equals( pluginVersion ) )
+ try
{
- logger.debug( "Resolving version for plugin: " + plugin.getKey() );
-
- pluginVersion = resolvePluginVersion( plugin.getGroupId(),
plugin.getArtifactId(), project, session );
- plugin.setVersion( pluginVersion );
+ String pluginVersion = plugin.getVersion();
- logger.debug( "Resolved to version: " + pluginVersion );
- }
-
- return verifyVersionedPlugin( plugin, project, session );
- }
-
- private PluginDescriptor verifyVersionedPlugin( Plugin plugin,
MavenProject project, MavenSession session )
- throws PluginVersionResolutionException, ArtifactNotFoundException,
ArtifactResolutionException, InvalidPluginException, PluginManagerException,
PluginNotFoundException
- {
- logger.debug( "In verifyVersionedPlugin for: " + plugin.getKey() );
+ logger.debug( "Resolving plugin: " + plugin.getKey() + " with
version: " + pluginVersion );
+
+ if ( ( pluginVersion == null ) || Artifact.LATEST_VERSION.equals(
pluginVersion ) || Artifact.RELEASE_VERSION.equals( pluginVersion ) )
+ {
+ logger.debug( "Resolving version for plugin: " +
plugin.getKey() );
+
+ pluginVersion = resolvePluginVersion( plugin.getGroupId(),
plugin.getArtifactId(), project, session );
+
+ plugin.setVersion( pluginVersion );
- // TODO: this might result in an artifact "RELEASE" being resolved
continuously
- // FIXME: need to find out how a plugin gets marked as 'installed'
- // and no ChildContainer exists. The check for that below fixes
- // the 'Can't find plexus container for plugin: xxx' error.
- try
- {
+ logger.debug( "Resolved to version: " + pluginVersion );
+ }
+
+ System.out.println( "XXXXXXXXXXXXXXXXXXXXXXX " +
plugin.getArtifactId() + ":" + plugin.getVersion() );
+
addPlugin( plugin, project, session );
-
+
+ PluginDescriptor result = pluginCollector.getPluginDescriptor(
plugin );
+
+
project.addPlugin( plugin );
+
+ return result;
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
}
catch ( ArtifactNotFoundException e )
{
- String groupId = plugin.getGroupId();
-
- String artifactId = plugin.getArtifactId();
-
- String version = plugin.getVersion();
-
- if ( ( groupId == null ) || ( artifactId == null ) || ( version ==
null ) )
- {
- throw new PluginNotFoundException( plugin, e );
- }
- else if ( groupId.equals( e.getGroupId() ) && artifactId.equals(
e.getArtifactId() ) && version.equals( e.getVersion() ) &&
"maven-plugin".equals( e.getType() ) )
- {
- throw new PluginNotFoundException( plugin, e );
- }
- else
- {
- throw e;
- }
+ throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
}
-
- PluginDescriptor pluginDescriptor =
pluginCollector.getPluginDescriptor( plugin );
-
- return pluginDescriptor;
- }
+ catch ( PluginVersionResolutionException e )
+ {
+ throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
+ }
+ catch ( InvalidPluginException e )
+ {
+ throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
+ }
+ catch ( PluginManagerException e )
+ {
+ throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
+ }
+ catch ( PluginVersionNotFoundException e )
+ {
+ throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
+ }
+ }
// We need to load different
private Map<String,ClassRealm> pluginRealms = new
HashMap<String,ClassRealm>();
@@ -295,7 +293,9 @@
// Not going to happen
}
}
-
+
+ pluginRealm.display();
+
try
{
logger.debug( "Discovering components in realm: " +
pluginRealm );
@@ -490,10 +490,8 @@
try
{
- for ( Iterator i = projects.iterator(); i.hasNext(); )
+ for ( MavenProject p : projects )
{
- MavenProject p = (MavenProject) i.next();
-
resolveTransitiveDependencies( session, repositorySystem,
mojoDescriptor.isDependencyResolutionRequired(), p,
mojoDescriptor.isAggregator() );
}
@@ -697,13 +695,41 @@
reportPlugin.setVersion( version );
}
- Plugin forLookup = new Plugin();
+ Plugin plugin = new Plugin();
- forLookup.setGroupId( reportPlugin.getGroupId() );
- forLookup.setArtifactId( reportPlugin.getArtifactId() );
- forLookup.setVersion( version );
+ plugin.setGroupId( reportPlugin.getGroupId() );
+ plugin.setArtifactId( reportPlugin.getArtifactId() );
+ plugin.setVersion( version );
+
+ try
+ {
+ addPlugin( plugin, project, session );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ String groupId = plugin.getGroupId();
+
+ String artifactId = plugin.getArtifactId();
+
+ String pluginVersion = plugin.getVersion();
+
+ if ( ( groupId == null ) || ( artifactId == null ) || (
pluginVersion == null ) )
+ {
+ throw new PluginNotFoundException( plugin, e );
+ }
+ else if ( groupId.equals( e.getGroupId() ) && artifactId.equals(
e.getArtifactId() ) && pluginVersion.equals( e.getVersion() ) &&
"maven-plugin".equals( e.getType() ) )
+ {
+ throw new PluginNotFoundException( plugin, e );
+ }
+ else
+ {
+ throw e;
+ }
+ }
- return verifyVersionedPlugin( forLookup, project, session );
+ PluginDescriptor pluginDescriptor =
pluginCollector.getPluginDescriptor( plugin );
+
+ return pluginDescriptor;
}
private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom,
MavenProject project, boolean report, MojoExecution mojoExecution )
@@ -755,7 +781,7 @@
if ( mojo instanceof ContextEnabled )
{
- Map pluginContext = session.getPluginContext(
pluginDescriptor, project );
+ Map<String,Object> pluginContext = session.getPluginContext(
pluginDescriptor, project );
if ( pluginContext != null )
{
@@ -1761,61 +1787,7 @@
}
}
}
- }
-
- // Plugin Loader
-
- /**
- * Load the {...@link PluginDescriptor} instance for the specified plugin,
using the project for
- * the {...@link ArtifactRepository} and other supplemental plugin
information as necessary.
- */
- public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project,
MavenSession session )
- throws PluginLoaderException
- {
- if ( plugin.getGroupId() == null )
- {
- plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
- }
-
- try
- {
- PluginDescriptor result = verifyPlugin( plugin, project, session );
-
- // this has been simplified from the old code that injected the
plugin management stuff, since
- // pluginManagement injection is now handled by the project method.
- project.addPlugin( plugin );
-
- return result;
- }
- catch ( ArtifactResolutionException e )
- {
- throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
- }
- catch ( ArtifactNotFoundException e )
- {
- throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
- }
- catch ( PluginNotFoundException e )
- {
- throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
- }
- catch ( PluginVersionResolutionException e )
- {
- throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
- }
- catch ( InvalidPluginException e )
- {
- throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
- }
- catch ( PluginManagerException e )
- {
- throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
- }
- catch ( PluginVersionNotFoundException e )
- {
- throw new PluginLoaderException( plugin, "Failed to load plugin.
Reason: " + e.getMessage(), e );
- }
- }
+ }
/**
* Load the {...@link PluginDescriptor} instance for the specified report
plugin, using the project for