maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r988749 [3/9] - in /maven/maven-3/trunk: ./ apache-maven/ maven-aether-provider/ maven-aether-provider/src/ maven-aether-provider/src/main/ maven-aether-provider/src/main/java/ maven-aether-provider/src/main/java/org/ maven-aether-provider/...
Date Tue, 24 Aug 2010 22:46:12 GMT
Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java (original)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java Tue Aug 24 22:46:07 2010
@@ -20,21 +20,27 @@ package org.apache.maven.artifact.instal
  */
 
 import java.io.File;
-import java.io.IOException;
 
+import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadataInstallationException;
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
-import org.apache.maven.repository.DefaultLocalRepositoryMaintainerEvent;
-import org.apache.maven.repository.LocalRepositoryMaintainer;
-import org.apache.maven.repository.LocalRepositoryMaintainerEvent;
-import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager;
+import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.MetadataBridge;
+import org.apache.maven.artifact.repository.metadata.Snapshot;
+import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.Versioning;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.FileUtils;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.installation.InstallRequest;
+import org.sonatype.aether.installation.InstallationException;
+import org.sonatype.aether.repository.LocalRepository;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+import org.sonatype.aether.util.artifact.SubArtifact;
 
 /**
  * @author Jason van Zyl
@@ -44,15 +50,13 @@ public class DefaultArtifactInstaller
     extends AbstractLogEnabled
     implements ArtifactInstaller
 {
-    @Requirement
-    private ArtifactTransformationManager transformationManager;
 
     @Requirement
-    private RepositoryMetadataManager repositoryMetadataManager;
-
-    @Requirement( optional = true )
-    private LocalRepositoryMaintainer localRepositoryMaintainer;
-
+    private RepositorySystem repoSystem;
+    
+    @Requirement
+    private LegacySupport legacySupport;
+    
     /** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */
     @Deprecated
     public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository )
@@ -67,59 +71,64 @@ public class DefaultArtifactInstaller
     public void install( File source, Artifact artifact, ArtifactRepository localRepository )
         throws ArtifactInstallationException
     {
-        try
-        {
-            transformationManager.transformForInstall( artifact, localRepository );
-
-            String localPath = localRepository.pathOf( artifact );
+        DefaultRepositorySystemSession session =
+            new DefaultRepositorySystemSession( legacySupport.getRepositorySession() );
+        LocalRepository localRepo = new LocalRepository( localRepository.getBasedir() );
+        session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) );
+
+        InstallRequest request = new InstallRequest();
+
+        org.sonatype.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact );
+        mainArtifact = mainArtifact.setFile( source );
+        request.addArtifact( mainArtifact );
 
-            // TODO: use a file: wagon and the wagon manager?
-            File destination = new File( localRepository.getBasedir(), localPath );
-            if ( !destination.getParentFile().exists() )
+        for ( ArtifactMetadata metadata : artifact.getMetadataList() )
+        {
+            if ( metadata instanceof ProjectArtifactMetadata )
             {
-                destination.getParentFile().mkdirs();
+                org.sonatype.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" );
+                pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
+                request.addArtifact( pomArtifact );
             }
-
-            boolean copy =
-                !destination.exists() || "pom".equals( artifact.getType() )
-                    || source.lastModified() != destination.lastModified() || source.length() != destination.length();
-
-            if ( copy )
+            else if ( metadata instanceof SnapshotArtifactRepositoryMetadata
+                || metadata instanceof ArtifactRepositoryMetadata )
             {
-                getLogger().info( "Installing " + source + " to " + destination );
-
-                FileUtils.copyFile( source, destination );
-                destination.setLastModified( source.lastModified() );
+                // eaten, handled by repo system
             }
             else
             {
-                getLogger().info( "Skipped re-installing " + source + " to " + destination + ", seems unchanged" );
+                request.addMetadata( new MetadataBridge( metadata ) );
             }
+        }
 
-            // must be after the artifact is installed
-            for ( ArtifactMetadata metadata : artifact.getMetadataList() )
-            {
-                repositoryMetadataManager.install( metadata, localRepository );
-            }
-            // TODO: would like to flush this, but the plugin metadata is added in advance, not as an install/deploy
-            // transformation
-            // This would avoid the need to merge and clear out the state during deployment
-            // artifact.getMetadataList().clear();
-
-            if ( localRepositoryMaintainer != null )
-            {
-                LocalRepositoryMaintainerEvent event =
-                    new DefaultLocalRepositoryMaintainerEvent( localRepository, artifact, destination );
-                localRepositoryMaintainer.artifactInstalled( event );
-            }
+        try
+        {
+            repoSystem.install( session, request );
         }
-        catch ( IOException e )
+        catch ( InstallationException e )
         {
-            throw new ArtifactInstallationException( "Error installing artifact: " + e.getMessage(), e );
+            throw new ArtifactInstallationException( e.getMessage(), e );
         }
-        catch ( RepositoryMetadataInstallationException e )
+
+        /*
+         * NOTE: Not used by Maven core, only here to provide backward-compat with plugins like the Install Plugin.
+         */
+
+        if ( artifact.isSnapshot() )
+        {
+            Snapshot snapshot = new Snapshot();
+            snapshot.setLocalCopy( true );
+            artifact.addMetadata( new SnapshotArtifactRepositoryMetadata( artifact, snapshot ) );
+        }
+
+        Versioning versioning = new Versioning();
+        versioning.updateTimestamp();
+        versioning.addVersion( artifact.getBaseVersion() );
+        if ( artifact.isRelease() )
         {
-            throw new ArtifactInstallationException( "Error installing artifact's metadata: " + e.getMessage(), e );
+            versioning.setRelease( artifact.getBaseVersion() );
         }
+        artifact.addMetadata( new ArtifactRepositoryMetadata( artifact, versioning ) );
     }
-}
\ No newline at end of file
+
+}

Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java (original)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java Tue Aug 24 22:46:07 2010
@@ -6,9 +6,9 @@ package org.apache.maven.artifact.reposi
  * 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
@@ -22,7 +22,6 @@ import java.io.Reader;
 import java.io.Writer;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -30,7 +29,6 @@ import org.apache.maven.artifact.metadat
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
 import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
-import org.apache.maven.artifact.repository.RepositoryCache;
 import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
 import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
@@ -49,7 +47,7 @@ import org.codehaus.plexus.util.xml.pull
 /**
  * @author Jason van Zyl
  */
-@Component( role = RepositoryMetadataManager.class )
+@Component(role=RepositoryMetadataManager.class)
 public class DefaultRepositoryMetadataManager
     extends AbstractLogEnabled
     implements RepositoryMetadataManager
@@ -60,8 +58,7 @@ public class DefaultRepositoryMetadataMa
     @Requirement
     private UpdateCheckManager updateCheckManager;
 
-    public void resolve( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories,
-                         ArtifactRepository localRepository )
+    public void resolve( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
         throws RepositoryMetadataResolutionException
     {
         RepositoryRequest request = new DefaultRepositoryRequest();
@@ -73,41 +70,6 @@ public class DefaultRepositoryMetadataMa
     public void resolve( RepositoryMetadata metadata, RepositoryRequest request )
         throws RepositoryMetadataResolutionException
     {
-        RepositoryCache cache = request.getCache();
-
-        CacheKey cacheKey = null;
-
-        if ( cache != null )
-        {
-            cacheKey = new CacheKey( metadata, request );
-
-            CacheRecord cacheRecord = (CacheRecord) cache.get( request, cacheKey );
-
-            if ( cacheRecord != null )
-            {
-                if ( getLogger().isDebugEnabled() )
-                {
-                    getLogger().debug( "Resolved metadata from cache: " + metadata + " @ " + cacheRecord.repository );
-                }
-
-                metadata.setMetadata( MetadataUtils.cloneMetadata( cacheRecord.metadata ) );
-
-                if ( cacheRecord.repository != null )
-                {
-                    for ( ArtifactRepository repository : request.getRemoteRepositories() )
-                    {
-                        if ( cacheRecord.repository.equals( repository.getId() ) )
-                        {
-                            metadata.setRepository( repository );
-                            break;
-                        }
-                    }
-                }
-
-                return;
-            }
-        }
-
         ArtifactRepository localRepository = request.getLocalRepository();
         List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();
 
@@ -209,13 +171,7 @@ public class DefaultRepositoryMetadataMa
         }
         catch ( RepositoryMetadataStoreException e )
         {
-            throw new RepositoryMetadataResolutionException( "Unable to store local copy of metadata: "
-                + e.getMessage(), e );
-        }
-
-        if ( cache != null )
-        {
-            cache.put( request, cacheKey, new CacheRecord( metadata ) );
+            throw new RepositoryMetadataResolutionException( "Unable to store local copy of metadata: " + e.getMessage(), e );
         }
     }
 
@@ -226,130 +182,7 @@ public class DefaultRepositoryMetadataMa
         return metadataFile.isFile() ? new Date( metadataFile.lastModified() ) : null;
     }
 
-    private static final class CacheKey
-    {
-
-        final Object metadataKey;
-
-        final ArtifactRepository localRepository;
-
-        final List<ArtifactRepository> remoteRepositories;
-
-        final int hashCode;
-
-        CacheKey( RepositoryMetadata metadata, RepositoryRequest request )
-        {
-            metadataKey = metadata.getKey();
-            localRepository = request.getLocalRepository();
-            remoteRepositories = request.getRemoteRepositories();
-
-            int hash = 17;
-            hash = hash * 31 + metadata.getKey().hashCode();
-            hash = hash * 31 + repoHashCode( localRepository );
-            for ( ArtifactRepository remoteRepository : remoteRepositories )
-            {
-                hash = hash * 31 + repoHashCode( remoteRepository );
-            }
-            hashCode = hash;
-        }
-
-        int repoHashCode( ArtifactRepository repository )
-        {
-            return ( repository != null && repository.getUrl() != null ) ? repository.getUrl().hashCode() : 0;
-        }
-
-        boolean repoEquals( ArtifactRepository repo1, ArtifactRepository repo2 )
-        {
-            if ( repo1 == repo2 )
-            {
-                return true;
-            }
-
-            if ( repo1 == null || repo2 == null )
-            {
-                return false;
-            }
-
-            return equal( repo1.getUrl(), repo2.getUrl() ) && repo1.getClass() == repo2.getClass();
-        }
-
-        private static <T> boolean equal( T s1, T s2 )
-        {
-            return s1 != null ? s1.equals( s2 ) : s2 == null;
-        }
-
-        @Override
-        public boolean equals( Object obj )
-        {
-            if ( this == obj )
-            {
-                return true;
-            }
-
-            if ( !( obj instanceof CacheKey ) )
-            {
-                return false;
-            }
-
-            CacheKey that = (CacheKey) obj;
-
-            if ( !this.metadataKey.equals( that.metadataKey ) )
-            {
-                return false;
-            }
-
-            if ( !repoEquals( this.localRepository, that.localRepository ) )
-            {
-                return false;
-            }
-
-            for ( Iterator<ArtifactRepository> it1 = this.remoteRepositories.iterator(), it2 =
-                that.remoteRepositories.iterator();; )
-            {
-                if ( !it1.hasNext() || !it2.hasNext() )
-                {
-                    if ( it1.hasNext() != it2.hasNext() )
-                    {
-                        return false;
-                    }
-                    break;
-                }
-                ArtifactRepository repo1 = it1.next();
-                ArtifactRepository repo2 = it2.next();
-                if ( !repoEquals( repo1, repo2 ) )
-                {
-                    return false;
-                }
-            }
-
-            return true;
-        }
-
-        @Override
-        public int hashCode()
-        {
-            return hashCode;
-        }
-
-    }
-
-    private static final class CacheRecord
-    {
-
-        final Metadata metadata;
-
-        final String repository;
-
-        CacheRecord( RepositoryMetadata metadata )
-        {
-            this.metadata = MetadataUtils.cloneMetadata( metadata.getMetadata() );
-            this.repository = ( metadata.getRepository() != null ) ? metadata.getRepository().getId() : null;
-        }
-
-    }
-
-    private void mergeMetadata( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories,
-                                ArtifactRepository localRepository )
+    private void mergeMetadata( RepositoryMetadata metadata, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
         throws RepositoryMetadataStoreException
     {
         // TODO: currently this is first wins, but really we should take the latest by comparing either the
@@ -378,9 +211,7 @@ public class DefaultRepositoryMetadataMa
         updateSnapshotMetadata( metadata, previousMetadata, selected, localRepository );
     }
 
-    private void updateSnapshotMetadata( RepositoryMetadata metadata,
-                                         Map<ArtifactRepository, Metadata> previousMetadata,
-                                         ArtifactRepository selected, ArtifactRepository localRepository )
+    private void updateSnapshotMetadata( RepositoryMetadata metadata, Map<ArtifactRepository, Metadata> previousMetadata, ArtifactRepository selected, ArtifactRepository localRepository )
         throws RepositoryMetadataStoreException
     {
         // TODO: this could be a lot nicer... should really be in the snapshot transformation?
@@ -405,8 +236,7 @@ public class DefaultRepositoryMetadataMa
                 }
                 else
                 {
-                    if ( ( m.getVersioning() != null ) && ( m.getVersioning().getSnapshot() != null )
-                        && m.getVersioning().getSnapshot().isLocalCopy() )
+                    if ( ( m.getVersioning() != null ) && ( m.getVersioning().getSnapshot() != null ) && m.getVersioning().getSnapshot().isLocalCopy() )
                     {
                         m.getVersioning().getSnapshot().setLocalCopy( false );
                         metadata.setMetadata( m );
@@ -419,14 +249,11 @@ public class DefaultRepositoryMetadataMa
         }
     }
 
-    private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository,
-                                  ArtifactRepository localRepository, Map<ArtifactRepository, Metadata> previousMetadata )
+    private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository, ArtifactRepository localRepository, Map<ArtifactRepository, Metadata> previousMetadata )
     {
         boolean setRepository = false;
 
-        File metadataFile =
-            new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( repoMetadata,
-                                                                                                   remoteRepository ) );
+        File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) );
 
         if ( metadataFile.exists() )
         {
@@ -488,13 +315,11 @@ public class DefaultRepositoryMetadataMa
         }
         catch ( IOException e )
         {
-            throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': "
-                + e.getMessage(), e );
+            throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e );
         }
         catch ( XmlPullParserException e )
         {
-            throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': "
-                + e.getMessage(), e );
+            throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e );
         }
         finally
         {
@@ -505,8 +330,8 @@ public class DefaultRepositoryMetadataMa
     }
 
     /**
-     * Ensures the last updated timestamp of the specified metadata does not refer to the future and fixes the local
-     * metadata if necessary to allow proper merging/updating of metadata during deployment.
+     * Ensures the last updated timestamp of the specified metadata does not refer to the future and fixes the local metadata if necessary to allow
+     * proper merging/updating of metadata during deployment.
      */
     private void fixTimestamp( File metadataFile, Metadata metadata, Metadata reference )
     {
@@ -562,8 +387,7 @@ public class DefaultRepositoryMetadataMa
         }
     }
 
-    public void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository,
-                               ArtifactRepository remoteRepository )
+    public void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
         throws RepositoryMetadataResolutionException
     {
         File file;
@@ -573,8 +397,7 @@ public class DefaultRepositoryMetadataMa
         }
         catch ( TransferFailedException e )
         {
-            throw new RepositoryMetadataResolutionException( metadata + " could not be retrieved from repository: "
-                + remoteRepository.getId() + " due to an error: " + e.getMessage(), e );
+            throw new RepositoryMetadataResolutionException( metadata + " could not be retrieved from repository: " + remoteRepository.getId() + " due to an error: " + e.getMessage(), e );
         }
 
         try
@@ -591,24 +414,18 @@ public class DefaultRepositoryMetadataMa
         }
     }
 
-    private File getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata,
-                                                              ArtifactRepository localRepository,
-                                                              ArtifactRepository remoteRepository )
+    private File getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
         throws TransferFailedException
     {
-        File file =
-            new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata,
-                                                                                                   remoteRepository ) );
+        File file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) );
 
         try
         {
-            wagonManager.getArtifactMetadataFromDeploymentRepository( metadata, remoteRepository, file,
-                                                                      ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
+            wagonManager.getArtifactMetadataFromDeploymentRepository( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
         }
         catch ( ResourceDoesNotExistException e )
         {
-            getLogger().info( metadata + " could not be found on repository: " + remoteRepository.getId()
-                                  + ", so will be created" );
+            getLogger().info( metadata + " could not be found on repository: " + remoteRepository.getId() + ", so will be created" );
 
             // delete the local copy so the old details aren't used.
             if ( file.exists() )
@@ -626,8 +443,7 @@ public class DefaultRepositoryMetadataMa
         return file;
     }
 
-    public void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository,
-                        ArtifactRepository deploymentRepository )
+    public void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository deploymentRepository )
         throws RepositoryMetadataDeploymentException
     {
         File file;
@@ -640,8 +456,7 @@ public class DefaultRepositoryMetadataMa
             }
             catch ( TransferFailedException e )
             {
-                throw new RepositoryMetadataDeploymentException( metadata + " could not be retrieved from repository: "
-                    + deploymentRepository.getId() + " due to an error: " + e.getMessage(), e );
+                throw new RepositoryMetadataDeploymentException( metadata + " could not be retrieved from repository: " + deploymentRepository.getId() + " due to an error: " + e.getMessage(), e );
             }
 
             if ( file.isFile() )
@@ -659,9 +474,7 @@ public class DefaultRepositoryMetadataMa
         else
         {
             // It's a POM - we don't need to retrieve it first
-            file =
-                new File( localRepository.getBasedir(),
-                          localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) );
+            file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) );
         }
 
         try

Added: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java?rev=988749&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java (added)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java Tue Aug 24 22:46:07 2010
@@ -0,0 +1,157 @@
+package org.apache.maven.artifact.repository.metadata;
+
+/*
+ * 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.io.File;
+
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.codehaus.plexus.util.FileUtils;
+import org.sonatype.aether.RepositoryException;
+import org.sonatype.aether.metadata.MergeableMetadata;
+
+/**
+ * <strong>Warning:</strong> This is an internal utility class that is only public for technical reasons, it is not part
+ * of the public API. In particular, this class can be changed or deleted without prior notice.
+ * 
+ * @author Benjamin Bentmann
+ */
+public final class MetadataBridge
+    implements MergeableMetadata
+{
+
+    private ArtifactMetadata metadata;
+
+    private boolean merged;
+
+    public MetadataBridge( ArtifactMetadata metadata )
+    {
+        this.metadata = metadata;
+    }
+
+    public void merge( File current, File result )
+        throws RepositoryException
+    {
+        try
+        {
+            if ( current.exists() )
+            {
+                FileUtils.copyFile( current, result );
+            }
+            ArtifactRepository localRepo = new MetadataRepository( result );
+            metadata.storeInLocalRepository( localRepo, localRepo );
+            merged = true;
+        }
+        catch ( Exception e )
+        {
+            throw new RepositoryException( e.getMessage(), e );
+        }
+    }
+
+    public boolean isMerged()
+    {
+        return merged;
+    }
+
+    public String getGroupId()
+    {
+        return emptify( metadata.getGroupId() );
+    }
+
+    public String getArtifactId()
+    {
+        return metadata.storedInGroupDirectory() ? "" : emptify( metadata.getArtifactId() );
+    }
+
+    public String getVersion()
+    {
+        return metadata.storedInArtifactVersionDirectory() ? emptify( metadata.getBaseVersion() ) : "";
+    }
+
+    public String getType()
+    {
+        return metadata.getRemoteFilename();
+    }
+
+    private String emptify( String string )
+    {
+        return ( string != null ) ? string : "";
+    }
+
+    public File getFile()
+    {
+        return null;
+    }
+
+    public MetadataBridge setFile( File file )
+    {
+        return this;
+    }
+
+    public Nature getNature()
+    {
+        if ( metadata instanceof RepositoryMetadata )
+        {
+            switch ( ( (RepositoryMetadata) metadata ).getNature() )
+            {
+                case RepositoryMetadata.RELEASE_OR_SNAPSHOT:
+                    return Nature.RELEASE_OR_SNAPSHOT;
+                case RepositoryMetadata.SNAPSHOT:
+                    return Nature.SNAPSHOT;
+                default:
+                    return Nature.RELEASE;
+            }
+        }
+        else
+        {
+            return Nature.RELEASE;
+        }
+    }
+
+    @SuppressWarnings( "deprecation" )
+    static class MetadataRepository
+        extends DefaultArtifactRepository
+    {
+
+        private File metadataFile;
+
+        public MetadataRepository( File metadataFile )
+        {
+            super( "local", "", null );
+            this.metadataFile = metadataFile;
+        }
+
+        @Override
+        public String getBasedir()
+        {
+            return metadataFile.getParent();
+        }
+
+        @Override
+        public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
+        {
+            return metadataFile.getName();
+        }
+
+    }
+
+}

Propchange: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/MetadataBridge.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java (original)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java Tue Aug 24 22:46:07 2010
@@ -1,26 +1,21 @@
 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.io.File;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedHashMap;
@@ -37,58 +32,44 @@ import java.util.concurrent.ThreadPoolEx
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.metadata.ResolutionGroup;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
 import org.apache.maven.artifact.repository.RepositoryRequest;
-import org.apache.maven.artifact.repository.metadata.Metadata;
-import org.apache.maven.artifact.repository.metadata.Snapshot;
-import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
-import org.apache.maven.artifact.repository.metadata.Versioning;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.LegacySupport;
-import org.apache.maven.repository.DefaultLocalRepositoryMaintainerEvent;
-import org.apache.maven.repository.LocalRepositoryMaintainer;
-import org.apache.maven.repository.LocalRepositoryMaintainerEvent;
-import org.apache.maven.repository.legacy.TransferListenerAdapter;
-import org.apache.maven.repository.legacy.WagonManager;
-import org.apache.maven.repository.legacy.metadata.ArtifactMetadata;
 import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest;
 import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
 import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
-import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.events.TransferListener;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.util.FileUtils;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.LocalRepository;
+import org.sonatype.aether.resolution.ArtifactRequest;
+import org.sonatype.aether.resolution.ArtifactResult;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
 
 /**
  * @author Jason van Zyl
  */
-@Component( role = ArtifactResolver.class )
+@Component(role = ArtifactResolver.class)
 public class DefaultArtifactResolver
     implements ArtifactResolver
 {
-    @Requirement
+    @Requirement 
     private Logger logger;
 
     @Requirement
-    private WagonManager wagonManager;
-
-    @Requirement
-    private ArtifactTransformationManager transformationManager;
-
-    @Requirement
     protected ArtifactFactory artifactFactory;
 
     @Requirement
@@ -99,16 +80,16 @@ public class DefaultArtifactResolver
 
     @Requirement
     private ArtifactMetadataSource source;
-
+    
     @Requirement
     private PlexusContainer container;
 
-    @Requirement( optional = true )
-    private LocalRepositoryMaintainer localRepositoryMaintainer;
-
     @Requirement
     private LegacySupport legacySupport;
 
+    @Requirement
+    private RepositorySystem repoSystem;
+
     private final Executor executor;
 
     public DefaultArtifactResolver()
@@ -141,13 +122,32 @@ public class DefaultArtifactResolver
         }
     }
 
+    private RepositorySystemSession getSession( ArtifactRepository localRepository )
+    {
+        MavenSession mavenSession = legacySupport.getSession();
+        DefaultRepositorySystemSession session;
+        if ( mavenSession != null )
+        {
+            session = new DefaultRepositorySystemSession( mavenSession.getRepositorySession() );
+        }
+        else
+        {
+            session = new DefaultRepositorySystemSession();
+        }
+        if ( localRepository != null && localRepository.getBasedir() != null )
+        {
+            LocalRepository localRepo = new LocalRepository( localRepository.getBasedir() );
+            session.setLocalRepositoryManager( repoSystem.newLocalRepositoryManager( localRepo ) );
+        }
+        return session;
+    }
+
     private void injectSession1( RepositoryRequest request, MavenSession session )
     {
         if ( session != null )
         {
             request.setOffline( session.isOffline() );
             request.setForceUpdate( session.getRequest().isUpdateSnapshots() );
-            request.setTransferListener( session.getRequest().getTransferListener() );
         }
     }
 
@@ -163,297 +163,125 @@ public class DefaultArtifactResolver
         }
     }
 
-    public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories,
-                         ArtifactRepository localRepository, TransferListener resolutionListener )
+    public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        RepositoryRequest request = new DefaultRepositoryRequest();
-        injectSession1( request, legacySupport.getSession() );
-        request.setLocalRepository( localRepository );
-        request.setRemoteRepositories( remoteRepositories );
-        resolve( artifact, request, resolutionListener, false );
+        resolve( artifact, remoteRepositories, getSession( localRepository ) );
     }
 
-    public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories,
-                               ArtifactRepository localRepository )
+    public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        RepositoryRequest request = new DefaultRepositoryRequest();
-        injectSession1( request, legacySupport.getSession() );
-        request.setLocalRepository( localRepository );
-        request.setRemoteRepositories( remoteRepositories );
-        resolve( artifact, request, null, true );
+        resolve( artifact, remoteRepositories, getSession( localRepository ) );
     }
 
-    private void resolve( Artifact artifact, RepositoryRequest request, TransferListener downloadMonitor,
-                          boolean force )
+    private void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, RepositorySystemSession session )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
         if ( artifact == null )
         {
             return;
         }
-
-        File destination;
-
+        
         if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
         {
             File systemFile = artifact.getFile();
 
             if ( systemFile == null )
             {
-                throw new ArtifactNotFoundException( "System artifact: " + artifact + " has no file attached",
-                                                     artifact );
+                throw new ArtifactNotFoundException( "System artifact: " + artifact + " has no file attached", artifact );
             }
 
             if ( !systemFile.exists() )
             {
-                throw new ArtifactNotFoundException( "System artifact: " + artifact + " not found in path: "
-                    + systemFile, artifact );
+                throw new ArtifactNotFoundException( "System artifact: " + artifact + " not found in path: " + systemFile, artifact );
             }
 
             if ( !systemFile.isFile() )
             {
-                throw new ArtifactNotFoundException( "System artifact: " + artifact + " is not a file: " + systemFile,
-                                                     artifact );
+                throw new ArtifactNotFoundException( "System artifact: " + artifact + " is not a file: " + systemFile, artifact );
             }
 
             artifact.setResolved( true );
-
+            
             return;
         }
 
-        ArtifactRepository localRepository = request.getLocalRepository();
-
-        List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();
-
         if ( !artifact.isResolved() )
         {
-            // ----------------------------------------------------------------------
-            // Check for the existence of the artifact in the specified local
-            // ArtifactRepository. If it is present then simply return as the
-            // request for resolution has been satisfied.
-            // ----------------------------------------------------------------------
-
-            artifact = localRepository.find( artifact );
+            ArtifactResult result;
 
-            if ( artifact.isResolved() )
+            try
             {
-                return;
+                ArtifactRequest artifactRequest = new ArtifactRequest();
+                artifactRequest.setArtifact( RepositoryUtils.toArtifact( artifact ) );
+                artifactRequest.setRepositories( RepositoryUtils.toRepos( remoteRepositories ) );
+                result = repoSystem.resolveArtifact( session, artifactRequest );
             }
-
-            transformationManager.transformForResolve( artifact, request );
-
-            destination = artifact.getFile();
-
-            if ( !request.isOffline() && ( force || !destination.exists() || isMutable( artifact ) ) )
+            catch ( org.sonatype.aether.resolution.ArtifactResolutionException e )
             {
-                try
-                {
-                    if ( artifact.getRepository() != null )
-                    {
-                        // the transformations discovered the artifact - so use it exclusively
-                        wagonManager.getArtifact( artifact, artifact.getRepository(), downloadMonitor,
-                                                  request.isForceUpdate() );
-                    }
-                    else
-                    {
-                        wagonManager.getArtifact( artifact, remoteRepositories, downloadMonitor,
-                                                  request.isForceUpdate() );
-                    }
-
-                    if ( localRepositoryMaintainer != null )
-                    {
-                        LocalRepositoryMaintainerEvent event =
-                            new DefaultLocalRepositoryMaintainerEvent( localRepository, artifact, null );
-                        localRepositoryMaintainer.artifactDownloaded( event );
-                    }
-
-                }
-                catch ( ResourceDoesNotExistException e )
+                if ( e.getCause() instanceof org.sonatype.aether.transfer.ArtifactNotFoundException )
                 {
                     throw new ArtifactNotFoundException( e.getMessage(), artifact, remoteRepositories, e );
                 }
-                catch ( TransferFailedException e )
-                {
-                    throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
-                }
-            }
-
-            if ( destination.exists() )
-            {
-                artifact.setResolved( true );
-            }
-            else
-            {
-                if ( request.isOffline() )
-                {
-                    throw new ArtifactResolutionException( "The repository system is offline"
-                        + " and the requested artifact is not locally available at " + destination, artifact,
-                                                           remoteRepositories );
-                }
                 else
                 {
-                    throw new ArtifactResolutionException( "Failed to resolve artifact, possibly due to a "
-                        + "repository list that is not appropriately equipped for this artifact's metadata.", artifact,
-                                                           remoteRepositories );
-                }
-            }
-
-            // 1.0-SNAPSHOT
-            //
-            // 1)         pom = 1.0-SNAPSHOT
-            // 2)         pom = 1.0-yyyymmdd.hhmmss
-            // 3) baseVersion = 1.0-SNAPSHOT
-            if ( artifact.isSnapshot() && isTimestamped( artifact ) )
-            {
-                String version = artifact.getVersion();
-
-                // 1.0-SNAPSHOT
-                artifact.selectVersion( artifact.getBaseVersion() );
-
-                // Make a file with a 1.0-SNAPSHOT format
-                File copy = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
-
-                // if the timestamped version was resolved or the copy doesn't exist then copy a version
-                // of the file like 1.0-SNAPSHOT. Even if there is a timestamped version the non-timestamped
-                // version will be created.
-                if ( !copy.exists() || copy.lastModified() != destination.lastModified()
-                    || copy.length() != destination.length() )
-                {
-                    // recopy file if it was reresolved, or doesn't exist.
-                    try
-                    {
-                        FileUtils.copyFile( destination, copy );
-
-                        copy.setLastModified( destination.lastModified() );
-                    }
-                    catch ( IOException e )
-                    {
-                        throw new ArtifactResolutionException( "Unable to copy resolved artifact for local use: "
-                            + e.getMessage(), artifact, remoteRepositories, e );
-                    }
+                    throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
                 }
-
-                // We are only going to use the 1.0-SNAPSHOT version
-                artifact.setFile( copy );
-
-                // Set the version to the 1.0-yyyymmdd.hhmmss version
-                artifact.selectVersion( version );
             }
-        }
-    }
-
-    private boolean isMutable( Artifact artifact )
-    {
-        return artifact.isSnapshot() && !isTimestamped( artifact ) && !isLocalCopy( artifact );
-    }
-
-    private boolean isTimestamped( Artifact artifact )
-    {
-        return !artifact.getBaseVersion().equals( artifact.getVersion() );
-    }
 
-    private boolean isLocalCopy( Artifact artifact )
-    {
-        boolean localCopy = false;
-
-        for ( ArtifactMetadata m : artifact.getMetadataList() )
-        {
-            if ( m instanceof SnapshotArtifactRepositoryMetadata )
-            {
-                SnapshotArtifactRepositoryMetadata snapshotMetadata = (SnapshotArtifactRepositoryMetadata) m;
-
-                Metadata metadata = snapshotMetadata.getMetadata();
-
-                if ( metadata != null )
-                {
-                    Versioning versioning = metadata.getVersioning();
-
-                    if ( versioning != null )
-                    {
-                        Snapshot snapshot = versioning.getSnapshot();
-
-                        if ( snapshot != null )
-                        {
-                            // TODO is it possible to have more than one SnapshotArtifactRepositoryMetadata
-                            localCopy = snapshot.isLocalCopy();
-                        }
-                    }
-                }
-            }
+            artifact.selectVersion( result.getArtifact().getVersion() );
+            artifact.setFile( result.getArtifact().getFile() );
+            artifact.setResolved( true );
         }
-
-        return localCopy;
     }
 
-    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
-                                                         ArtifactRepository localRepository,
-                                                         List<ArtifactRepository> remoteRepositories,
+    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
                                                          ArtifactMetadataSource source, ArtifactFilter filter )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
-                                    remoteRepositories, source, filter );
+        return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories, source, filter );
 
     }
 
-    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
-                                                         Map managedVersions, ArtifactRepository localRepository,
-                                                         List<ArtifactRepository> remoteRepositories,
-                                                         ArtifactMetadataSource source )
+    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
+                                                         List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
-                                    remoteRepositories, source, null );
+        return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, null );
     }
 
-    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
-                                                         Map managedVersions, ArtifactRepository localRepository,
-                                                         List<ArtifactRepository> remoteRepositories,
-                                                         ArtifactMetadataSource source, ArtifactFilter filter )
+    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
+                                                         List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
-        return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
-                                    remoteRepositories, source, filter, null );
+        return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, null );
     }
 
-    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
-                                                         List<ArtifactRepository> remoteRepositories,
-                                                         ArtifactRepository localRepository,
+    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository,
                                                          ArtifactMetadataSource source )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null );
     }
 
-    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
-                                                         List<ArtifactRepository> remoteRepositories,
-                                                         ArtifactRepository localRepository,
-                                                         ArtifactMetadataSource source,
-                                                         List<ResolutionListener> listeners )
+    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository,
+                                                         ArtifactMetadataSource source, List<ResolutionListener> listeners )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
         return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
                                     remoteRepositories, source, null, listeners );
     }
 
-    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
-                                                         Map managedVersions, ArtifactRepository localRepository,
-                                                         List<ArtifactRepository> remoteRepositories,
-                                                         ArtifactMetadataSource source, ArtifactFilter filter,
-                                                         List<ResolutionListener> listeners )
-        throws ArtifactResolutionException, ArtifactNotFoundException
-    {
-        return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
-                                    remoteRepositories, source, filter, listeners, null );
-    }
-
-    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact,
-                                                         Map managedVersions, ArtifactRepository localRepository,
-                                                         List<ArtifactRepository> remoteRepositories,
-                                                         ArtifactMetadataSource source, ArtifactFilter filter,
-                                                         List<ResolutionListener> listeners,
+    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
+                                                         List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners )
+        throws ArtifactResolutionException, ArtifactNotFoundException
+    {
+        return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners, null );
+    }
+
+    public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
+                                                         List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners,
                                                          List<ConflictResolver> conflictResolvers )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
@@ -461,7 +289,7 @@ public class DefaultArtifactResolver
             .setArtifact( originatingArtifact )
             .setResolveRoot( false )
             // This is required by the surefire plugin
-            .setArtifactDependencies( artifacts )
+            .setArtifactDependencies( artifacts )            
             .setManagedVersionMap( managedVersions )
             .setLocalRepository( localRepository )
             .setRemoteRepositories( remoteRepositories )
@@ -497,10 +325,10 @@ public class DefaultArtifactResolver
         Set<Artifact> artifacts = request.getArtifactDependencies();
         Map managedVersions = request.getManagedVersionMap();
         List<ResolutionListener> listeners = request.getListeners();
-        ArtifactFilter collectionFilter = request.getCollectionFilter();
+        ArtifactFilter collectionFilter = request.getCollectionFilter();                       
         ArtifactFilter resolutionFilter = request.getResolutionFilter();
-        TransferListener transferListener = TransferListenerAdapter.newAdapter( request.getTransferListener() );
-
+        RepositorySystemSession session = getSession( request.getLocalRepository() );
+        
         //TODO: hack because metadata isn't generated in m2e correctly and i want to run the maven i have in the workspace
         if ( source == null )
         {
@@ -532,12 +360,12 @@ public class DefaultArtifactResolver
         // This is often an artifact like a POM that is taken from disk and we already have hold of the
         // file reference. But this may be a Maven Plugin that we need to resolve from a remote repository
         // as well as its dependencies.
-
+                        
         if ( request.isResolveRoot() /* && rootArtifact.getFile() == null */ )
-        {
+        {            
             try
             {
-                resolve( rootArtifact, request, transferListener, false );
+                resolve( rootArtifact, request.getRemoteRepositories(), session );
             }
             catch ( ArtifactResolutionException e )
             {
@@ -609,7 +437,7 @@ public class DefaultArtifactResolver
                 return result;
             }
         }
-
+        
         if ( artifacts == null || artifacts.isEmpty() )
         {
             if ( request.isResolveRoot() )
@@ -617,19 +445,18 @@ public class DefaultArtifactResolver
                 result.addArtifact( rootArtifact );
             }
             return result;
-        }
+        } 
 
         // After the collection we will have the artifact object in the result but they will not be resolved yet.
         result =
             artifactCollector.collect( artifacts, rootArtifact, managedVersions, collectionRequest, source,
                                        collectionFilter, listeners, null );
-
+                        
         // We have metadata retrieval problems, or there are cycles that have been detected
         // so we give this back to the calling code and let them deal with this information
         // appropriately.
 
-        if ( result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations()
-            || result.hasCircularDependencyExceptions() )
+        if ( result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations() || result.hasCircularDependencyExceptions() )
         {
             return result;
         }
@@ -646,11 +473,8 @@ public class DefaultArtifactResolver
 
                 if ( resolutionFilter == null || resolutionFilter.include( artifact ) )
                 {
-                    ArtifactResolutionRequest childRequest = new ArtifactResolutionRequest( request );
-                    childRequest.setRemoteRepositories( node.getRemoteRepositories() );
-
-                    executor.execute( new ResolveTask( classLoader, latch, artifact, transferListener, childRequest,
-                                                       result ) );
+                    executor.execute( new ResolveTask( classLoader, latch, artifact, session,
+                                                       node.getRemoteRepositories(), result ) );
                 }
                 else
                 {
@@ -671,19 +495,18 @@ public class DefaultArtifactResolver
         // We want to send the root artifact back in the result but we need to do this after the other dependencies
         // have been resolved.
         if ( request.isResolveRoot() )
-        {
+        {            
             // Add the root artifact (as the first artifact to retain logical order of class path!)
             Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();
             allArtifacts.add( rootArtifact );
             allArtifacts.addAll( result.getArtifacts() );
             result.setArtifacts( allArtifacts );
-        }
-
+        }                        
+                 
         return result;
     }
 
-    public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories,
-                         ArtifactRepository localRepository )
+    public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
         throws ArtifactResolutionException, ArtifactNotFoundException
     {
         resolve( artifact, remoteRepositories, localRepository, null );
@@ -719,21 +542,20 @@ public class DefaultArtifactResolver
 
         private final Artifact artifact;
 
-        private final TransferListener transferListener;
+        private final RepositorySystemSession session;
 
-        private final ArtifactResolutionRequest request;
+        private final List<ArtifactRepository> remoteRepositories;
 
         private final ArtifactResolutionResult result;
 
-        public ResolveTask( ClassLoader classLoader, CountDownLatch latch, Artifact artifact,
-                            TransferListener transferListener, ArtifactResolutionRequest request,
-                            ArtifactResolutionResult result )
+        public ResolveTask( ClassLoader classLoader, CountDownLatch latch, Artifact artifact, RepositorySystemSession session,
+                            List<ArtifactRepository> remoteRepositories, ArtifactResolutionResult result )
         {
             this.classLoader = classLoader;
             this.latch = latch;
             this.artifact = artifact;
-            this.transferListener = transferListener;
-            this.request = request;
+            this.session = session;
+            this.remoteRepositories = remoteRepositories;
             this.result = result;
         }
 
@@ -742,7 +564,7 @@ public class DefaultArtifactResolver
             try
             {
                 Thread.currentThread().setContextClassLoader( classLoader );
-                resolve( artifact, request, transferListener, false );
+                resolve( artifact, remoteRepositories, session );
             }
             catch ( ArtifactNotFoundException anfe )
             {

Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Tue Aug 24 22:46:07 2010
@@ -94,6 +94,7 @@ public class DefaultMavenProjectBuilder
         MavenSession session = legacySupport.getSession();
         if ( session != null )
         {
+            request.setRepositorySession( session.getRepositorySession() );
             request.setOffline( session.isOffline() );
             request.setSystemProperties( session.getSystemProperties() );
             if ( request.getUserProperties().isEmpty() )
@@ -108,7 +109,6 @@ public class DefaultMavenProjectBuilder
                 request.setMirrors( req.getMirrors() );
                 request.setProxies( req.getProxies() );
                 request.setRemoteRepositories( req.getRemoteRepositories() );
-                request.setTransferListener( req.getTransferListener() );
                 request.setForceUpdate( req.isUpdateSnapshots() );
             }
         }

Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java (original)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java Tue Aug 24 22:46:07 2010
@@ -83,7 +83,6 @@ public class DefaultLegacyArtifactCollec
             request.setServers( session.getRequest().getServers() );
             request.setMirrors( session.getRequest().getMirrors() );
             request.setProxies( session.getRequest().getProxies() );
-            request.setTransferListener( session.getRequest().getTransferListener() );
         }
     }
 

Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java (original)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java Tue Aug 24 22:46:07 2010
@@ -29,11 +29,33 @@ import java.util.List;
 
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.LegacySupport;
 import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.DefaultMavenExecutionResult;
+import org.apache.maven.execution.MavenSession;
 import org.codehaus.plexus.PlexusTestCase;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.collection.DependencyGraphTransformer;
+import org.sonatype.aether.collection.DependencyManager;
+import org.sonatype.aether.collection.DependencySelector;
+import org.sonatype.aether.collection.DependencyTraverser;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.repository.LocalRepository;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+import org.sonatype.aether.util.graph.manager.ClassicDependencyManager;
+import org.sonatype.aether.util.graph.selector.AndDependencySelector;
+import org.sonatype.aether.util.graph.selector.ExclusionDependencySelector;
+import org.sonatype.aether.util.graph.selector.OptionalDependencySelector;
+import org.sonatype.aether.util.graph.selector.ScopeDependencySelector;
+import org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
+import org.sonatype.aether.util.graph.transformer.NearestVersionConflictResolver;
+import org.sonatype.aether.util.graph.transformer.ConflictMarker;
+import org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner;
+import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator;
+import org.sonatype.aether.util.graph.traverser.FatArtifactTraverser;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
@@ -53,6 +75,14 @@ public abstract class AbstractArtifactCo
         super.setUp();
         artifactFactory = lookup( ArtifactFactory.class);        
         artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class );
+
+        RepositorySystemSession repoSession = initRepoSession();
+        MavenSession session =
+            new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(),
+                              new DefaultMavenExecutionResult() );
+
+        LegacySupport legacySupport = lookup(LegacySupport.class);
+        legacySupport.setSession( session );
     }
     
     @Override
@@ -297,4 +327,33 @@ public abstract class AbstractArtifactCo
             }
         }
     }
+
+    protected RepositorySystemSession initRepoSession()
+        throws Exception
+    {
+        DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
+        session.setIgnoreMissingArtifactDescriptor( true );
+        session.setIgnoreInvalidArtifactDescriptor( true );
+        DependencyTraverser depTraverser = new FatArtifactTraverser();
+        session.setDependencyTraverser( depTraverser );
+
+        DependencyManager depManager = new ClassicDependencyManager();
+        session.setDependencyManager( depManager );
+
+        DependencySelector depFilter =
+            new AndDependencySelector( new ScopeDependencySelector( "test", "provided" ),
+                                       new OptionalDependencySelector(), new ExclusionDependencySelector() );
+        session.setDependencySelector( depFilter );
+
+        DependencyGraphTransformer transformer =
+            new ChainedDependencyGraphTransformer( new ConflictMarker(), new JavaEffectiveScopeCalculator(),
+                                                   new NearestVersionConflictResolver(),
+                                                   new JavaDependencyContextRefiner() );
+        session.setDependencyGraphTransformer( transformer );
+
+        session.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepository().getBasedir() ) );
+
+        return session;
+    }
+
 }

Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java (original)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java Tue Aug 24 22:46:07 2010
@@ -27,6 +27,7 @@ import org.apache.maven.artifact.reposit
 import org.apache.maven.model.building.ModelBuildingException;
 import org.apache.maven.model.building.ModelProblem;
 import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.repository.internal.MavenRepositorySystemSession;
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
@@ -129,6 +130,7 @@ public abstract class AbstractMavenProje
         configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) );
         configuration.setProcessPlugins( false );
         configuration.setResolveDependencies( true );
+        initRepoSession( configuration );
 
         try
         {
@@ -157,8 +159,17 @@ public abstract class AbstractMavenProje
     {
         ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
         configuration.setLocalRepository( getLocalRepository() );
+        initRepoSession( configuration );
 
         return projectBuilder.build( pom, configuration ).getProject();
     }
 
+    protected void initRepoSession( ProjectBuildingRequest request )
+    {
+        File localRepo = new File( request.getLocalRepository().getBasedir() );
+        MavenRepositorySystemSession session = new MavenRepositorySystemSession();
+        session.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) );
+        request.setRepositorySession( session );
+    }
+
 }

Added: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java?rev=988749&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java (added)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java Tue Aug 24 22:46:07 2010
@@ -0,0 +1,82 @@
+package org.apache.maven.project;
+
+/*
+ * 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.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.impl.ArtifactResolver;
+import org.sonatype.aether.impl.internal.DefaultArtifactResolver;
+import org.sonatype.aether.resolution.ArtifactRequest;
+import org.sonatype.aether.resolution.ArtifactResolutionException;
+import org.sonatype.aether.resolution.ArtifactResult;
+import org.sonatype.aether.transfer.ArtifactNotFoundException;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Component( role = ArtifactResolver.class, hint = "classpath" )
+public class ClasspathArtifactResolver
+    extends DefaultArtifactResolver
+{
+
+    public List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
+                                                  Collection<? extends ArtifactRequest> requests )
+        throws ArtifactResolutionException
+    {
+        List<ArtifactResult> results = new ArrayList<ArtifactResult>();
+
+        for ( ArtifactRequest request : requests )
+        {
+            ArtifactResult result = new ArtifactResult( request );
+            results.add( result );
+
+            Artifact artifact = request.getArtifact();
+            if ( "maven-test".equals( artifact.getGroupId() ) )
+            {
+                String scope = artifact.getArtifactId().substring( "scope-".length() );
+
+                try
+                {
+                    artifact = artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir
+                        + "transitive-" + scope + "-dep.xml" ) );
+                    result.setArtifact( artifact );
+                }
+                catch ( FileNotFoundException e )
+                {
+                    throw new IllegalStateException( "Missing test POM for " + artifact );
+                }
+            }
+            else
+            {
+                result.addException( new ArtifactNotFoundException( artifact, null ) );
+                throw new ArtifactResolutionException( results );
+            }
+        }
+
+        return results;
+    }
+
+}

Propchange: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java (original)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java Tue Aug 24 22:46:07 2010
@@ -26,17 +26,9 @@ import java.util.Set;
 
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.lifecycle.*;
-import org.apache.maven.lifecycle.LifecycleExecutionException;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.PluginExecution;
-import org.apache.maven.plugin.InvalidPluginDescriptorException;
 import org.apache.maven.plugin.MojoExecution;
-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.plugin.prefix.NoPluginFoundForPrefixException;
-import org.apache.maven.plugin.version.PluginVersionResolutionException;
 
 /**
  * A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid
@@ -49,8 +41,6 @@ public class EmptyLifecycleExecutor
 {
 
     public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks )
-        throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
-        MojoNotFoundException
     {
         return new MavenExecutionPlan(null, null, null, new DefaultLifecycles() );
     }
@@ -102,14 +92,10 @@ public class EmptyLifecycleExecutor
     }
 
     public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session )
-        throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
-        PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
-        LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
     {
     }
 
     public List<MavenProject> executeForkedExecutions( MojoExecution mojoExecution, MavenSession session )
-        throws LifecycleExecutionException
     {
         return Collections.emptyList();
     }

Added: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java?rev=988749&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java (added)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java Tue Aug 24 22:46:07 2010
@@ -0,0 +1,78 @@
+package org.apache.maven.project;
+
+/*
+ * 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.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public class EmptyLifecyclePluginAnalyzer
+    implements LifeCyclePluginAnalyzer
+{
+    public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
+    {
+        Set<Plugin> plugins;
+
+        // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
+        if ( "JAR".equals( packaging ) )
+        {
+            plugins = new LinkedHashSet<Plugin>();
+
+            plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
+            plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );
+            plugins.add( newPlugin( "maven-surefire-plugin", "test" ) );
+            plugins.add( newPlugin( "maven-jar-plugin", "jar" ) );
+            plugins.add( newPlugin( "maven-install-plugin", "install" ) );
+            plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) );
+        }
+        else
+        {
+            plugins = Collections.emptySet();
+        }
+
+        return plugins;
+    }
+
+    private Plugin newPlugin( String artifactId, String... goals )
+    {
+        Plugin plugin = new Plugin();
+
+        plugin.setGroupId( "org.apache.maven.plugins" );
+        plugin.setArtifactId( artifactId );
+
+        for ( String goal : goals )
+        {
+            PluginExecution pluginExecution = new PluginExecution();
+            pluginExecution.setId( "default-" + goal );
+            pluginExecution.addGoal( goal );
+            plugin.addExecution( pluginExecution );
+        }
+
+        return plugin;
+    }
+
+}

Propchange: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java?rev=988749&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java (added)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java Tue Aug 24 22:46:07 2010
@@ -0,0 +1,59 @@
+package org.apache.maven.project;
+
+/*
+ * 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.io.File;
+
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public class LegacyLocalRepositoryManager
+    extends SimpleLocalRepositoryManager
+{
+
+    public LegacyLocalRepositoryManager( File basedir )
+    {
+        super( basedir );
+    }
+
+    public String getPathForLocalArtifact( Artifact artifact )
+    {
+        StringBuilder path = new StringBuilder( 128 );
+
+        path.append( artifact.getGroupId() ).append( '/' );
+
+        path.append( artifact.getExtension() ).append( 's' ).append( '/' );
+
+        path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
+
+        if ( artifact.getClassifier().length() > 0 )
+        {
+            path.append( '-' ).append( artifact.getClassifier() );
+        }
+
+        path.append( '.' ).append( artifact.getExtension() );
+
+        return path.toString();
+    }
+
+}

Propchange: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/LegacyLocalRepositoryManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java (original)
+++ maven/maven-3/trunk/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java Tue Aug 24 22:46:07 2010
@@ -24,6 +24,9 @@ import java.util.Iterator;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
+import org.sonatype.aether.impl.ArtifactDescriptorReader;
+import org.sonatype.aether.impl.ArtifactResolver;
 
 public class ProjectClasspathTest
     extends AbstractMavenProjectTestCase
@@ -33,11 +36,15 @@ public class ProjectClasspathTest
     public void setUp()
         throws Exception
     {
+        ArtifactResolver resolver = lookup( ArtifactResolver.class, "classpath" );
+        DefaultArtifactDescriptorReader pomReader = (DefaultArtifactDescriptorReader)lookup(ArtifactDescriptorReader.class);
+        pomReader.setArtifactResolver( resolver );
+
         projectBuilder = lookup( ProjectBuilder.class, "classpath" );
 
         // the metadata source looks up the default impl, so we have to trick it
         getContainer().addComponent( projectBuilder, ProjectBuilder.class, "default" );
-        
+
         repositorySystem = lookup( RepositorySystem.class );        
     }
    



Mime
View raw message