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.codehaus.plexus.component.repository.exception.ComponentLookupException;
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.pull.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
@ -126,8 +126,7 @@ public class DefaultLifecycleExecutor
}
private void executeGoal( String task, MavenSession session, MavenProject project )
throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException,
ArtifactResolutionException
throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException, ArtifactResolutionException
{
if ( phases.contains( task ) )
{
@ -142,7 +141,7 @@ public class DefaultLifecycleExecutor
}
private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
MavenProject project )
MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException
{
List goals = processGoalChain( task, lifecycleMappings );
@ -224,7 +223,8 @@ public class DefaultLifecycleExecutor
String goal = (String) k.next();
MojoDescriptor desc = mojoDescriptor.getPluginDescriptor().getMojo( goal );
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 );
LifecycleMapping m = null;
LifecycleMapping m;
if ( pluginContainingLifecycleMapping != null )
{
try
{
pluginManager.verifyPlugin( pluginContainingLifecycleMapping, project, session.getSettings(), session.getLocalRepository() );
pluginManager.verifyPlugin( pluginContainingLifecycleMapping, project, session.getSettings(),
session.getLocalRepository() );
m = (LifecycleMapping) pluginManager.getPluginComponent( pluginContainingLifecycleMapping,
LifecycleMapping.ROLE, packaging );
@ -313,9 +314,9 @@ public class DefaultLifecycleExecutor
}
catch ( ComponentLookupException e )
{
throw new LifecycleExecutionException( "Plugin: " + pluginContainingLifecycleMapping.getKey()
+ " declares lifecycle mapping for: \'" + packaging
+ "\', but does not appear to contain the actual mapping among its component descriptors.", e );
throw new LifecycleExecutionException( "Plugin: " + pluginContainingLifecycleMapping.getKey() +
" declares lifecycle mapping for: \'" + packaging +
"\', but does not appear to contain the actual mapping among its component descriptors.", e );
}
}
else
@ -329,8 +330,7 @@ public class DefaultLifecycleExecutor
catch ( ComponentLookupException e )
{
getLogger().warn(
"Lifecycle mappings not found for packaging: \'" + packaging
+ "\'. Using defaults." );
"Lifecycle mappings not found for packaging: \'" + packaging + "\'. Using defaults." );
getLogger().debug( "Lifecycle mappings not found for packaging: \'" + packaging + "\'.", e );
@ -340,11 +340,13 @@ public class DefaultLifecycleExecutor
}
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 )
{
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 )
{
@ -401,8 +403,7 @@ public class DefaultLifecycleExecutor
if ( plugin.getGoals() != null && !plugin.getGoals().isEmpty() )
{
getLogger().warn(
"DEPRECATED: goal definitions for plugin '" + plugin.getKey()
+ "' must be in an executions element" );
"DEPRECATED: goal definitions for plugin '" + plugin.getKey() + "' must be in an executions element" );
}
PluginDescriptor pluginDescriptor;
@ -455,7 +456,8 @@ public class DefaultLifecycleExecutor
/**
* @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(); )
{
@ -479,7 +481,7 @@ public class DefaultLifecycleExecutor
}
private void bindExecutionToLifecycle( PluginDescriptor pluginDescriptor, Map phaseMap, PluginExecution execution,
Settings settings )
Settings settings )
throws LifecycleExecutionException
{
for ( Iterator i = execution.getGoals().iterator(); i.hasNext(); )
@ -510,7 +512,7 @@ public class DefaultLifecycleExecutor
}
private void addToLifecycleMappings( Map lifecycleMappings, String phase, MojoExecution mojoExecution,
Settings settings )
Settings settings )
{
List goals = (List) lifecycleMappings.get( phase );
@ -556,7 +558,7 @@ public class DefaultLifecycleExecutor
private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException
{
String goal = null;
String goal;
Plugin plugin = null;
PluginDescriptor pluginDescriptor = null;
@ -576,7 +578,8 @@ public class DefaultLifecycleExecutor
}
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 )
@ -587,7 +590,8 @@ public class DefaultLifecycleExecutor
}
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
{
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";
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";
throw new LifecycleExecutionException( message );
}
@ -640,8 +644,8 @@ public class DefaultLifecycleExecutor
{
try
{
pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session.getSettings(), session
.getLocalRepository() );
pluginDescriptor = pluginManager.verifyPlugin( plugin, project, session.getSettings(),
session.getLocalRepository() );
}
catch ( PluginManagerException e )
{

View File

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

View File

@ -11,6 +11,7 @@ import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
@ -27,20 +28,22 @@ public class DefaultPluginMappingBuilder
private RepositoryMetadataManager repositoryMetadataManager;
public PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories,
ArtifactRepository localRepository )
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException
{
return loadPluginMappings( groupIds, pluginRepositories, localRepository, new PluginMappingManager() );
}
public PluginMappingManager refreshPluginMappingManager( PluginMappingManager mappingManager, List pluginRepositories,
public PluginMappingManager refreshPluginMappingManager( PluginMappingManager mappingManager,
List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException, PluginMappingManagementException
{
// prevent performance drag from abuse of this method.
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..." );
@ -60,45 +63,43 @@ public class DefaultPluginMappingBuilder
mappingManager.markRefreshed();
return loadPluginMappings(groupIds, pluginRepositories, localRepository, mappingManager);
return loadPluginMappings( groupIds, pluginRepositories, localRepository, mappingManager );
}
private PluginMappingManager loadPluginMappings( List groupIds, List pluginRepositories,
ArtifactRepository localRepository,
PluginMappingManager mappingManager )
throws RepositoryMetadataManagementException, PluginMappingManagementException
ArtifactRepository localRepository,
PluginMappingManager mappingManager )
throws PluginMappingManagementException
{
List pluginGroupIds = new ArrayList( groupIds );
// TODO: use constant
if ( !pluginGroupIds.contains( "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 );
PluginMap pluginMap = readPluginMap( mappingFile );
if ( pluginMap != null )
{
mappingManager.addPluginMap( pluginMap );
}
mappingManager.addPluginMap( pluginMap );
}
catch ( RepositoryMetadataManagementException e )
{
getLogger()
.warn( "Cannot resolve plugin-mapping metadata for groupId: " + groupId + " - IGNORING." );
}
catch ( RepositoryMetadataManagementException e )
{
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 );
}
catch ( FileNotFoundException e )
{
throw new PluginMappingManagementException( "Cannot read plugin mappings from: " + mappingFile, e );
}
catch ( IOException e )
{
throw new PluginMappingManagementException( "Cannot read plugin mappings from: " + mappingFile, e );

View File

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