mirror of
https://github.com/apache/maven.git
synced 2025-02-23 02:15:50 +00:00
clean up exceptions
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163443 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
99219164fa
commit
418aa443dd
@ -40,8 +40,10 @@
|
||||
import org.codehaus.plexus.i18n.I18N;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
@ -149,7 +151,15 @@ public MavenExecutionResponse handleReactor( MavenReactorExecutionRequest reques
|
||||
|
||||
projects = projectBuilder.getSortedProjects( projects );
|
||||
}
|
||||
catch ( Exception e )
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
||||
}
|
||||
catch ( CycleDetectedException e )
|
||||
{
|
||||
throw new ReactorException( "Error processing projects for the reactor: ", e );
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@ -320,7 +321,7 @@ protected static Properties getMavenProperties( File mavenHomeLocal )
|
||||
{
|
||||
mavenProperties.load( new FileInputStream( mavenPropertiesFile ) );
|
||||
}
|
||||
catch ( Exception e )
|
||||
catch ( IOException e )
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -143,6 +143,7 @@ public Object lookup( String role, String roleHint )
|
||||
return container.lookup( role, roleHint );
|
||||
}
|
||||
|
||||
// TODO: can remove when phases are gone
|
||||
public void release( Object component )
|
||||
{
|
||||
if ( component != null )
|
||||
|
@ -89,6 +89,7 @@ public Object lookup( String role, String hint )
|
||||
return session.lookup( role, hint );
|
||||
}
|
||||
|
||||
// TODO: can remove when phases are gone
|
||||
public void release( Object component )
|
||||
{
|
||||
session.release( component );
|
||||
|
@ -233,15 +233,11 @@ protected void addPlugin( Artifact pluginArtifact, MavenSession session )
|
||||
|
||||
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE );
|
||||
|
||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver,
|
||||
mavenProjectBuilder );
|
||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
||||
|
||||
( (ArtifactEnabledContainer) container ).addComponent( pluginArtifact,
|
||||
artifactResolver,
|
||||
remotePluginRepositories,
|
||||
session.getLocalRepository(),
|
||||
metadataSource,
|
||||
artifactFilter );
|
||||
( (ArtifactEnabledContainer) container ).addComponent( pluginArtifact, artifactResolver,
|
||||
remotePluginRepositories, session.getLocalRepository(),
|
||||
metadataSource, artifactFilter );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@ -267,14 +263,21 @@ public PluginExecutionResponse executeMojo( MavenSession session, String goalNam
|
||||
MojoDescriptor mojoDescriptor = getMojoDescriptor( goalName );
|
||||
if ( mojoDescriptor == null )
|
||||
{
|
||||
throw new GoalExecutionException( "Unable to find goal: " + goalName );
|
||||
throw new GoalExecutionException( "Unable to find goal: " + goalName );
|
||||
}
|
||||
|
||||
if ( mojoDescriptor.requiresDependencyResolution() )
|
||||
try
|
||||
{
|
||||
resolveTransitiveDependencies( session );
|
||||
if ( mojoDescriptor.requiresDependencyResolution() )
|
||||
{
|
||||
resolveTransitiveDependencies( session );
|
||||
|
||||
downloadDependencies( session );
|
||||
downloadDependencies( session );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new GoalExecutionException( "Unable to resolve required dependencies for goal", e );
|
||||
}
|
||||
|
||||
try
|
||||
@ -434,10 +437,8 @@ public static String createPluginParameterRequiredMessage( MojoDescriptor mojo,
|
||||
{
|
||||
StringBuffer message = new StringBuffer();
|
||||
|
||||
message.append( "The '" + parameter.getName() ).
|
||||
append( "' parameter is required for the execution of the " ).
|
||||
append( mojo.getId() ).
|
||||
append( " mojo and cannot be null." );
|
||||
message.append( "The '" + parameter.getName() ).append( "' parameter is required for the execution of the " ).append(
|
||||
mojo.getId() ).append( " mojo and cannot be null." );
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
@ -456,17 +457,10 @@ public void contextualize( Context context )
|
||||
public void initialize()
|
||||
throws Exception
|
||||
{
|
||||
artifactFilter = new ExclusionSetFilter( new String[]
|
||||
{
|
||||
"maven-core",
|
||||
"maven-artifact",
|
||||
"maven-model",
|
||||
"maven-plugin",
|
||||
"plexus-container-api",
|
||||
"plexus-container-default",
|
||||
"plexus-artifact-container",
|
||||
"classworlds"
|
||||
} );
|
||||
artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact", "maven-model",
|
||||
"maven-plugin", "plexus-container-api",
|
||||
"plexus-container-default", "plexus-artifact-container",
|
||||
"classworlds"} );
|
||||
|
||||
// TODO: move this to be configurable from the Maven component
|
||||
remotePluginRepositories = new HashSet();
|
||||
@ -480,26 +474,18 @@ public void initialize()
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private void resolveTransitiveDependencies( MavenSession context )
|
||||
throws GoalExecutionException
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
MavenProject project = context.getProject();
|
||||
|
||||
try
|
||||
{
|
||||
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
||||
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
||||
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
|
||||
context.getRemoteRepositories(),
|
||||
context.getLocalRepository(),
|
||||
sourceReader );
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
|
||||
context.getRemoteRepositories(),
|
||||
context.getLocalRepository(),
|
||||
sourceReader );
|
||||
|
||||
project.getArtifacts().addAll( result.getArtifacts().values() );
|
||||
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new GoalExecutionException( "Error resolving transitive dependencies.", e );
|
||||
}
|
||||
project.getArtifacts().addAll( result.getArtifacts().values() );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@ -515,9 +501,7 @@ private void downloadDependencies( MavenSession context )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
|
||||
artifactResolver.resolve( artifact,
|
||||
context.getRemoteRepositories(),
|
||||
context.getLocalRepository() );
|
||||
artifactResolver.resolve( artifact, context.getRemoteRepositories(), context.getLocalRepository() );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
|
@ -41,6 +41,7 @@
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
import org.codehaus.plexus.util.dag.DAG;
|
||||
import org.codehaus.plexus.util.dag.TopologicalSorter;
|
||||
|
||||
@ -285,7 +286,7 @@ private File findParentModel( Parent parent, Set remoteArtifactRepositories, Art
|
||||
* </ul>
|
||||
*/
|
||||
public List getSortedProjects( List projects )
|
||||
throws Exception
|
||||
throws CycleDetectedException
|
||||
{
|
||||
DAG dag = new DAG();
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -35,5 +36,5 @@ MavenProject build( File project, ArtifactRepository localRepository, boolean tr
|
||||
// take this out
|
||||
|
||||
List getSortedProjects( List projects )
|
||||
throws Exception;
|
||||
throws CycleDetectedException;
|
||||
}
|
||||
|
@ -226,18 +226,4 @@ public void setExecutionStrategy( String executionStrategy )
|
||||
{
|
||||
this.executionStrategy = executionStrategy;
|
||||
}
|
||||
|
||||
public MojoDescriptor copy()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (MojoDescriptor) this.clone();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// TODO: this needs better handling
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user