diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactStatus.java b/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactStatus.java
deleted file mode 100644
index 80a65f6f6e..0000000000
--- a/maven-compat/src/main/java/org/apache/maven/artifact/ArtifactStatus.java
+++ /dev/null
@@ -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 Brett Porter
- * @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 map;
-
- private ArtifactStatus( String key,
- int rank )
- {
- this.rank = rank;
- this.key = key;
-
- if ( map == null )
- {
- map = new HashMap();
- }
- 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;
- }
-}
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsChangeRequest.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsChangeRequest.java
deleted file mode 100644
index a58d9c9226..0000000000
--- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsChangeRequest.java
+++ /dev/null
@@ -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;
- }
-
-
-}
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsDataSource.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsDataSource.java
deleted file mode 100644
index 0c5c953f0c..0000000000
--- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsDataSource.java
+++ /dev/null
@@ -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 Oleg Gusakov
- */
-
-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;
-}
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
index 11d816510e..e0290ef12d 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
@@ -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();
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
index 206611bcfb..9b93189c1c 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
@@ -89,4 +89,11 @@ public interface WagonManager
throws TransferFailedException, ResourceDoesNotExistException;
Set 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;
+
}
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java
index f480fae5dd..b156fa2822 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.java
@@ -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 Jason van Zyl
- * @version $Id$
+ * @author Jason van Zyl
*/
public class ArtifactNotFoundException
extends AbstractArtifactResolutionException
{
private String downloadUrl;
- protected ArtifactNotFoundException( String message,
- Artifact artifact,
- List remoteRepositories )
+ protected ArtifactNotFoundException( String message, Artifact artifact, List 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 remoteRepositories,
- ResourceDoesNotExistException cause )
+ protected ArtifactNotFoundException( String message, Artifact artifact, List 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 remoteRepositories,
- Throwable cause )
+ public ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List 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 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 remoteRepositories,
- String downloadUrl,
- List path,
- ResourceDoesNotExistException cause )
+ private ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List 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 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;
}
diff --git a/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java
index 3c37c30506..aa41f676f2 100644
--- a/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java
+++ b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java
@@ -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)
+- 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)
-- 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();
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
index 8e3d9f4899..318934dc80 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
@@ -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 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 phasesWithMojosToExecute = new ArrayList();
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 plugins, MavenProject project, ArtifactRepository localRepository )
+ public void populateDefaultConfigurationForPlugins( Collection plugins, ArtifactRepository localRepository, List 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 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() );
}
}
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
index 9729703331..f7d3743802 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
@@ -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 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 plugins, MavenProject project, ArtifactRepository localRepository )
+ void populateDefaultConfigurationForPlugins( Collection plugins, ArtifactRepository localRepository, List remoteRepositories )
throws LifecycleExecutionException;
void execute( MavenSession session );
-
- Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal, MavenProject project, ArtifactRepository localRepository )
- throws LifecycleExecutionException;
}
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsDataSourceException.java b/maven-core/src/main/java/org/apache/maven/plugin/CycleDetectedInPluginGraphException.java
similarity index 56%
rename from maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsDataSourceException.java
rename to maven-core/src/main/java/org/apache/maven/plugin/CycleDetectedInPluginGraphException.java
index ce530752dc..9d99b4f3d6 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/CredentialsDataSourceException.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/CycleDetectedInPluginGraphException.java
@@ -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 Brett Porter
+ * @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 );
- }
-
}
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
index ddbe266767..44f7f727b2 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
@@ -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();
}
- // This should be template method code for allowing subclasses to assist in contributing search/hint information
- public Plugin findPluginForPrefix( String prefix, ArtifactRepository localRepository, List 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 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 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 pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, localRepository, remoteRepositories );
+ Set 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( pluginArtifacts ) );
return pluginDescriptor;
@@ -493,9 +490,19 @@ public class DefaultPluginManager
}
}
- public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository,
- List remoteRepositories )
- throws PluginLoaderException
+ public MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List 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 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;
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorParsingException.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorParsingException.java
new file mode 100644
index 0000000000..5366f4d7a6
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorParsingException.java
@@ -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;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
index 6215ba0586..74fae84f03 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
@@ -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 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 remoteRepositories )
- throws PluginLoaderException;
+ throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException;
+
+ MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List remoteRepositories )
+ throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException;
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List 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;
}
\ No newline at end of file
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginResolutionException.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginResolutionException.java
new file mode 100644
index 0000000000..6615ddbabc
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginResolutionException.java
@@ -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 Brett Porter
+ * @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;
+ }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
index 4f5686b137..d6e20f4d3d 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
@@ -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 )
diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index 0d676dbd04..7c660da216 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -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 );
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
index fa2625f032..a03f10c085 100644
--- a/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
@@ -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 );
}
diff --git a/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java b/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
index 940957e4cd..17f1f9029b 100644
--- a/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
+++ b/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
@@ -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 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 plugins, MavenProject project,
- ArtifactRepository localRepository )
+ public void populateDefaultConfigurationForPlugins( Collection plugins, ArtifactRepository localRepository, List remoteRepositories )
throws LifecycleExecutionException
{
}
-
}
diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoNotFoundException.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoNotFoundException.java
new file mode 100644
index 0000000000..c0a6c69e16
--- /dev/null
+++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoNotFoundException.java
@@ -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;
+ }
+}
diff --git a/maven-repository/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java b/maven-repository/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
index 247df93cd4..83c2133ced 100644
--- a/maven-repository/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
+++ b/maven-repository/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
@@ -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 );
+ }
}
diff --git a/maven-repository/src/main/java/org/apache/maven/repository/RepositorySystem.java b/maven-repository/src/main/java/org/apache/maven/repository/RepositorySystem.java
index 6053147928..a63045e41f 100644
--- a/maven-repository/src/main/java/org/apache/maven/repository/RepositorySystem.java
+++ b/maven-repository/src/main/java/org/apache/maven/repository/RepositorySystem.java
@@ -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 getMirrors( List repositories );
+ List getMirrors( List 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;
}
diff --git a/pom.xml b/pom.xml
index 1abf3dcbf7..4399c247e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@ under the License.
1.0-alpha-9
1.2_Java1.3
3.8.1
- 1.0-beta-3.0.7
+ 1.0-beta-3.0.8-SNAPSHOT
1.1
1.0-alpha-1
1.5.8