maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver DefaultArtifactResolver.java
Date Thu, 17 Mar 2005 00:17:27 GMT
brett       2005/03/16 16:17:26

  Modified:    maven-artifact/src/main/java/org/apache/maven/artifact/resolver
                        DefaultArtifactResolver.java
  Log:
  PR: MNG-207
  fix scope issue in a conflict
  
  Revision  Changes    Path
  1.18      +43 -20    maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
  
  Index: DefaultArtifactResolver.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DefaultArtifactResolver.java	15 Mar 2005 21:41:04 -0000	1.17
  +++ DefaultArtifactResolver.java	17 Mar 2005 00:17:26 -0000	1.18
  @@ -2,6 +2,7 @@
   
   import org.apache.maven.artifact.AbstractArtifactComponent;
   import org.apache.maven.artifact.Artifact;
  +import org.apache.maven.artifact.DefaultArtifact;
   import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
   import org.apache.maven.artifact.manager.WagonManager;
   import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
  @@ -23,7 +24,7 @@
   
   /**
    * @todo get rid of {@link AbstractArtifactComponent}and then create an
  - *       AbstractArtifactResolver that does the transitive boilerplate
  + * AbstractArtifactResolver that does the transitive boilerplate
    */
   public class DefaultArtifactResolver
       extends AbstractArtifactComponent
  @@ -62,10 +63,9 @@
           try
           {
               Logger logger = getLogger();
  -            logger.debug("Resolving: " + artifact.getId() + " from:\n" +
  -                    "{localRepository: " + localRepository + "}\n" +
  -                    "{remoteRepositories: " + remoteRepositories + "}");
  -            
  +            logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository:
" + localRepository +
  +                          "}\n" + "{remoteRepositories: " + remoteRepositories + "}" );
  +
               setLocalRepositoryPath( artifact, localRepository );
   
               if ( artifact.exists() )
  @@ -93,15 +93,8 @@
       {
           StringBuffer sb = new StringBuffer();
   
  -        sb.append( "The artifact is not present locally as:" )
  -          .append( LS )
  -          .append( LS )
  -          .append( artifact.getPath() )
  -          .append( LS )
  -          .append( LS )
  -          .append( "or in any of the specified remote repositories:" )
  -          .append( LS )
  -          .append( LS );
  +        sb.append( "The artifact is not present locally as:" ).append( LS ).append( LS
).append( artifact.getPath() ).append(
  +            LS ).append( LS ).append( "or in any of the specified remote repositories:"
).append( LS ).append( LS );
   
           for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
           {
  @@ -139,7 +132,8 @@
       // ----------------------------------------------------------------------
   
       public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
  -        ArtifactRepository localRepository, ArtifactMetadataSource source, ArtifactFilter
filter )
  +                                                         ArtifactRepository localRepository,
  +                                                         ArtifactMetadataSource source,
ArtifactFilter filter )
           throws ArtifactResolutionException
       {
           ArtifactResolutionResult artifactResolutionResult;
  @@ -162,13 +156,17 @@
       }
   
       public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
  -        ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException
  +                                                         ArtifactRepository localRepository,
  +                                                         ArtifactMetadataSource source
)
  +        throws ArtifactResolutionException
       {
           return resolveTransitively( artifacts, remoteRepositories, localRepository, source,
null );
       }
   
       public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
  -        ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException
  +                                                         ArtifactRepository localRepository,
  +                                                         ArtifactMetadataSource source
)
  +        throws ArtifactResolutionException
       {
           return resolveTransitively( Collections.singleton( artifact ), remoteRepositories,
localRepository, source );
       }
  @@ -178,7 +176,8 @@
       // ----------------------------------------------------------------------
   
       private ArtifactResolutionResult collect( Set artifacts, ArtifactRepository localRepository,
  -        List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter )
  +                                              List remoteRepositories, ArtifactMetadataSource
source,
  +                                              ArtifactFilter filter )
           throws TransitiveArtifactResolutionException
       {
           ArtifactResolutionResult result = new ArtifactResolutionResult();
  @@ -211,6 +210,30 @@
                       {
                           addConflict( result, knownArtifact, newArtifact );
                       }
  +
  +                    // TODO: scope handler
  +                    boolean updateScope = false;
  +                    if ( Artifact.SCOPE_RUNTIME.equals( newArtifact.getScope() ) &&
  +                        Artifact.SCOPE_TEST.equals( knownArtifact.getScope() ) )
  +                    {
  +                        updateScope = true;
  +                    }
  +
  +                    if ( Artifact.SCOPE_COMPILE.equals( newArtifact.getScope() ) &&
  +                        !Artifact.SCOPE_COMPILE.equals( knownArtifact.getScope() ) )
  +                    {
  +                        updateScope = true;
  +                    }
  +
  +                    if ( updateScope )
  +                    {
  +                        // TODO: Artifact factory?
  +                        Artifact artifact = new DefaultArtifact( knownArtifact.getGroupId(),
  +                                                                 knownArtifact.getArtifactId(),
knownVersion,
  +                                                                 newArtifact.getScope(),
knownArtifact.getType(),
  +                                                                 knownArtifact.getExtension()
);
  +                        resolvedArtifacts.put( artifact.getConflictId(), artifact );
  +                    }
                   }
                   else
                   {
  @@ -233,8 +256,8 @@
                       }
                       catch ( ArtifactMetadataRetrievalException e )
                       {
  -                        throw new TransitiveArtifactResolutionException( "Error retrieving
metadata [" + newArtifact
  -                            + "] : ", e );
  +                        throw new TransitiveArtifactResolutionException( "Error retrieving
metadata [" + newArtifact +
  +                                                                         "] : ", e );
                       }
   
                       // the pom for given dependency exisit we will add it to the
  
  
  

Mime
View raw message