You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/05/06 16:21:01 UTC
svn commit: r168605 - in
/maven/components/trunk/maven-core/src/main/java/org/apache/maven:
lifecycle/DefaultLifecycleExecutor.java plugin/DefaultPluginManager.java
plugin/PluginManager.java
Author: brett
Date: Fri May 6 07:21:00 2005
New Revision: 168605
URL: http://svn.apache.org/viewcvs?rev=168605&view=rev
Log:
recognise prefix of plugins already loaded
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/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=168605&r1=168604&r2=168605&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 Fri May 6 07:21:00 2005
@@ -343,14 +343,22 @@
String version = null;
String goal = null;
+ PluginDescriptor pluginDescriptor = null;
+
StringTokenizer tok = new StringTokenizer( task, ":" );
int numTokens = tok.countTokens();
if ( numTokens == 2 )
{
- // TODO: look up registered aliases in plugin manager instead
- groupId = PluginDescriptor.getDefaultPluginGroupId();
- artifactId = PluginDescriptor.getDefaultPluginArtifactId( tok.nextToken() );
+ String prefix = tok.nextToken();
goal = tok.nextToken();
+
+ pluginDescriptor = pluginManager.verifyPlugin( prefix );
+
+ if ( pluginDescriptor == null )
+ {
+ groupId = PluginDescriptor.getDefaultPluginGroupId();
+ artifactId = PluginDescriptor.getDefaultPluginArtifactId( prefix );
+ }
}
else if ( numTokens == 4 )
{
@@ -366,28 +374,37 @@
throw new LifecycleExecutionException( message );
}
- // TODO: this shouldn't be necessary all the time.
- injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId, version );
+ if ( pluginDescriptor == null )
+ {
+ injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId, version );
+ try
+ {
+ pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, session );
+ }
+ catch ( PluginManagerException e )
+ {
+ throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+ }
+ }
+
+ MojoDescriptor mojoDescriptor = null;
- try
+ // TODO: should be able to create a Map from this
+ for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext() && mojoDescriptor == null; )
{
- PluginDescriptor pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, session );
- // TODO: should be able to create a Map from this
- for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
+ MojoDescriptor desc = (MojoDescriptor) i.next();
+ if ( desc.getGoal().equals( goal ) )
{
- MojoDescriptor mojoDescriptor = (MojoDescriptor) i.next();
- if ( mojoDescriptor.getGoal().equals( goal ) )
- {
- return mojoDescriptor;
- }
+ mojoDescriptor = desc;
}
}
- catch ( PluginManagerException e )
+
+ if ( mojoDescriptor == null )
{
- throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+ throw new LifecycleExecutionException( "Required goal not found: " + task );
}
- throw new LifecycleExecutionException( "Required goal not found: " + task );
+ return mojoDescriptor;
}
public List getPhases()
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=168605&r1=168604&r2=168605&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/DefaultPluginManager.java Fri May 6 07:21:00 2005
@@ -73,6 +73,8 @@
protected Map pluginDescriptors;
+ protected Map pluginDescriptorsByPrefix;
+
protected PlexusContainer container;
protected PluginDescriptorBuilder pluginDescriptorBuilder;
@@ -87,6 +89,8 @@
{
pluginDescriptors = new HashMap();
+ pluginDescriptorsByPrefix = new HashMap();
+
pluginDescriptorBuilder = new PluginDescriptorBuilder();
}
@@ -96,6 +100,11 @@
PluginDescriptor.constructPluginKey( groupId, artifactId, version ) );
}
+ private PluginDescriptor getPluginDescriptor( String prefix )
+ {
+ return (PluginDescriptor) pluginDescriptorsByPrefix.get( prefix );
+ }
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -117,9 +126,8 @@
if ( pluginDescriptor.getVersion() == null )
{
// TODO: temporary - until we're done testing that version is always written
- throw new NullPointerException(
- "Version was null - check your plugin '" + pluginDescriptor.getId() +
- "' was built with Maven 2.0 Alpha 2" );
+ throw new NullPointerException( "Version was null - check your plugin '" + pluginDescriptor.getId() +
+ "' was built with Maven 2.0 Alpha 2" );
}
String key = pluginDescriptor.getId();
@@ -129,6 +137,12 @@
pluginsInProcess.add( key );
pluginDescriptors.put( key, pluginDescriptor );
+
+ // TODO: throw an (not runtime) exception if there is a prefix overlap - means doing so elsewhere
+ if ( !pluginDescriptorsByPrefix.containsKey( pluginDescriptor.getGoalPrefix() ) )
+ {
+ pluginDescriptorsByPrefix.put( pluginDescriptor.getGoalPrefix(), pluginDescriptor );
+ }
}
}
}
@@ -140,6 +154,20 @@
private boolean isPluginInstalled( String groupId, String artifactId, String version )
{
return pluginDescriptors.containsKey( PluginDescriptor.constructPluginKey( groupId, artifactId, version ) );
+ }
+
+ private boolean isPluginInstalled( String prefix )
+ {
+ return pluginDescriptorsByPrefix.containsKey( prefix );
+ }
+
+ public PluginDescriptor verifyPlugin( String prefix )
+ {
+ if ( !isPluginInstalled( prefix ) )
+ {
+ // TODO: lookup remotely
+ }
+ return getPluginDescriptor( prefix );
}
public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenSession session )
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=168605&r1=168604&r2=168605&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/PluginManager.java Fri May 6 07:21:00 2005
@@ -33,6 +33,8 @@
void executeMojo( MavenSession session, MojoDescriptor mojoDescriptor )
throws MojoExecutionException, PluginManagerException, ArtifactResolutionException;
+ PluginDescriptor verifyPlugin( String prefix );
+
PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenSession session )
throws ArtifactResolutionException, PluginManagerException;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org