general cleanup

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@220319 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-22 13:43:45 +00:00
parent 36d0a854e1
commit 6e6c12a647
4 changed files with 113 additions and 83 deletions

View File

@ -45,8 +45,8 @@ import org.apache.maven.project.injection.ModelDefaultsInjector;
import org.apache.maven.settings.Settings; import org.apache.maven.settings.Settings;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -126,8 +126,7 @@ public class DefaultLifecycleExecutor
} }
private void executeGoal( String task, MavenSession session, MavenProject project ) private void executeGoal( String task, MavenSession session, MavenProject project )
throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException, throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException, ArtifactResolutionException
ArtifactResolutionException
{ {
if ( phases.contains( task ) ) if ( phases.contains( task ) )
{ {
@ -142,7 +141,7 @@ public class DefaultLifecycleExecutor
} }
private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings, private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
MavenProject project ) MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException
{ {
List goals = processGoalChain( task, lifecycleMappings ); List goals = processGoalChain( task, lifecycleMappings );
@ -224,7 +223,8 @@ public class DefaultLifecycleExecutor
String goal = (String) k.next(); String goal = (String) k.next();
MojoDescriptor desc = mojoDescriptor.getPluginDescriptor().getMojo( goal ); MojoDescriptor desc = mojoDescriptor.getPluginDescriptor().getMojo( goal );
MojoExecution mojoExecution = new MojoExecution( desc, (Xpp3Dom) e.getConfiguration() ); MojoExecution mojoExecution = new MojoExecution( desc, (Xpp3Dom) e.getConfiguration() );
addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution, session.getSettings() ); addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution,
session.getSettings() );
} }
} }
} }
@ -298,13 +298,14 @@ public class DefaultLifecycleExecutor
Plugin pluginContainingLifecycleMapping = mappingManager.getByPackaging( packaging ); Plugin pluginContainingLifecycleMapping = mappingManager.getByPackaging( packaging );
LifecycleMapping m = null; LifecycleMapping m;
if ( pluginContainingLifecycleMapping != null ) if ( pluginContainingLifecycleMapping != null )
{ {
try try
{ {
pluginManager.verifyPlugin( pluginContainingLifecycleMapping, project, session.getSettings(), session.getLocalRepository() ); pluginManager.verifyPlugin( pluginContainingLifecycleMapping, project, session.getSettings(),
session.getLocalRepository() );
m = (LifecycleMapping) pluginManager.getPluginComponent( pluginContainingLifecycleMapping, m = (LifecycleMapping) pluginManager.getPluginComponent( pluginContainingLifecycleMapping,
LifecycleMapping.ROLE, packaging ); LifecycleMapping.ROLE, packaging );
@ -313,9 +314,9 @@ public class DefaultLifecycleExecutor
} }
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
{ {
throw new LifecycleExecutionException( "Plugin: " + pluginContainingLifecycleMapping.getKey() throw new LifecycleExecutionException( "Plugin: " + pluginContainingLifecycleMapping.getKey() +
+ " declares lifecycle mapping for: \'" + packaging " declares lifecycle mapping for: \'" + packaging +
+ "\', but does not appear to contain the actual mapping among its component descriptors.", e ); "\', but does not appear to contain the actual mapping among its component descriptors.", e );
} }
} }
else else
@ -329,8 +330,7 @@ public class DefaultLifecycleExecutor
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
{ {
getLogger().warn( getLogger().warn(
"Lifecycle mappings not found for packaging: \'" + packaging "Lifecycle mappings not found for packaging: \'" + packaging + "\'. Using defaults." );
+ "\'. Using defaults." );
getLogger().debug( "Lifecycle mappings not found for packaging: \'" + packaging + "\'.", e ); getLogger().debug( "Lifecycle mappings not found for packaging: \'" + packaging + "\'.", e );
@ -340,11 +340,13 @@ public class DefaultLifecycleExecutor
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
throw new LifecycleExecutionException( "Cannot load plugin which defines lifecycle mappings for: \'" + packaging + "\'.", e ); throw new LifecycleExecutionException(
"Cannot load plugin which defines lifecycle mappings for: \'" + packaging + "\'.", e );
} }
catch ( PluginVersionResolutionException e ) catch ( PluginVersionResolutionException e )
{ {
throw new LifecycleExecutionException( "Cannot load plugin which defines lifecycle mappings for: \'" + packaging + "\'.", e ); throw new LifecycleExecutionException(
"Cannot load plugin which defines lifecycle mappings for: \'" + packaging + "\'.", e );
} }
catch ( PluginManagerException e ) catch ( PluginManagerException e )
{ {
@ -401,8 +403,7 @@ public class DefaultLifecycleExecutor
if ( plugin.getGoals() != null && !plugin.getGoals().isEmpty() ) if ( plugin.getGoals() != null && !plugin.getGoals().isEmpty() )
{ {
getLogger().warn( getLogger().warn(
"DEPRECATED: goal definitions for plugin '" + plugin.getKey() "DEPRECATED: goal definitions for plugin '" + plugin.getKey() + "' must be in an executions element" );
+ "' must be in an executions element" );
} }
PluginDescriptor pluginDescriptor; PluginDescriptor pluginDescriptor;
@ -455,7 +456,8 @@ public class DefaultLifecycleExecutor
/** /**
* @deprecated * @deprecated
*/ */
private void bindGoalMapToLifecycle( PluginDescriptor pluginDescriptor, Map goalMap, Map phaseMap, Settings settings ) private void bindGoalMapToLifecycle( PluginDescriptor pluginDescriptor, Map goalMap, Map phaseMap,
Settings settings )
{ {
for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); ) for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
{ {
@ -479,7 +481,7 @@ public class DefaultLifecycleExecutor
} }
private void bindExecutionToLifecycle( PluginDescriptor pluginDescriptor, Map phaseMap, PluginExecution execution, private void bindExecutionToLifecycle( PluginDescriptor pluginDescriptor, Map phaseMap, PluginExecution execution,
Settings settings ) Settings settings )
throws LifecycleExecutionException throws LifecycleExecutionException
{ {
for ( Iterator i = execution.getGoals().iterator(); i.hasNext(); ) for ( Iterator i = execution.getGoals().iterator(); i.hasNext(); )
@ -510,7 +512,7 @@ public class DefaultLifecycleExecutor
} }
private void addToLifecycleMappings( Map lifecycleMappings, String phase, MojoExecution mojoExecution, private void addToLifecycleMappings( Map lifecycleMappings, String phase, MojoExecution mojoExecution,
Settings settings ) Settings settings )
{ {
List goals = (List) lifecycleMappings.get( phase ); List goals = (List) lifecycleMappings.get( phase );
@ -556,7 +558,7 @@ public class DefaultLifecycleExecutor
private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project ) private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException throws ArtifactResolutionException, LifecycleExecutionException
{ {
String goal = null; String goal;
Plugin plugin = null; Plugin plugin = null;
PluginDescriptor pluginDescriptor = null; PluginDescriptor pluginDescriptor = null;
@ -576,7 +578,8 @@ public class DefaultLifecycleExecutor
} }
catch ( PluginManagerException e ) catch ( PluginManagerException e )
{ {
throw new LifecycleExecutionException( "Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin collector.", e ); throw new LifecycleExecutionException(
"Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin collector.", e );
} }
if ( pluginDescriptor == null ) if ( pluginDescriptor == null )
@ -587,7 +590,8 @@ public class DefaultLifecycleExecutor
} }
catch ( PluginManagerException e ) catch ( PluginManagerException e )
{ {
throw new LifecycleExecutionException( "Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin mappings metadata.", e ); throw new LifecycleExecutionException(
"Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin mappings metadata.", e );
} }
} }
@ -631,8 +635,8 @@ public class DefaultLifecycleExecutor
} }
else else
{ {
String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" +
+ " a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal"; " a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
throw new LifecycleExecutionException( message ); throw new LifecycleExecutionException( message );
} }
@ -640,8 +644,8 @@ public class DefaultLifecycleExecutor
{ {
try try
{ {
pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session.getSettings(), session pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session.getSettings(),
.getLocalRepository() ); session.getLocalRepository() );
} }
catch ( PluginManagerException e ) catch ( PluginManagerException e )
{ {

View File

@ -1165,8 +1165,6 @@
<field> <field>
<name>version</name> <name>version</name>
<version>3.0.0+</version> <version>3.0.0+</version>
<!-- [ jdcasey:01-Feb-2005 ] No longer required. We'll validate after injecting defaults. -->
<!-- required>true</required -->
<description><![CDATA[ <description><![CDATA[
The version of the dependency, e.g. <code>3.2.1</code> The version of the dependency, e.g. <code>3.2.1</code>
]]></description> ]]></description>
@ -1368,12 +1366,14 @@
<version>4.0.0</version> <version>4.0.0</version>
<description><![CDATA[The artifact id of the project to exclude.]]></description> <description><![CDATA[The artifact id of the project to exclude.]]></description>
<type>String</type> <type>String</type>
<required>true</required>
</field> </field>
<field> <field>
<name>groupId</name> <name>groupId</name>
<version>4.0.0</version> <version>4.0.0</version>
<description><![CDATA[The group id of the project to exclude.]]></description> <description><![CDATA[The group id of the project to exclude.]]></description>
<type>String</type> <type>String</type>
<required>true</required>
</field> </field>
</fields> </fields>
</class> </class>
@ -1652,12 +1652,14 @@
<name>artifactId</name> <name>artifactId</name>
<version>4.0.0</version> <version>4.0.0</version>
<description><![CDATA[The artifact id of the project to extend.]]></description> <description><![CDATA[The artifact id of the project to extend.]]></description>
<required>true</required>
<type>String</type> <type>String</type>
</field> </field>
<field> <field>
<name>groupId</name> <name>groupId</name>
<version>4.0.0</version> <version>4.0.0</version>
<description><![CDATA[The group id of the project to extend.]]></description> <description><![CDATA[The group id of the project to extend.]]></description>
<required>true</required>
<type>String</type> <type>String</type>
</field> </field>
<field> <field>
@ -2132,6 +2134,7 @@
<name>groupId</name> <name>groupId</name>
<version>4.0.0</version> <version>4.0.0</version>
<type>String</type> <type>String</type>
<required>true</required>
<defaultValue>org.apache.maven.plugins</defaultValue> <defaultValue>org.apache.maven.plugins</defaultValue>
</field> </field>
<field> <field>
@ -2503,6 +2506,7 @@
<name>groupId</name> <name>groupId</name>
<version>4.0.0</version> <version>4.0.0</version>
<type>String</type> <type>String</type>
<required>true</required>
<defaultValue>org.apache.maven.plugins</defaultValue> <defaultValue>org.apache.maven.plugins</defaultValue>
</field> </field>
<field> <field>

View File

@ -11,6 +11,7 @@ import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
@ -27,20 +28,22 @@ public class DefaultPluginMappingBuilder
private RepositoryMetadataManager repositoryMetadataManager; private RepositoryMetadataManager repositoryMetadataManager;
public PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories, public PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories,
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException throws RepositoryMetadataManagementException, PluginMappingManagementException
{ {
return loadPluginMappings( groupIds, pluginRepositories, localRepository, new PluginMappingManager() ); return loadPluginMappings( groupIds, pluginRepositories, localRepository, new PluginMappingManager() );
} }
public PluginMappingManager refreshPluginMappingManager( PluginMappingManager mappingManager, List pluginRepositories, public PluginMappingManager refreshPluginMappingManager( PluginMappingManager mappingManager,
List pluginRepositories,
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException throws RepositoryMetadataManagementException, PluginMappingManagementException
{ {
// prevent performance drag from abuse of this method. // prevent performance drag from abuse of this method.
if ( mappingManager.isRefreshed() ) if ( mappingManager.isRefreshed() )
{ {
throw new PluginMappingManagementException( "Plugin-mappings have already been refreshed. Cannot re-refresh." ); throw new PluginMappingManagementException(
"Plugin-mappings have already been refreshed. Cannot re-refresh." );
} }
getLogger().info( "Refreshing plugin-mapping metadata..." ); getLogger().info( "Refreshing plugin-mapping metadata..." );
@ -60,45 +63,43 @@ public class DefaultPluginMappingBuilder
mappingManager.markRefreshed(); mappingManager.markRefreshed();
return loadPluginMappings(groupIds, pluginRepositories, localRepository, mappingManager); return loadPluginMappings( groupIds, pluginRepositories, localRepository, mappingManager );
} }
private PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories, private PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories,
ArtifactRepository localRepository, ArtifactRepository localRepository,
PluginMappingManager mappingManager ) PluginMappingManager mappingManager )
throws RepositoryMetadataManagementException, PluginMappingManagementException throws PluginMappingManagementException
{ {
List pluginGroupIds = new ArrayList( groupIds ); List pluginGroupIds = new ArrayList( groupIds );
// TODO: use constant
if ( !pluginGroupIds.contains( "org.apache.maven.plugins" ) ) if ( !pluginGroupIds.contains( "org.apache.maven.plugins" ) )
{ {
pluginGroupIds.add( "org.apache.maven.plugins" ); pluginGroupIds.add( "org.apache.maven.plugins" );
} }
if ( pluginGroupIds != null ) for ( Iterator it = pluginGroupIds.iterator(); it.hasNext(); )
{ {
for ( Iterator it = pluginGroupIds.iterator(); it.hasNext(); ) String groupId = (String) it.next();
try
{ {
String groupId = (String) it.next(); File mappingFile = resolveMappingMetadata( groupId, pluginRepositories, localRepository );
try PluginMap pluginMap = readPluginMap( mappingFile );
if ( pluginMap != null )
{ {
File mappingFile = resolveMappingMetadata( groupId, pluginRepositories, localRepository ); mappingManager.addPluginMap( pluginMap );
PluginMap pluginMap = readPluginMap( mappingFile );
if ( pluginMap != null )
{
mappingManager.addPluginMap( pluginMap );
}
} }
catch ( RepositoryMetadataManagementException e ) }
{ catch ( RepositoryMetadataManagementException e )
getLogger() {
.warn( "Cannot resolve plugin-mapping metadata for groupId: " + groupId + " - IGNORING." ); getLogger()
.warn( "Cannot resolve plugin-mapping metadata for groupId: " + groupId + " - IGNORING." );
getLogger().debug( "Error resolving plugin-mapping metadata for groupId: " + groupId + ".", e ); getLogger().debug( "Error resolving plugin-mapping metadata for groupId: " + groupId + ".", e );
}
} }
} }
@ -121,6 +122,10 @@ public class DefaultPluginMappingBuilder
result = mappingReader.read( fileReader ); result = mappingReader.read( fileReader );
} }
catch ( FileNotFoundException e )
{
throw new PluginMappingManagementException( "Cannot read plugin mappings from: " + mappingFile, e );
}
catch ( IOException e ) catch ( IOException e )
{ {
throw new PluginMappingManagementException( "Cannot read plugin mappings from: " + mappingFile, e ); throw new PluginMappingManagementException( "Cannot read plugin mappings from: " + mappingFile, e );

View File

@ -1,5 +1,21 @@
package org.apache.maven.plugin.mapping; package org.apache.maven.plugin.mapping;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed 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.model.Plugin; import org.apache.maven.model.Plugin;
import java.util.ArrayList; import java.util.ArrayList;
@ -12,9 +28,11 @@ public class PluginMappingManager
{ {
private List mappings = new ArrayList(); private List mappings = new ArrayList();
private boolean refreshed = false;
private boolean refreshed;
private Map pluginDefinitionsByPrefix = new HashMap(); private Map pluginDefinitionsByPrefix = new HashMap();
private Map pluginDefinitionsByPackaging = new HashMap(); private Map pluginDefinitionsByPackaging = new HashMap();
public void addPluginMap( PluginMap pluginMap ) public void addPluginMap( PluginMap pluginMap )
@ -53,8 +71,7 @@ public class PluginMappingManager
public Plugin getByPrefix( String pluginPrefix ) public Plugin getByPrefix( String pluginPrefix )
{ {
synchronized ( this ) synchronized ( this ) {
{
if ( pluginDefinitionsByPrefix == null ) if ( pluginDefinitionsByPrefix == null )
{ {
calculatePluginDefinitionsByPrefix(); calculatePluginDefinitionsByPrefix();
@ -66,8 +83,7 @@ public class PluginMappingManager
public Plugin getByPackaging( String packaging ) public Plugin getByPackaging( String packaging )
{ {
synchronized ( this ) synchronized ( this ) {
{
if ( pluginDefinitionsByPackaging == null ) if ( pluginDefinitionsByPackaging == null )
{ {
calculatePluginDefinitionsByPackaging(); calculatePluginDefinitionsByPackaging();
@ -99,7 +115,8 @@ public class PluginMappingManager
plugin.setArtifactId( artifactId ); plugin.setArtifactId( artifactId );
for ( Iterator packagingIterator = mapping.getPackagingHandlers().iterator(); packagingIterator.hasNext(); ) for ( Iterator packagingIterator = mapping.getPackagingHandlers().iterator();
packagingIterator.hasNext(); )
{ {
String packaging = (String) packagingIterator.next(); String packaging = (String) packagingIterator.next();