o first pass at setting up error handling for each possible error condition

- this resulted in cleaning up some exceptions in plexus so that they might message could be surfaced in Maven
o move the plugin prefix searching to the lifecycle executor and get it out of the plugin manager
o add capability to the RepositorySystem to get plain resources from a repository. I'm going simple with the repository group
  metadata and I will just get the file directly as the only implementation is the plugin group metadata. the system is 
  not easily or generally extensible so i'll just take what I need



git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@776412 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-05-19 18:53:07 +00:00
parent 59224daa9e
commit e0298b7c97
22 changed files with 431 additions and 566 deletions

View File

@ -1,115 +0,0 @@
package org.apache.maven.artifact;
/*
* 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.HashMap;
import java.util.Map;
/**
* Type safe enumeration for the artifact status field.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public final class ArtifactStatus
implements Comparable
{
/** No trust - no information about status. */
public static final ArtifactStatus NONE = new ArtifactStatus( "none", 0 );
/** No trust - information was generated with defaults. */
public static final ArtifactStatus GENERATED = new ArtifactStatus( "generated", 1 );
/** Low trust - was converted from the Maven 1.x repository. */
public static final ArtifactStatus CONVERTED = new ArtifactStatus( "converted", 2 );
/** Moderate trust - it was deployed directly from a partner. */
public static final ArtifactStatus PARTNER = new ArtifactStatus( "partner", 3 );
/** Moderate trust - it was deployed directly by a user. */
public static final ArtifactStatus DEPLOYED = new ArtifactStatus( "deployed", 4 );
/** Trusted, as it has had its data verified by hand. */
public static final ArtifactStatus VERIFIED = new ArtifactStatus( "verified", 5 );
private final int rank;
private final String key;
private static Map<String,ArtifactStatus> map;
private ArtifactStatus( String key,
int rank )
{
this.rank = rank;
this.key = key;
if ( map == null )
{
map = new HashMap<String,ArtifactStatus>();
}
map.put( key, this );
}
public static ArtifactStatus valueOf( String status )
{
ArtifactStatus retVal = null;
if ( status != null )
{
retVal = map.get( status );
}
return retVal != null ? retVal : NONE;
}
public boolean equals( Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
final ArtifactStatus that = (ArtifactStatus) o;
return rank == that.rank;
}
public int hashCode()
{
return rank;
}
public String toString()
{
return key;
}
public int compareTo( Object o )
{
ArtifactStatus s = (ArtifactStatus) o;
return rank - s.rank;
}
}

View File

@ -1,75 +0,0 @@
package org.apache.maven.artifact.manager;
/*
* 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.wagon.authentication.AuthenticationInfo;
public class CredentialsChangeRequest
{
private String resourceId;
private AuthenticationInfo authInfo;
private String oldPassword;
public CredentialsChangeRequest()
{
}
public CredentialsChangeRequest( String resourceId,
AuthenticationInfo authInfo,
String oldPassword )
{
super();
this.resourceId = resourceId;
this.authInfo = authInfo;
this.oldPassword = oldPassword;
}
public String getResourceId()
{
return resourceId;
}
public void setResourceId( String resourceId )
{
this.resourceId = resourceId;
}
public AuthenticationInfo getAuthInfo()
{
return authInfo;
}
public void setAuthInfo( AuthenticationInfo authInfo )
{
this.authInfo = authInfo;
}
public String getOldPassword()
{
return oldPassword;
}
public void setOldPassword( String oldPassword )
{
this.oldPassword = oldPassword;
}
}

View File

@ -1,56 +0,0 @@
package org.apache.maven.artifact.manager;
/*
* 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.wagon.authentication.AuthenticationInfo;
/**
* A wrapper class around setting/retrieving/caching authentication
* info by resource ID. Typical usage - accessing server authentication for
* by it's ID
*
* @author <a href="oleg@codehaus.org">Oleg Gusakov</a>
*/
public interface CredentialsDataSource
{
public static final String ROLE = CredentialsDataSource.class.getName();
/**
* find, if not found, prompt and create Authentication info
* for a given resource
*
* @param resourceId resource ID for which authentication is required
* @return resource AuthenticationInfo. Should always exist.
* @throws CredentialsDataSourceException
*/
AuthenticationInfo get( String resourceId )
throws CredentialsDataSourceException;
/**
* set, if not found, prompt and create Authentication info
* for a given resource. This one uses the old password
* member of AuthenticationInfo
*
* @throws CredentialsDataSourceException
*/
void set( CredentialsChangeRequest req )
throws CredentialsDataSourceException;
}

View File

@ -139,7 +139,7 @@ public class DefaultWagonManager
putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null );
}
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
public void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException
{
String protocol = repository.getProtocol();
@ -427,7 +427,7 @@ public class DefaultWagonManager
getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true );
}
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
public void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
throws TransferFailedException, ResourceDoesNotExistException
{
String protocol = repository.getProtocol();

View File

@ -89,4 +89,11 @@ public interface WagonManager
throws TransferFailedException, ResourceDoesNotExistException;
Set<String> getSupportProtocols();
void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force )
throws TransferFailedException, ResourceDoesNotExistException;
void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException;
}

View File

@ -1,22 +1,18 @@
package org.apache.maven.artifact.resolver;
/*
* 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.
* 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;
@ -26,99 +22,44 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.wagon.ResourceDoesNotExistException;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @author Jason van Zyl
*/
public class ArtifactNotFoundException
extends AbstractArtifactResolutionException
{
private String downloadUrl;
protected ArtifactNotFoundException( String message,
Artifact artifact,
List<ArtifactRepository> remoteRepositories )
protected ArtifactNotFoundException( String message, Artifact artifact, List<ArtifactRepository> remoteRepositories )
{
super( message, artifact, remoteRepositories );
}
public ArtifactNotFoundException( String message,
Artifact artifact )
public ArtifactNotFoundException( String message, Artifact artifact )
{
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact.getDependencyTrail() );
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact
.getDependencyTrail() );
}
protected ArtifactNotFoundException( String message,
Artifact artifact,
List<ArtifactRepository> remoteRepositories,
ResourceDoesNotExistException cause )
protected ArtifactNotFoundException( String message, Artifact artifact, List<ArtifactRepository> remoteRepositories, ResourceDoesNotExistException cause )
{
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
artifact.getClassifier(),
remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), cause );
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), remoteRepositories, artifact.getDownloadUrl(), artifact
.getDependencyTrail(), cause );
}
@Deprecated
protected ArtifactNotFoundException( String message,
Artifact artifact,
List<ArtifactRepository> remoteRepositories,
Throwable cause )
public ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List<ArtifactRepository> remoteRepositories,
String downloadUrl, List path, ResourceDoesNotExistException cause )
{
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
artifact.getClassifier(),
remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), cause );
}
@Deprecated
public ArtifactNotFoundException( String message,
String groupId,
String artifactId,
String version,
String type,
String classifier,
List<ArtifactRepository> remoteRepositories,
String downloadUrl,
List path,
Throwable cause )
{
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier,
downloadUrl, path ), groupId, artifactId,
version, type, classifier, remoteRepositories, null, cause );
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories,
null, cause );
this.downloadUrl = downloadUrl;
}
public ArtifactNotFoundException( String message,
String groupId,
String artifactId,
String version,
String type,
String classifier,
List<ArtifactRepository> remoteRepositories,
String downloadUrl,
List path,
ResourceDoesNotExistException cause )
private ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List<ArtifactRepository> remoteRepositories,
String downloadUrl, List path )
{
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier,
downloadUrl, path ), groupId, artifactId,
version, type, classifier, remoteRepositories, null, cause );
this.downloadUrl = downloadUrl;
}
private ArtifactNotFoundException( String message,
String groupId,
String artifactId,
String version,
String type,
String classifier,
List<ArtifactRepository> remoteRepositories,
String downloadUrl,
List path )
{
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier,
downloadUrl, path ), groupId, artifactId,
version, type, classifier, remoteRepositories, null );
super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories,
null );
this.downloadUrl = downloadUrl;
}

View File

@ -1,13 +1,25 @@
package org.apache.maven.exception;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.MojoNotFoundException;
import org.apache.maven.plugin.PluginDescriptorParsingException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginResolutionException;
import org.codehaus.plexus.component.annotations.Component;
/*
- test projects for each of these
- how to categorize the problems so that the id of the problem can be match to a page with descriptive help and the test project
- nice little sample projects that could be run in the core as well as integration tests
All Possible Errors
- bad command line parameter
- invalid lifecycle phase (maybe same as bad CLI param, though you were talking about embedder too)
- <module> specified is not found
- malformed settings
- malformed POM
- local repository not writable
@ -16,10 +28,16 @@ All Possible Errors
- extension metadata missing
- extension artifact missing
- artifact metadata retrieval problem
- version range violation
- version range violation
- circular dependency
- artifact missing
- artifact retrieval exception
- md5 checksum doesn't match for local artifact, need to redownload this
- POM doesn't exist for a goal that requires one
- parent POM missing (in both the repository + relative path)
- component not found
Plugins:
- plugin metadata missing
- plugin metadata retrieval problem
- plugin artifact missing
@ -29,23 +47,13 @@ All Possible Errors
- plugin configuration problem
- plugin execution failure due to something that is know to possibly go wrong (like compilation failure)
- plugin execution error due to something that is not expected to go wrong (the compiler executable missing)
- md5 checksum doesn't match for local artifact, need to redownload this
- asking to use a plugin for which you do not have a version defined - tools to easily select versions
brett:
- transitive dependency problems - tracking down
- invalid lifecycle phase (maybe same as bad CLI param, though you were talking about embedder too)
- <module> specified is not found
- POM doesn't exist for a goal that requires one
- goal not found in a plugin (probably could list the ones that are)
- parent POM missing (in both the repository + relative path)
brian:
- component not found
- missing goal in plugin
- removing the scripting options from the core
*/
//PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException;
@Component(role=ExceptionHandler.class)
public class DefaultExceptionHandler
implements ExceptionHandler
@ -56,7 +64,40 @@ public class DefaultExceptionHandler
String reference = "http://";
if ( exception instanceof MojoFailureException )
// Plugin problems
if ( exception instanceof PluginNotFoundException )
{
message = exception.getMessage();
}
else if ( exception instanceof PluginResolutionException )
{
message = exception.getMessage();
}
else if ( exception instanceof PluginDescriptorParsingException )
{
message = exception.getMessage();
}
else if ( exception instanceof CycleDetectedInPluginGraphException )
{
message = exception.getMessage();
}
// Project dependency downloading problems.
else if ( exception instanceof ArtifactNotFoundException )
{
message = exception.getMessage();
}
else if ( exception instanceof ArtifactResolutionException )
{
message = ((MojoExecutionException)exception).getLongMessage();
}
// Mojo problems
else if ( exception instanceof MojoNotFoundException )
{
message = exception.getMessage();
}
else if ( exception instanceof MojoFailureException )
{
message = ((MojoFailureException)exception).getLongMessage();
}
@ -64,6 +105,7 @@ public class DefaultExceptionHandler
{
message = ((MojoExecutionException)exception).getLongMessage();
}
else
{
message = exception.getMessage();

View File

@ -39,10 +39,14 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.PluginLoaderException;
import org.apache.maven.plugin.MojoNotFoundException;
import org.apache.maven.plugin.PluginDescriptorParsingException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.plugin.PluginResolutionException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@ -60,9 +64,6 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
//TODO: The configuration for the lifecycle needs to be externalized so that I can use the annotations
// properly for the wiring and reference and external source for the lifecycle configuration.
//TODO: Inside an IDE we are replacing the notion of our reactor with a workspace. In both of these cases
// we need to layer these as local repositories.
//TODO: Cache the lookups of the PluginDescriptors
//TODO: check for online status in the build plan and die if necessary
//TODO if ( mojoDescriptor.isProjectRequired() && !session.isUsingPOMsFromFilesystem() )
//{
@ -125,7 +126,7 @@ public class DefaultLifecycleExecutor
goals = Collections.singletonList( goal );
}
}
for ( MavenProject currentProject : session.getProjects() )
{
logger.info( "Building " + currentProject.getName() );
@ -142,7 +143,7 @@ public class DefaultLifecycleExecutor
{
lifecyclePlan = calculateLifecyclePlan( goal, session );
}
catch ( LifecycleExecutionException e )
catch ( Exception e )
{
session.getResult().addException( e );
return;
@ -157,12 +158,12 @@ public class DefaultLifecycleExecutor
{
downloadProjectDependencies( session, Artifact.SCOPE_TEST /**mojoDescriptor.isDependencyResolutionRequired()*/ );
}
catch ( ArtifactResolutionException e )
catch ( ArtifactNotFoundException e )
{
session.getResult().addException( e );
return;
}
catch ( ArtifactNotFoundException e )
catch ( ArtifactResolutionException e )
{
session.getResult().addException( e );
return;
@ -221,7 +222,7 @@ public class DefaultLifecycleExecutor
// 4. Bind those mojos found in the lifecycle mapping for the packaging to the lifecycle
// 5. Bind mojos specified in the project itself to the lifecycle
public List<MojoExecution> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
throws LifecycleExecutionException
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException
{
// Extract the project from the session
MavenProject project = session.getCurrentProject();
@ -311,18 +312,17 @@ public class DefaultLifecycleExecutor
phaseToMojoMapping.get( execution.getPhase() ).add( s );
}
}
// if not then i need to grab the mojo descriptor and look at
// the phase that is specified
// if not then i need to grab the mojo descriptor and look at the phase that is specified
else
{
for( String goal : execution.getGoals() )
{
String s = plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() + ":" + goal;
MojoDescriptor md = getMojoDescriptor( s, session.getCurrentProject(), session.getLocalRepository() );
MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(), project.getRemoteArtifactRepositories() );
if ( md.getPhase() != null && phaseToMojoMapping.get( md.getPhase() ) != null )
if ( mojoDescriptor.getPhase() != null && phaseToMojoMapping.get( mojoDescriptor.getPhase() ) != null )
{
phaseToMojoMapping.get( md.getPhase() ).add( s );
phaseToMojoMapping.get( mojoDescriptor.getPhase() ).add( s );
}
}
}
@ -334,13 +334,7 @@ public class DefaultLifecycleExecutor
// We are only interested in the phases that correspond to the lifecycle we are trying to run. If we are running the "clean"
// lifecycle we are not interested in goals -- like "generate-sources -- that belong to the default lifecycle.
//
// We only want to execute up to and including the specified lifecycle phase.
// if ( phase.equals( lifecyclePhase ) )
//{
// break;
//}
List<String> phasesWithMojosToExecute = new ArrayList<String>();
for( String phase : phaseToMojoMapping.keySet() )
@ -365,7 +359,10 @@ public class DefaultLifecycleExecutor
//
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
//
MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, project, session.getLocalRepository() );
String[] s = StringUtils.split( mojo, ":" );
MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, session );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
@ -426,12 +423,14 @@ public class DefaultLifecycleExecutor
}
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
MojoDescriptor getMojoDescriptor( String task, MavenProject project, ArtifactRepository localRepository )
throws LifecycleExecutionException
MojoDescriptor getMojoDescriptor( String task, MavenSession session )
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException
{
String goal;
MavenProject project = session.getCurrentProject();
Plugin plugin;
String goal = null;
Plugin plugin = null;
StringTokenizer tok = new StringTokenizer( task, ":" );
int numTokens = tok.countTokens();
@ -450,30 +449,7 @@ public class DefaultLifecycleExecutor
// Maven plugin deployment we will find the right PluginDescriptor from the remote
// repository.
plugin = pluginManager.findPluginForPrefix( prefix, localRepository, project.getRemoteArtifactRepositories() );
// Search plugin in the current POM
if ( plugin == null )
{
for ( Plugin buildPlugin : project.getBuildPlugins() )
{
PluginDescriptor desc;
try
{
desc = pluginManager.loadPlugin( buildPlugin, localRepository, project.getRemoteArtifactRepositories() );
}
catch ( PluginLoaderException e )
{
throw new LifecycleExecutionException( "Error loading PluginDescriptor.", e );
}
if ( prefix.equals( desc.getGoalPrefix() ) )
{
plugin = buildPlugin;
}
}
}
plugin = findPluginForPrefix( prefix, session );
}
else if ( numTokens == 3 || numTokens == 4 )
{
@ -488,63 +464,10 @@ public class DefaultLifecycleExecutor
goal = tok.nextToken();
}
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";
throw new LifecycleExecutionException( message );
}
for ( Plugin buildPlugin : project.getBuildPlugins() )
{
if ( buildPlugin.getKey().equals( plugin.getKey() ) )
{
if ( plugin.getVersion() == null || plugin.getVersion().equals( buildPlugin.getVersion() ) )
{
plugin = buildPlugin;
}
break;
}
}
MojoDescriptor mojoDescriptor;
try
{
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, localRepository, project.getRemoteArtifactRepositories() );
}
catch ( PluginLoaderException e )
{
throw new LifecycleExecutionException( "Error loading MojoDescriptor.", e );
}
return mojoDescriptor;
return pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(), project.getRemoteArtifactRepositories() );
}
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, MavenProject project, ArtifactRepository localRepository )
throws LifecycleExecutionException
{
Plugin plugin = new Plugin();
plugin.setGroupId( groupId );
plugin.setArtifactId( artifactId );
plugin.setVersion( version );
MojoDescriptor mojoDescriptor;
//need to do the active project thing as the site plugin is referencing itself
try
{
mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, localRepository, project.getRemoteArtifactRepositories() );
}
catch ( PluginLoaderException e )
{
throw new LifecycleExecutionException( "Error loading MojoDescriptor.", e );
}
return mojoDescriptor;
}
public void initialize()
throws InitializationException
{
@ -660,7 +583,7 @@ public class DefaultLifecycleExecutor
}
}
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, MavenProject project, ArtifactRepository localRepository )
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws LifecycleExecutionException
{
for( Plugin p : plugins )
@ -669,25 +592,51 @@ public class DefaultLifecycleExecutor
{
for( String goal : e.getGoals() )
{
Xpp3Dom dom = getDefaultPluginConfiguration( p.getGroupId(), p.getArtifactId(), p.getVersion(), goal, project, localRepository );
Xpp3Dom dom = getDefaultPluginConfiguration( p.getGroupId(), p.getArtifactId(), p.getVersion(), goal, localRepository, remoteRepositories );
e.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) e.getConfiguration(), dom, Boolean.TRUE ) );
}
}
}
}
public Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, MavenProject project, ArtifactRepository localRepository )
private Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws LifecycleExecutionException
{
return convert( getMojoDescriptor( groupId, artifactId, version, goal, project, localRepository ) );
MojoDescriptor mojoDescriptor;
try
{
mojoDescriptor = pluginManager.getMojoDescriptor( groupId, artifactId, version, goal, localRepository, remoteRepositories );
}
catch ( PluginNotFoundException e )
{
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
}
catch ( PluginResolutionException e )
{
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
}
catch ( PluginDescriptorParsingException e )
{
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
}
catch ( CycleDetectedInPluginGraphException e )
{
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
}
catch ( MojoNotFoundException e )
{
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
}
return convert( mojoDescriptor );
}
public Xpp3Dom getMojoConfiguration( MojoDescriptor mojoDescriptor )
{
return convert( mojoDescriptor );
}
Xpp3Dom convert( MojoDescriptor mojoDescriptor )
{
Xpp3Dom dom = new Xpp3Dom( "configuration" );
@ -988,5 +937,17 @@ public class DefaultLifecycleExecutor
ArtifactResolutionResult result = repositorySystem.resolve( request );
resolutionErrorHandler.throwErrors( request, result );
project.setArtifacts( result.getArtifacts() );
}
// This would ideally be kept up
public Plugin findPluginForPrefix( String prefix, MavenSession session )
{
// [prefix]:[goal]
//
// eclipse:eclipse
// idea:idea
return null;
//return getByPrefix( prefix, session.getPluginGroups(), project.getRemoteArtifactRepositories(), session.getLocalRepository() );
}
}

View File

@ -26,9 +26,14 @@ import java.util.Set;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.MojoNotFoundException;
import org.apache.maven.plugin.PluginDescriptorParsingException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginResolutionException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@ -48,7 +53,7 @@ public interface LifecycleExecutor
* @throws LifecycleExecutionException
*/
List<MojoExecution> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
throws LifecycleExecutionException;
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException;
// 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
@ -64,11 +69,8 @@ public interface LifecycleExecutor
// Given a set of {@link org.apache.maven.Plugin} objects where the GAV is set we can lookup the plugin
// descriptor and populate the default configuration.
//
void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, MavenProject project, ArtifactRepository localRepository )
void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws LifecycleExecutionException;
void execute( MavenSession session );
Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, MavenProject project, ArtifactRepository localRepository )
throws LifecycleExecutionException;
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.artifact.manager;
package org.apache.maven.plugin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -19,28 +19,29 @@ package org.apache.maven.artifact.manager;
* under the License.
*/
public class CredentialsDataSourceException
import org.apache.maven.model.Plugin;
import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException;
/**
* Exception occurring trying to resolve a plugin.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class CycleDetectedInPluginGraphException
extends Exception
{
private final Plugin plugin;
public CredentialsDataSourceException()
public CycleDetectedInPluginGraphException( Plugin plugin, CycleDetectedInComponentGraphException e )
{
super( "A cycle was detected in the component graph of the plugin: " + plugin.getArtifactId() );
this.plugin = plugin;
}
public CredentialsDataSourceException( String message )
public Plugin getPlugin()
{
super( message );
return plugin;
}
public CredentialsDataSourceException( Throwable cause )
{
super( cause );
}
public CredentialsDataSourceException( String message,
Throwable cause )
{
super( message, cause );
}
}

View File

@ -55,6 +55,7 @@ import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.codehaus.plexus.component.configurator.ComponentConfigurator;
import org.codehaus.plexus.component.configurator.ConfigurationListener;
@ -66,7 +67,6 @@ import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
@ -114,17 +114,25 @@ public class DefaultPluginManager
pluginDescriptors = new HashMap<String, PluginDescriptor>();
}
// This should be template method code for allowing subclasses to assist in contributing search/hint information
public Plugin findPluginForPrefix( String prefix, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
private String pluginKey( Plugin plugin )
{
//Use the plugin managers capabilities to get information to augement the request
return null;
//return getByPrefix( prefix, session.getPluginGroups(), project.getRemoteArtifactRepositories(), session.getLocalRepository() );
return plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion();
}
/**
*
* @param plugin
* @param localRepository
* @param remoteRepositories
* @return PluginDescriptor The component descriptor for the Maven plugin.
* @throws PluginNotFoundException The plugin could not be found in any repositories.
* @throws PluginResolutionException The plugin could be found but could not be resolved.
* @throws PlexusConfigurationException A discovered component descriptor cannot be read, or or can't be parsed correctly. Shouldn't
* happen but if someone has made a descriptor by hand it's possible.
* @throws CycleDetectedInComponentGraphException A cycle has been detected in the component graph for a plugin that has been dynamically loaded.
*/
public PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws PluginLoaderException
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException
{
PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );
@ -133,40 +141,8 @@ public class DefaultPluginManager
if ( pluginDescriptor != null && pluginDescriptor.getClassRealm() != null )
{
return pluginDescriptor;
}
try
{
return addPlugin( plugin, localRepository, remoteRepositories );
}
catch ( ArtifactResolutionException e )
// PluginResolutionException - a problem that occurs resolving the plugin artifact or its deps
{
throw new PluginLoaderException( plugin, "Failed to load plugin. Reason: " + e.getMessage(), e );
}
catch ( ArtifactNotFoundException e )
// PluginNotFoundException - the plugin itself cannot be found in any repositories
{
throw new PluginLoaderException( plugin, "Failed to load plugin. Reason: " + e.getMessage(), e );
}
catch ( PluginContainerException 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 );
}
}
private String pluginKey( Plugin plugin )
{
return plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion();
}
protected PluginDescriptor addPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactNotFoundException, ArtifactResolutionException, PluginContainerException, PluginVersionNotFoundException
{
}
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin );
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
@ -176,7 +152,15 @@ public class DefaultPluginManager
ArtifactResolutionResult result = repositorySystem.resolve( request );
resolutionErrorHandler.throwErrors( request, result );
try
{
resolutionErrorHandler.throwErrors( request, result );
}
catch ( ArtifactResolutionException e )
{
throw new PluginResolutionException( plugin, e );
}
ClassRealm pluginRealm = pluginClassLoaderCache.get( constructPluginKey( plugin ) );
@ -187,7 +171,20 @@ public class DefaultPluginManager
pluginRealm = container.createChildRealm( pluginKey( plugin ) );
Set<Artifact> pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, localRepository, remoteRepositories );
Set<Artifact> pluginArtifacts;
try
{
pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, localRepository, remoteRepositories );
}
catch ( ArtifactNotFoundException e )
{
throw new PluginNotFoundException( plugin, e );
}
catch ( ArtifactResolutionException e )
{
throw new PluginResolutionException( plugin, e );
}
for ( Artifact a : pluginArtifacts )
{
@ -200,23 +197,23 @@ public class DefaultPluginManager
// Not going to happen
}
}
try
{
container.discoverComponents( pluginRealm );
}
catch ( PlexusConfigurationException e )
{
throw new PluginContainerException( plugin, pluginRealm, "Error scanning plugin realm for components.", e );
throw new PluginDescriptorParsingException( plugin, e );
}
catch ( ComponentRepositoryException e )
catch ( CycleDetectedInComponentGraphException e )
{
throw new PluginContainerException( plugin, pluginRealm, "Error scanning plugin realm for components.", e );
throw new CycleDetectedInPluginGraphException( plugin, e );
}
pluginClassLoaderCache.put( constructPluginKey( plugin ), pluginRealm );
PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );
pluginDescriptor = getPluginDescriptor( plugin );
pluginDescriptor.setArtifacts( new ArrayList<Artifact>( pluginArtifacts ) );
return pluginDescriptor;
@ -493,9 +490,19 @@ public class DefaultPluginManager
}
}
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws PluginLoaderException
public MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException
{
Plugin plugin = new Plugin();
plugin.setGroupId( groupId );
plugin.setArtifactId( artifactId );
plugin.setVersion( version );
return getMojoDescriptor( plugin, goal, localRepository, remoteRepositories );
}
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException
{
PluginDescriptor pluginDescriptor = loadPlugin( plugin, localRepository, remoteRepositories );
@ -503,7 +510,7 @@ public class DefaultPluginManager
if ( mojoDescriptor == null )
{
throw new PluginLoaderException( plugin, "Failed to load plugin mojo. Reason: Unknown mojo: " + goal );
throw new MojoNotFoundException( goal, pluginDescriptor );
}
return mojoDescriptor;

View File

@ -0,0 +1,42 @@
package org.apache.maven.plugin;
/*
* 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.model.Plugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
/**
* @author Jason van Zyl
*/
public class PluginDescriptorParsingException
extends Exception
{
private Plugin plugin;
public PluginDescriptorParsingException( Plugin plugin, PlexusConfigurationException e )
{
super( e );
this.plugin = plugin;
}
}

View File

@ -18,12 +18,16 @@ package org.apache.maven.plugin;
import java.util.List;
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.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException;
import org.codehaus.plexus.component.discovery.ComponentDiscoverer;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
/**
* @author Jason van Zyl
@ -33,17 +37,24 @@ public interface PluginManager
{
// - find the plugin [extension point: any client may wish to do whatever they choose]
// - load the plugin into a classloader [extension point: we want to take them from a repository, some may take from disk or whatever]
// - configure the plugin [extension point]
// - configure the plugin [extension point] -- actually this should happen before the plugin manager gets anything i.e. do whatever you want to get the information
// - execute the plugin
Plugin findPluginForPrefix( String prefix, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories );
// Use more meaningful exceptions
// plugin not found
// plugin resolution exception
// plugin configuration can't be parsed -- and this may be a result of client insertion of configuration
// plugin component deps have a cycle -- this should be prevented for the most part but client code may inject an override component which itself has a cycle
PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws PluginLoaderException;
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException;
MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException;
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws PluginLoaderException;
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException;
// Why do we have a plugin execution exception as well?
void executeMojo( MavenSession session, MojoExecution execution )
throws MojoFailureException, MojoExecutionException, PluginConfigurationException, PluginExecutionException;
}

View File

@ -0,0 +1,48 @@
package org.apache.maven.plugin;
/*
* 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.resolver.AbstractArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.model.Plugin;
/**
* Exception occurring trying to resolve a plugin.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class PluginResolutionException
extends AbstractArtifactResolutionException
{
private final Plugin plugin;
public PluginResolutionException( Plugin plugin, ArtifactResolutionException e )
{
super( "Plugin could not be resolved: " + e.getMessage(), e.getGroupId(), e.getArtifactId(), e.getVersion(), "maven-plugin",null, e.getRemoteRepositories(), null, e.getCause() );
this.plugin = plugin;
}
public Plugin getPlugin()
{
return plugin;
}
}

View File

@ -192,7 +192,7 @@ public class DefaultMavenProjectBuilder
{
pluginConfigurationExpander.expandPluginConfiguration( project.getModel() );
lifecycle.populateDefaultConfigurationForPlugins( project.getModel().getBuild().getPlugins(), project, configuration.getLocalRepository() );
lifecycle.populateDefaultConfigurationForPlugins( project.getModel().getBuild().getPlugins(), configuration.getLocalRepository(), project.getRemoteArtifactRepositories() );
}
}
catch ( IOException e )

View File

@ -587,17 +587,13 @@ public class MavenProject
list.add( getBuild().getTestOutputDirectory() );
list.add( getBuild().getOutputDirectory() );
System.out.println( ">>>>> " + getArtifacts() );
for ( Artifact a : getArtifacts() )
{
if ( a.getArtifactHandler().isAddedToClasspath() )
{
File file = a.getFile();
System.out.println( ">> " + a.getArtifactId() );
if ( file == null )
{
throw new DependencyResolutionRequiredException( a );

View File

@ -6,7 +6,6 @@ import java.util.List;
import org.apache.maven.AbstractCoreMavenComponentTestCase;
import org.apache.maven.exception.ExceptionHandler;
import org.apache.maven.exception.ExceptionSummary;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
@ -93,7 +92,7 @@ public class LifecycleExecutorTest
{
File pom = getProject( "project-with-additional-lifecycle-elements" );
MavenSession session = createMavenSession( pom );
MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( "org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process", session.getCurrentProject(), session.getLocalRepository() );
MojoDescriptor mojoDescriptor = lifecycleExecutor.getMojoDescriptor( "org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process", session );
Xpp3Dom dom = lifecycleExecutor.convert( mojoDescriptor );
System.out.println( dom );
}

View File

@ -29,9 +29,14 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.MojoNotFoundException;
import org.apache.maven.plugin.PluginDescriptorParsingException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginResolutionException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
@ -45,7 +50,7 @@ public class EmptyLifecycleExecutor
{
public List<MojoExecution> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
throws LifecycleExecutionException
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException
{
return Collections.emptyList();
}
@ -71,10 +76,8 @@ public class EmptyLifecycleExecutor
return Collections.emptySet();
}
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, MavenProject project,
ArtifactRepository localRepository )
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws LifecycleExecutionException
{
}
}

View File

@ -0,0 +1,27 @@
package org.apache.maven.plugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
public class MojoNotFoundException
extends Exception
{
private String goal;
private PluginDescriptor pluginDescriptor;
public MojoNotFoundException( String goal, PluginDescriptor pluginDescriptor )
{
this.goal = goal;
this.pluginDescriptor = pluginDescriptor;
}
public String getGoal()
{
return goal;
}
public PluginDescriptor getPluginDescriptor()
{
return pluginDescriptor;
}
}

View File

@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
@ -38,7 +39,10 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.RepositoryPermissions;
import org.codehaus.plexus.component.annotations.Component;
@ -66,6 +70,9 @@ public class LegacyRepositorySystem
@Requirement
private MirrorBuilder mirrorBuilder;
@Requirement
private WagonManager wagonManager;
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
{
return artifactFactory.createArtifact( groupId, artifactId, version, scope, type );
@ -347,4 +354,16 @@ public class LegacyRepositorySystem
// ArtifactResolutionResult result = artifactCollector.
return null;
}
public void retrieve( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException, ResourceDoesNotExistException
{
wagonManager.getRemoteFile( repository, destination, remotePath, downloadMonitor, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, true );
}
public void publish( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException
{
wagonManager.putRemoteFile( repository, source, remotePath, downloadMonitor );
}
}

View File

@ -16,9 +16,7 @@ package org.apache.maven.repository;
*/
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
@ -28,6 +26,9 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.events.TransferListener;
/**
* @author Jason van Zyl
@ -72,19 +73,23 @@ public interface RepositorySystem
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
/**
* this is the new metadata-based entry point into repository system. By default - it will transitively resolve metadata
* for the supplied root GAV and return a flat set of dependency metadatas. Tweaking the request allows user to ask for
* various formats of the response - resolved tree, resolved graph or dirty tree. Only the resolved tree is implemented now
* in MercuryRepositorySystem, LegacyRepositorySystem ignores this call for now.
*
* @param request - supplies all necessary details for the resolution configuration
* @return
*/
MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );
//TODO: remove the request should already be processed to select the mirror for the request instead of the processing happen internally.
// Mirrors
void addMirror( String id, String mirrorOf, String url );
List<ArtifactRepository> getMirrors( List<ArtifactRepository> repositories );
List<ArtifactRepository> getMirrors( List<ArtifactRepository> repositories );
// Install
// Deploy
// Map types of artifacts
// Raw file transfers
void publish( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException;
void retrieve( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor )
throws TransferFailedException, ResourceDoesNotExistException;
}

View File

@ -51,7 +51,7 @@ under the License.
<doxiaVersion>1.0-alpha-9</doxiaVersion>
<easyMockVersion>1.2_Java1.3</easyMockVersion>
<junitVersion>3.8.1</junitVersion>
<plexusVersion>1.0-beta-3.0.7</plexusVersion>
<plexusVersion>1.0-beta-3.0.8-SNAPSHOT</plexusVersion>
<plexusInterpolationVersion>1.1</plexusInterpolationVersion>
<plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>
<plexusUtilsVersion>1.5.8</plexusUtilsVersion>