Author: brianf Date: Wed Mar 26 20:21:55 2008 New Revision: 641701 URL: http://svn.apache.org/viewvc?rev=641701&view=rev Log: MNG-3119: reverting the jira due to issues with forked lifecycles
Removed: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DuplicateArtifactAttachmentException.java maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectHelperTest.java Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=641701&r1=641700&r2=641701&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original) +++ maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Wed Mar 26 20:21:55 2008 @@ -20,6 +20,20 @@ * under the License. */ +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.apache.maven.MavenArtifactFilterManager; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -52,7 +66,6 @@ import org.apache.maven.plugin.version.PluginVersionManager; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.project.DuplicateArtifactAttachmentException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; @@ -83,20 +96,6 @@ import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - public class DefaultPluginManager extends AbstractLogEnabled implements PluginManager, Initializable, Contextualizable @@ -453,12 +452,6 @@ dispatcher.dispatchEnd( event, goalExecId ); } - catch ( DuplicateArtifactAttachmentException e ) - { - session.getEventDispatcher().dispatchError( event, goalExecId, e ); - - throw new MojoExecutionException( "Error attaching artifact to project: Duplicate attachment.", e ); - } catch ( MojoExecutionException e ) { session.getEventDispatcher().dispatchError( event, goalExecId, e ); @@ -1415,7 +1408,7 @@ { project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) ); } - + Set resolvedArtifacts; try { @@ -1430,7 +1423,7 @@ catch (MultipleArtifactsNotFoundException me) { /*only do this if we are an aggregating plugin: MNG-2277 - if the dependency doesn't yet exist but is in the reactor, then + if the dependency doesn't yet exist but is in the reactor, then all we can do is warn and skip it. A better fix can be inserted into 2.1*/ if (isAggregator && checkMissingArtifactsInReactor( context.getSortedProjects(), me.getMissingArtifacts() )) { @@ -1473,19 +1466,19 @@ //most likely it would be produced by the project we just found in the reactor since all //the other info matches. Assume it's ok. getLogger().warn( "The dependency: "+ p.getId()+" can't be resolved but has been found in the reactor.\nThis dependency has been excluded from the plugin execution. You should rerun this mojo after executing mvn install.\n" ); - + //found it, move on. foundInReactor.add( p ); break; - } + } } } - + //if all of them have been found, we can continue. return foundInReactor.size() == missing.size(); } - - + + // ---------------------------------------------------------------------- // Artifact downloading // ---------------------------------------------------------------------- Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java?rev=641701&r1=641700&r2=641701&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java (original) +++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java Wed Mar 26 20:21:55 2008 @@ -24,79 +24,62 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.model.Resource; import org.apache.maven.project.artifact.AttachedArtifact; -import org.codehaus.plexus.logging.AbstractLogEnabled; import java.io.File; import java.util.List; public class DefaultMavenProjectHelper - extends AbstractLogEnabled implements MavenProjectHelper { - + private ArtifactHandlerManager artifactHandlerManager; public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile ) { String type = artifactType; - + ArtifactHandler handler = null; - + if ( type != null ) { handler = artifactHandlerManager.getArtifactHandler( artifactType ); } - + if ( handler == null ) { handler = artifactHandlerManager.getArtifactHandler( "jar" ); } Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, artifactClassifier, handler ); - + artifact.setFile( artifactFile ); artifact.setResolved( true ); - - attachArtifact( project, artifact ); + + project.addAttachedArtifact( artifact ); } public void attachArtifact( MavenProject project, String artifactType, File artifactFile ) { ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( artifactType ); - + Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, handler ); - + artifact.setFile( artifactFile ); artifact.setResolved( true ); - - attachArtifact(project, artifact); + + project.addAttachedArtifact( artifact ); } public void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier ) { Artifact projectArtifact = project.getArtifact(); - + Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier, projectArtifact.getArtifactHandler() ); - + artifact.setFile( artifactFile ); artifact.setResolved( true ); - - attachArtifact(project, artifact); - } - - public void attachArtifact(MavenProject project, Artifact artifact) - { - try - { - project.addAttachedArtifact( artifact ); - } - catch (DuplicateArtifactAttachmentException dae) - { - getLogger().warn(dae.getMessage()); - - // We can throw this because it's unchecked, and won't change the MavenProjectHelper API, which would break backward compat if it did. - throw dae; - } + + project.addAttachedArtifact( artifact ); } public void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ) Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=641701&r1=641700&r2=641701&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original) +++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Wed Mar 26 20:21:55 2008 @@ -1351,15 +1351,7 @@ } public void addAttachedArtifact( Artifact artifact ) - throws DuplicateArtifactAttachmentException { - List attachedArtifacts = getAttachedArtifacts(); - - if ( attachedArtifacts.contains( artifact ) ) - { - throw new DuplicateArtifactAttachmentException( this, artifact ); - } - getAttachedArtifacts().add( artifact ); } @@ -1771,25 +1763,25 @@ { StringBuffer sb = new StringBuffer(30); sb.append( "MavenProject: " ); - sb.append( getGroupId() ); + sb.append( this.getGroupId() ); sb.append( ":" ); - sb.append( getArtifactId() ); + sb.append( this.getArtifactId() ); sb.append( ":" ); - sb.append( getVersion() ); + sb.append( this.getVersion() ); sb.append( " @ " ); - - try + + try { - sb.append( getFile().getPath() ); + sb.append( this.getFile().getPath() ); } catch (NullPointerException e) { //don't log it. } - - return sb.toString(); + + return sb.toString(); } - + /** * @throws CloneNotSupportedException * @since 2.0.9