You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/07/19 07:05:01 UTC

svn commit: r219616 - in /maven/components/trunk: maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/ maven-artifact-manager/src/test/java/org/apache/maven/artifact/ maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ m...

Author: brett
Date: Mon Jul 18 22:04:39 2005
New Revision: 219616

URL: http://svn.apache.org/viewcvs?rev=219616&view=rev
Log:
PR: MNG-505
artifact refactoring to facilitate version ranges


Added:
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java   (with props)
Modified:
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
    maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java
    maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
    maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
    maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/InvalidArtifactDiagnoserTest.java
    maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java Mon Jul 18 22:04:39 2005
@@ -16,21 +16,21 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.settings.Mirror;
-import org.apache.maven.settings.Server;
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
 import org.apache.maven.model.Model;
 import org.apache.maven.profiles.activation.ProfileActivationUtils;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
@@ -104,20 +104,20 @@
             manager.addProxy( proxy.getType(), proxy.getHost(), proxy.getPort(), proxy.getUserName(),
                               proxy.getPassword(), proxy.getNonProxyHosts() );
         }
-        
+
         ArtifactRepositoryFactory repositoryFactory = null;
-        
+
         ArtifactRepository artifactRepository;
-        
+
         try
         {
             repositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
-            
+
             String snapshotPolicy = repository.getSnapshotPolicy();
             String checksumPolicy = repository.getChecksumPolicy();
-            
-            artifactRepository = repositoryFactory.createArtifactRepository( "remote", repository.getUrl(), 
-                                                                             repositoryLayout, snapshotPolicy, 
+
+            artifactRepository = repositoryFactory.createArtifactRepository( "remote", repository.getUrl(),
+                                                                             repositoryLayout, snapshotPolicy,
                                                                              checksumPolicy );
         }
         finally
@@ -260,9 +260,9 @@
                 try
                 {
                     ClassWorld classWorld = new ClassWorld();
-                    
-                    ClassRealm classRealm = classWorld.newRealm( "plexus.core", getClass().getClassLoader() );
-                    
+
+                    classWorld.newRealm( "plexus.core", getClass().getClassLoader() );
+
                     embedder.start( classWorld );
                 }
                 catch ( PlexusContainerException e )
@@ -273,7 +273,7 @@
                 {
                     throw new BuildException( "Unable to create embedder ClassRealm", e );
                 }
-                
+
                 getProject().addReference( Embedder.class.getName(), embedder );
             }
         }
@@ -307,18 +307,18 @@
     protected Pom createDummyPom()
     {
         Model mavenModel = new Model();
-        
+
         mavenModel.setGroupId( "unspecified" );
         mavenModel.setArtifactId( "unspecified" );
         mavenModel.setVersion( "0.0" );
         mavenModel.setPackaging( "jar" );
-        
+
         MavenProject mavenProject = new MavenProject( mavenModel );
-        
+
         Pom pom = new Pom();
-        
+
         pom.setMavenProject( mavenProject );
-        
+
         return pom;
     }
 
@@ -360,8 +360,6 @@
     {
         ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
         // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
-        Artifact artifact = factory.createArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), null,
-                                                    pom.getPackaging() );
-        return artifact;
+        return factory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), pom.getPackaging() );
     }
 }

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java Mon Jul 18 22:04:39 2005
@@ -63,7 +63,7 @@
         ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
         MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
         ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
-        MavenMetadataSource metadataSource = new MavenMetadataSource( resolver, projectBuilder, artifactFactory );
+        MavenMetadataSource metadataSource = new MavenMetadataSource( projectBuilder, artifactFactory );
 
         List dependencies = this.dependencies;
 
@@ -101,8 +101,8 @@
         ArtifactResolutionResult result;
         try
         {
-            Artifact pomArtifact = artifactFactory.createArtifact( pom.getGroupId(), pom.getArtifactId(),
-                                                                   pom.getVersion(), null, pom.getPackaging() );
+            Artifact pomArtifact = artifactFactory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(),
+                                                                        pom.getVersion(), pom.getPackaging() );
 
             List listeners = Collections.EMPTY_LIST;
             if ( verbose )

Modified: maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java (original)
+++ maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java Mon Jul 18 22:04:39 2005
@@ -16,7 +16,7 @@
 
 package org.apache.maven.artifact;
 
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
@@ -56,10 +56,7 @@
         ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
                                                                                  "legacy" );
 
-        ArtifactRepository localRepository = new DefaultArtifactRepository( "test", "file://" + f.getPath(),
-                                                                            repoLayout );
-
-        return localRepository;
+        return (ArtifactRepository) new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
     }
 
     protected String getRepositoryLayout()
@@ -77,10 +74,7 @@
         ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
                                                                                  "legacy" );
 
-        ArtifactRepository localRepository = new DefaultArtifactRepository( "local", "file://" + f.getPath(),
-                                                                            repoLayout );
-
-        return localRepository;
+        return (ArtifactRepository) new DefaultArtifactRepository( "local", "file://" + f.getPath(), repoLayout );
     }
 
     protected ArtifactRepository remoteRepository()
@@ -93,11 +87,9 @@
         ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
                                                                                  "legacy" );
 
-        ArtifactRepository repository = new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
-                                                                       ArtifactRepository.SNAPSHOT_POLICY_NEVER,
-                                                                       ArtifactRepository.CHECKSUM_POLICY_WARN );
-
-        return repository;
+        return (ArtifactRepository) new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
+                                                                   ArtifactRepository.SNAPSHOT_POLICY_NEVER,
+                                                                   ArtifactRepository.CHECKSUM_POLICY_WARN );
     }
 
     protected ArtifactRepository badRemoteRepository()
@@ -106,10 +98,7 @@
         ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
                                                                                  "legacy" );
 
-        ArtifactRepository repository = new DefaultArtifactRepository( "test", "http://foo.bar/repository",
-                                                                       repoLayout );
-
-        return repository;
+        return (ArtifactRepository) new DefaultArtifactRepository( "test", "http://foo.bar/repository", repoLayout );
     }
 
     protected void assertRemoteArtifactPresent( Artifact artifact )
@@ -242,22 +231,24 @@
     }
 
     protected Artifact createArtifact( String artifactId, String version )
+        throws Exception
     {
         return createArtifact( artifactId, version, "jar" );
     }
 
     protected Artifact createArtifact( String artifactId, String version, String type )
+        throws Exception
     {
-        // TODO: fix handler instantiation
-        return new DefaultArtifact( "org.apache.maven", artifactId, version, null, type, null,
-                                    new DefaultArtifactHandler( type ) );
+        return createArtifact( "org.apache.maven", artifactId, version, type );
     }
 
     protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
+        throws Exception
     {
-        // TODO: fix handler instantiation
-        return new DefaultArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE, type, null,
-                                    new DefaultArtifactHandler( type ) );
+        ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
+        // TODO: used to be SCOPE_COMPILE, check
+        return artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
     }
 
     protected void deleteLocalArtifact( Artifact artifact )

Modified: maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java (original)
+++ maven/components/trunk/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java Mon Jul 18 22:04:39 2005
@@ -20,6 +20,7 @@
 import org.apache.maven.artifact.ArtifactComponentTestCase;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.metadata.ResolutionGroup;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 
 import java.util.ArrayList;
@@ -82,6 +83,7 @@
     }
 
     protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
+        throws Exception
     {
         // for the anonymous classes
         return super.createArtifact( groupId, artifactId, version, type );
@@ -97,12 +99,20 @@
         ArtifactMetadataSource mds = new ArtifactMetadataSource()
         {
             public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
+                throws ArtifactMetadataRetrievalException
             {
                 Set dependencies = new HashSet();
 
                 if ( artifact.getArtifactId().equals( "g" ) )
                 {
-                    dependencies.add( createArtifact( "org.apache.maven", "h", "1.0", "jar" ) );
+                    try
+                    {
+                        dependencies.add( createArtifact( "org.apache.maven", "h", "1.0", "jar" ) );
+                    }
+                    catch ( Exception e )
+                    {
+                        throw new ArtifactMetadataRetrievalException( e );
+                    }
                 }
 
                 return new ResolutionGroup( dependencies, remoteRepositories );
@@ -136,12 +146,20 @@
         ArtifactMetadataSource mds = new ArtifactMetadataSource()
         {
             public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
+                throws ArtifactMetadataRetrievalException
             {
                 Set dependencies = new HashSet();
 
                 if ( artifact.getArtifactId().equals( "i" ) )
                 {
-                    dependencies.add( createArtifact( "org.apache.maven", "j", "1.0", "jar" ) );
+                    try
+                    {
+                        dependencies.add( createArtifact( "org.apache.maven", "j", "1.0", "jar" ) );
+                    }
+                    catch ( Exception e )
+                    {
+                        throw new ArtifactMetadataRetrievalException( e );
+                    }
                 }
 
                 return new ResolutionGroup( dependencies, remoteRepositories );

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java Mon Jul 18 22:04:39 2005
@@ -20,6 +20,7 @@
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
@@ -71,8 +72,7 @@
 
     private List dependencyTrail;
 
-    // TODO: direct all through the artifact factory
-    public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type,
+    public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type,
                             String classifier, ArtifactHandler artifactHandler )
     {
         this.groupId = groupId;
@@ -80,7 +80,7 @@
         this.artifactId = artifactId;
 
         // TODO: this would be where we might have a min/max instead
-        this.version = version;
+        this.version = versionRange.getVersion();
 
         this.artifactHandler = artifactHandler;
 

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java Mon Jul 18 22:04:39 2005
@@ -17,16 +17,43 @@
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.VersionRange;
 
 public interface ArtifactFactory
 {
     static String ROLE = ArtifactFactory.class.getName();
 
+    /**
+     * @deprecated
+     */
     Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
                              String inheritedScope );
 
-    Artifact createArtifact( String groupId, String artifactId, String knownVersion, String scope, String type );
-    
-    Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope,
-                                                  String type, String classifier );
+    // TODO: deprecate and chase down (probably used for copying only)
+    Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type );
+
+    /**
+     * @deprecated
+     */
+    Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope, String type,
+                                           String classifier );
+
+    Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type,
+                                           String classifier );
+
+    Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
+                                       String scope );
+
+    Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
+                                       String scope, String inheritedScope );
+
+    Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging );
+
+    Artifact createProjectArtifact( String groupId, String artifactId, String version );
+
+    Artifact createParentArtifact( String groupId, String artifactId, String version );
+
+    Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange );
+
+    Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope );
 }

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java (original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java Mon Jul 18 22:04:39 2005
@@ -20,6 +20,7 @@
 import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.versioning.VersionRange;
 
 public class DefaultArtifactFactory
     implements ArtifactFactory
@@ -47,6 +48,49 @@
         return createArtifact( groupId, artifactId, version, scope, type, classifier, null );
     }
 
+    public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type,
+                                                  String classifier )
+    {
+        return createArtifact( groupId, artifactId, version, null, type, classifier, null );
+    }
+
+    public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
+                                              String scope )
+    {
+        return createArtifact( groupId, artifactId, versionRange, null, type, null, null );
+    }
+
+    public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
+                                              String scope, String inheritedScope )
+    {
+        return createArtifact( groupId, artifactId, versionRange, scope, type, null, inheritedScope );
+    }
+
+    public Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging )
+    {
+        return createArtifact( groupId, artifactId, version, null, packaging, null, null );
+    }
+
+    public Artifact createProjectArtifact( String groupId, String artifactId, String version )
+    {
+        return createProjectArtifact( groupId, artifactId, version, null );
+    }
+
+    public Artifact createParentArtifact( String groupId, String artifactId, String version )
+    {
+        return createProjectArtifact( groupId, artifactId, version );
+    }
+
+    public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange )
+    {
+        return createArtifact( groupId, artifactId, versionRange, Artifact.SCOPE_RUNTIME, "maven-plugin", null, null );
+    }
+
+    public Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope )
+    {
+        return createArtifact( groupId, artifactId, version, scope, "pom" );
+    }
+
     public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
                                     String inheritedScope )
     {
@@ -56,6 +100,22 @@
     private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
                                      String classifier, String inheritedScope )
     {
+        // TODO: better constructor
+        VersionRange versionRange;
+        if ( version != null )
+        {
+            versionRange = new VersionRange( "[" + version + "]" );
+        }
+        else
+        {
+            versionRange = new VersionRange( null );
+        }
+        return createArtifact( groupId, artifactId, versionRange, scope, type, classifier, inheritedScope );
+    }
+
+    private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope,
+                                     String type, String classifier, String inheritedScope )
+    {
         // TODO: can refactor - inherited scope calculation belongs in the collector, use scope handler
 
         String desiredScope = Artifact.SCOPE_RUNTIME;
@@ -87,6 +147,6 @@
 
         ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type );
 
-        return new DefaultArtifact( groupId, artifactId, version, desiredScope, type, classifier, handler );
+        return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, classifier, handler );
     }
 }

Added: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java?rev=219616&view=auto
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java (added)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java Mon Jul 18 22:04:39 2005
@@ -0,0 +1,47 @@
+package org.apache.maven.artifact.versioning;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Construct a version range from a specification.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class VersionRange
+{
+    private String version;
+
+    public VersionRange( String spec )
+    {
+        if ( spec != null )
+        {
+            // temporary!
+            if ( spec.startsWith( "[" ) )
+            {
+                spec = spec.substring( 1, spec.length() - 1 );
+            }
+        }
+
+        this.version = spec;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+}

Propchange: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Mon Jul 18 22:04:39 2005
@@ -29,6 +29,7 @@
 import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
 import org.apache.maven.artifact.resolver.filter.InversionArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.ReportPlugin;
@@ -165,8 +166,8 @@
             String groupId = plugin.getGroupId();
             String artifactId = plugin.getArtifactId();
 
-            plugin.setVersion( pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, settings,
-                                                                          localRepository ) );
+            plugin.setVersion(
+                pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, settings, localRepository ) );
         }
 
         // TODO: this might result in an artifact "RELEASE" being resolved continuously
@@ -174,14 +175,13 @@
         {
             try
             {
-                Artifact pluginArtifact = artifactFactory.createArtifact( plugin.getGroupId(),
-                                                                          plugin.getArtifactId(),
-                                                                          plugin.getVersion(),
-                                                                          Artifact.SCOPE_RUNTIME,
-                                                                          MojoDescriptor.MAVEN_PLUGIN );
-
-                // TODO: [jc; 2005-july-06] what's this for?
-                //plugin.setVersion( pluginArtifact.getBaseVersion() );
+                VersionRange versionRange = new VersionRange( plugin.getVersion() );
+                Artifact pluginArtifact = artifactFactory.createPluginArtifact( plugin.getGroupId(),
+                                                                                plugin.getArtifactId(), versionRange );
+
+                // I think this ensures the plugin is not resolved multiple times
+                // TODO: put it back
+//                plugin.setVersion( pluginArtifact.getBaseVersion() );
 
                 addPlugin( plugin, pluginArtifact, project, localRepository );
 
@@ -198,10 +198,9 @@
                 String artifactId = plugin.getArtifactId();
                 String version = plugin.getVersion();
 
-                if (
-                    ( groupId == null || artifactId == null || version == null ||
-                        ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
-                            version.equals( e.getVersion() ) ) ) && "maven-plugin".equals( e.getType() ) )
+                if ( ( groupId == null || artifactId == null || version == null || ( groupId.equals( e.getGroupId() ) &&
+                    artifactId.equals( e.getArtifactId() ) && version.equals( e.getVersion() ) ) ) &&
+                    "maven-plugin".equals( e.getType() ) )
                 {
                     throw new PluginNotFoundException( e );
                 }
@@ -222,7 +221,8 @@
         artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
 
         PlexusContainer child = container.createChildContainer( plugin.getKey(), Collections
-            .singletonList( pluginArtifact.getFile() ), Collections.EMPTY_MAP, Collections.singletonList( pluginCollector ) );
+            .singletonList( pluginArtifact.getFile() ), Collections.EMPTY_MAP,
+                                                        Collections.singletonList( pluginCollector ) );
 
         // this plugin's descriptor should have been discovered in the child creation, so we should be able to
         // circle around and set the artifacts and class realm
@@ -328,10 +328,9 @@
         }
     }
 
-    public List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project,
-                            MavenSession session, ArtifactRepository localRepository )
-        throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException,
-        ArtifactResolutionException
+    public List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
+                            ArtifactRepository localRepository )
+        throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException, ArtifactResolutionException
     {
         Plugin forLookup = new Plugin();
         forLookup.setGroupId( reportPlugin.getGroupId() );
@@ -360,7 +359,8 @@
                     MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, id );
 
                     String executionId = mojoExecution.getExecutionId();
-                    Xpp3Dom dom = project.getReportConfiguration( reportPlugin.getGroupId(), reportPlugin.getArtifactId(), executionId );
+                    Xpp3Dom dom = project.getReportConfiguration( reportPlugin.getGroupId(),
+                                                                  reportPlugin.getArtifactId(), executionId );
 
                     reports.add( getConfiguredMojo( mojoDescriptor, session, dom, project ) );
                 }
@@ -451,8 +451,7 @@
 
             try
             {
-                MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
-                                                                              artifactFactory );
+                MavenMetadataSource metadataSource = new MavenMetadataSource( mavenProjectBuilder, artifactFactory );
 
                 List remoteRepositories = new ArrayList();
 
@@ -543,9 +542,8 @@
                 // ideally, this would be elevated above the true debug output, but below the default INFO level...
                 // [BP] (2004-07-18): need to understand the context more but would prefer this could be either WARN or
                 // removed - shouldn't need DEBUG to diagnose a problem most of the time.
-                getLogger().debug(
-                    "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" +
-                        mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" );
+                getLogger().debug( "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" +
+                    mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" );
             }
         }
 
@@ -631,9 +629,8 @@
                         }
                         if ( fieldValue != null )
                         {
-                            getLogger().warn(
-                                "DEPRECATED: using default-value to set the default value of field '" +
-                                    parameter.getName() + "'" );
+                            getLogger().warn( "DEPRECATED: using default-value to set the default value of field '" +
+                                parameter.getName() + "'" );
                         }
                     }
                     catch ( NoSuchFieldException e )
@@ -920,14 +917,13 @@
                                                 ArtifactFactory artifactFactory, MavenProject project )
         throws ArtifactResolutionException
     {
-        MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
-                                                                    artifactFactory );
+        MavenMetadataSource sourceReader = new MavenMetadataSource( mavenProjectBuilder, artifactFactory );
 
         ArtifactFilter filter = new ScopeArtifactFilter( scope );
 
         // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
-        Artifact artifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
-                                                            project.getVersion(), null, project.getPackaging() );
+        Artifact artifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
+                                                                 project.getVersion(), project.getPackaging() );
 
         // TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same
         // check this with yourkit as a hot spot.

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java Mon Jul 18 22:04:39 2005
@@ -601,11 +601,10 @@
     private String resolveMetaVersion( String groupId, String artifactId, List remoteRepositories,
                                        ArtifactRepository localRepository, String metaVersionId )
     {
-        Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, metaVersionId, Artifact.SCOPE_RUNTIME,
-                                                            "pom" );
+        // TODO: check - this was SCOPE_RUNTIME before, now is null
+        Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
 
-        MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, projectBuilder,
-                                                                      artifactFactory );
+        MavenMetadataSource metadataSource = new MavenMetadataSource( projectBuilder, artifactFactory );
 
         String version = null;
         try

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java (original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java Mon Jul 18 22:04:39 2005
@@ -17,9 +17,9 @@
  */
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Build;
@@ -66,7 +66,8 @@
         assertEquals( expected, actual );
     }
 
-    private static MavenSession createSession( MavenProject project, PlexusContainer container, ArtifactRepository repo )
+    private static MavenSession createSession( MavenProject project, PlexusContainer container,
+                                               ArtifactRepository repo )
     {
         return new MavenSession( project, container, new Settings(), repo, new DefaultEventDispatcher(),
                                  Collections.EMPTY_LIST );
@@ -103,7 +104,7 @@
     {
         PluginDescriptor pd = new PluginDescriptor();
 
-        Artifact artifact = new DefaultArtifact( "testGroup", "testArtifact", "1.0", Artifact.SCOPE_COMPILE, "jar", null, null );
+        Artifact artifact = createArtifact( "testGroup", "testArtifact", "1.0" );
 
         pd.setArtifacts( Collections.singletonList( artifact ) );
 
@@ -138,9 +139,17 @@
         PlexusContainer container = getContainer();
         MavenSession session = createSession( project, container, repo );
 
-        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, pluginDescriptor,
-                                                                                          null, container.getLogger(),
-                                                                                          project );
-        return expressionEvaluator;
+        return (ExpressionEvaluator) new PluginParameterExpressionEvaluator( session, pluginDescriptor, null,
+                                                                             container.getLogger(), project );
+    }
+
+    protected Artifact createArtifact( String groupId, String artifactId, String version )
+        throws Exception
+    {
+        ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
+        // TODO: used to be SCOPE_COMPILE, check
+        return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );
     }
+
 }

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/InvalidArtifactDiagnoserTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/InvalidArtifactDiagnoserTest.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/InvalidArtifactDiagnoserTest.java (original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/InvalidArtifactDiagnoserTest.java Mon Jul 18 22:04:39 2005
@@ -1,6 +1,9 @@
 package org.apache.maven.usability;
 
 import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.codehaus.plexus.PlexusTestCase;
 
 import junit.framework.TestCase;
 
@@ -21,9 +24,8 @@
  */
 
 public class InvalidArtifactDiagnoserTest
-    extends TestCase
+    extends PlexusTestCase
 {
-
     private InvalidArtifactDiagnoser diagnoser = new InvalidArtifactDiagnoser();
 
     public void testShouldDiagnoseArtifactWithMissingGroupId() throws Throwable
@@ -61,7 +63,7 @@
 
         try
         {
-            new DefaultArtifact( groupId, artifactId, version, null, type, null, null );
+            createArtifact( groupId, artifactId, version, type );
 
             fail( "artifact creation did not fail; nothing to diagnose." );
         }
@@ -79,4 +81,12 @@
             }
         }
     }
+
+    private Artifact createArtifact( String groupId, String artifactId, String version, String type )
+        throws Exception
+    {
+        ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+        return artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
+    }
+
 }

Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java (original)
+++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Mon Jul 18 22:04:39 2005
@@ -16,24 +16,23 @@
  * limitations under the License.
  */
 
-import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.codehaus.classworlds.ClassRealm;
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
-import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
 import org.apache.maven.plugin.lifecycle.Lifecycle;
+import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
 import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.util.List;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.io.InputStreamReader;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.FileNotFoundException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Mon Jul 18 22:04:39 2005
@@ -24,6 +24,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
@@ -120,7 +121,7 @@
                                                List externalProfiles )
         throws ProjectBuildingException, ArtifactResolutionException
     {
-        ArtifactMetadataSource source = new MavenMetadataSource( artifactResolver, this, artifactFactory );
+        ArtifactMetadataSource source = new MavenMetadataSource( this, artifactFactory );
         return buildWithDependencies( projectDescriptor, localRepository, source, externalProfiles );
     }
 
@@ -144,7 +145,7 @@
 
         // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
         Artifact projectArtifact = project.getArtifact();
-        
+
         Map managedVersions = createManagedVersionMap( project.getDependencyManagement() );
         ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
                                                                                 projectArtifact, managedVersions,
@@ -166,8 +167,9 @@
             {
                 Dependency d = (Dependency) i.next();
 
-                Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
-                                                                    d.getScope(), d.getType(), null );
+                Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
+                                                                              new VersionRange( d.getVersion() ),
+                                                                              d.getType(), d.getScope() );
 
                 map.put( d.getManagementKey(), artifact );
             }
@@ -194,7 +196,8 @@
         // Always cache files in the source tree over those in the repository
         modelCache.put( createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() ), model );
 
-        MavenProject project = build( projectDescriptor.getAbsolutePath(), model, localRepository, Collections.EMPTY_LIST, externalProfiles );
+        MavenProject project = build( projectDescriptor.getAbsolutePath(), model, localRepository,
+                                      Collections.EMPTY_LIST, externalProfiles );
 
         // Only translate the base directory for files in the source tree
         pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor );
@@ -216,7 +219,8 @@
     {
         Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
 
-        return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories, Collections.EMPTY_LIST );
+        return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories,
+                      Collections.EMPTY_LIST );
     }
 
     private Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
@@ -274,14 +278,14 @@
         if ( remoteArtifactRepositories == null || remoteArtifactRepositories.isEmpty() )
         {
             aggregatedRemoteWagonRepositories = ProjectUtils.buildArtifactRepositories( superModel.getRepositories(),
-                                                                                       artifactRepositoryFactory,
-                                                                                       container );
+                                                                                        artifactRepositoryFactory,
+                                                                                        container );
         }
         else
         {
             aggregatedRemoteWagonRepositories = remoteArtifactRepositories;
         }
-        
+
         for ( Iterator i = externalProfiles.iterator(); i.hasNext(); )
         {
             Profile externalProfile = (Profile) i.next();
@@ -379,16 +383,16 @@
         project.addProfileProperties( profileProperties );
 
         project.setActiveProfiles( activeProfiles );
-        
+
         // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
-        Artifact projectArtifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
-                                                                   project.getVersion(), null, project.getPackaging() );
-        
+        Artifact projectArtifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
+                                                                        project.getVersion(), project.getPackaging() );
+
         project.setArtifact( projectArtifact );
 
-        project.setPluginArtifactRepositories(
-            ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(), artifactRepositoryFactory,
-                                                    container ) );
+        project.setPluginArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(),
+                                                                                       artifactRepositoryFactory,
+                                                                                       container ) );
 
         DistributionManagement dm = model.getDistributionManagement();
         if ( dm != null )
@@ -401,9 +405,9 @@
 
         if ( parentProject != null )
         {
-            Artifact parentArtifact = artifactFactory.createArtifact( parentProject.getGroupId(),
-                                                                      parentProject.getArtifactId(),
-                                                                      parentProject.getVersion(), null, "pom" );
+            Artifact parentArtifact = artifactFactory.createProjectArtifact( parentProject.getGroupId(),
+                                                                             parentProject.getArtifactId(),
+                                                                             parentProject.getVersion() );
             project.setParentArtifact( parentArtifact );
         }
 
@@ -415,9 +419,8 @@
 
         if ( validationResult.getMessageCount() > 0 )
         {
-            throw new ProjectBuildingException(
-                "Failed to validate POM for \'" + pomLocation + "\'.\n\n  Reason(s):\n" +
-                    validationResult.render( "  " ) );
+            throw new ProjectBuildingException( "Failed to validate POM for \'" + pomLocation +
+                "\'.\n\n  Reason(s):\n" + validationResult.render( "  " ) );
         }
 
         return project;
@@ -431,11 +434,11 @@
         {
             List respositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
                                                                          artifactRepositoryFactory, container );
-            
+
             for ( Iterator it = respositories.iterator(); it.hasNext(); )
             {
                 ArtifactRepository repository = (ArtifactRepository) it.next();
-                
+
                 if ( !aggregatedRemoteWagonRepositories.contains( repository ) )
                 {
                     aggregatedRemoteWagonRepositories.add( repository );
@@ -473,8 +476,9 @@
             // as we go in order to do this.
             // ----------------------------------------------------------------------
 
-            Artifact artifact = artifactFactory.createArtifact( parentModel.getGroupId(), parentModel.getArtifactId(),
-                                                                parentModel.getVersion(), null, "pom" );
+            Artifact artifact = artifactFactory.createParentArtifact( parentModel.getGroupId(),
+                                                                      parentModel.getArtifactId(),
+                                                                      parentModel.getVersion() );
 
             model = findModelFromRepository( artifact, aggregatedRemoteWagonRepositories, localRepository );
 
@@ -504,15 +508,13 @@
         }
         catch ( IOException e )
         {
-            throw new ProjectBuildingException(
-                "Failed to build model from file '" + file.getAbsolutePath() + "'.\nError: \'" +
-                    e.getLocalizedMessage() + "\'", e );
+            throw new ProjectBuildingException( "Failed to build model from file '" + file.getAbsolutePath() +
+                "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
         }
         catch ( XmlPullParserException e )
         {
-            throw new ProjectBuildingException(
-                "Failed to parse model from file '" + file.getAbsolutePath() + "'.\nError: \'" +
-                    e.getLocalizedMessage() + "\'", e );
+            throw new ProjectBuildingException( "Failed to parse model from file '" + file.getAbsolutePath() +
+                "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
         }
         finally
         {
@@ -531,15 +533,13 @@
         }
         catch ( IOException e )
         {
-            throw new ProjectBuildingException(
-                "Failed build model from URL \'" + url.toExternalForm() + "\'\nError: \'" + e.getLocalizedMessage() +
-                    "\'", e );
+            throw new ProjectBuildingException( "Failed build model from URL \'" + url.toExternalForm() +
+                "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
         }
         catch ( XmlPullParserException e )
         {
-            throw new ProjectBuildingException(
-                "Failed to parse model from URL \'" + url.toExternalForm() + "\'\nError: \'" + e.getLocalizedMessage() +
-                    "\'", e );
+            throw new ProjectBuildingException( "Failed to parse model from URL \'" + url.toExternalForm() +
+                "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
         }
         finally
         {
@@ -580,8 +580,8 @@
                 version = p.getVersion();
             }
 
-            Artifact artifact = artifactFactory.createArtifact( p.getGroupId(), p.getArtifactId(), version, null,
-                                                                "maven-plugin" );
+            Artifact artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
+                                                                      new VersionRange( version ) );
             if ( artifact != null )
             {
                 pluginArtifacts.add( artifact );

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Mon Jul 18 22:04:39 2005
@@ -26,6 +26,7 @@
 import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Exclusion;
 import org.apache.maven.project.MavenProject;
@@ -50,8 +51,7 @@
     private ArtifactFactory artifactFactory;
 
     // TODO: Remove resolver from params list.
-    public MavenMetadataSource( ArtifactResolver artifactResolver, MavenProjectBuilder projectBuilder,
-                                ArtifactFactory artifactFactory )
+    public MavenMetadataSource( MavenProjectBuilder projectBuilder, ArtifactFactory artifactFactory )
     {
         this.mavenProjectBuilder = projectBuilder;
         this.artifactFactory = artifactFactory;
@@ -61,8 +61,8 @@
         throws ArtifactMetadataRetrievalException
     {
         // TODO: only metadata is really needed - resolve as metadata
-        Artifact pomArtifact = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
-                                                               artifact.getVersion(), artifact.getScope(), "pom" );
+        Artifact pomArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
+                                                               artifact.getVersion(), artifact.getScope() );
 
         // TODO: this a very thin wrapper around a project builder - is it needed?
         List dependencies = null;
@@ -75,9 +75,10 @@
                                                                       localRepository );
             dependencies = p.getDependencies();
             artifact.setDownloadUrl( pomArtifact.getDownloadUrl() );
-            
-            Set artifacts = createArtifacts( artifactFactory, dependencies, artifact.getScope(), artifact.getDependencyFilter() );
-            
+
+            Set artifacts = createArtifacts( artifactFactory, dependencies, artifact.getScope(),
+                                             artifact.getDependencyFilter() );
+
             return new ResolutionGroup( artifacts, p.getRemoteArtifactRepositories() );
         }
         catch ( ProjectBuildingException e )
@@ -95,8 +96,9 @@
         {
             Dependency d = (Dependency) i.next();
 
-            Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
-                                                                d.getScope(), d.getType(), inheritedScope );
+            Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
+                                                                          new VersionRange( d.getVersion() ),
+                                                                          d.getType(), d.getScope(), inheritedScope );
 
             if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
             {

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java?rev=219616&r1=219615&r2=219616&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java (original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java Mon Jul 18 22:04:39 2005
@@ -27,6 +27,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
@@ -51,23 +52,28 @@
     implements Contextualizable
 {
     private ArtifactRepositoryFactory repositoryFactory;
+
     private PlexusContainer container;
 
     public static class Source
         implements ArtifactMetadataSource
     {
         private ArtifactFactory artifactFactory;
+
         private final ArtifactRepositoryFactory repositoryFactory;
+
         private final PlexusContainer container;
 
-        public Source( ArtifactFactory artifactFactory, ArtifactRepositoryFactory repositoryFactory, PlexusContainer container )
+        public Source( ArtifactFactory artifactFactory, ArtifactRepositoryFactory repositoryFactory,
+                       PlexusContainer container )
         {
             this.artifactFactory = artifactFactory;
             this.repositoryFactory = repositoryFactory;
             this.container = container;
         }
 
-        public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
+        public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
+                                         List remoteRepositories )
             throws ArtifactMetadataRetrievalException
         {
             Model model = null;
@@ -101,19 +107,20 @@
             {
                 IOUtil.close( r );
             }
-            
+
             Set artifacts = createArtifacts( model.getDependencies(), artifact.getScope() );
-            
+
             List artifactRepositories;
             try
             {
-                artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(), repositoryFactory, container );
+                artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
+                                                                               repositoryFactory, container );
             }
             catch ( ProjectBuildingException e )
             {
                 throw new ArtifactMetadataRetrievalException( e );
             }
-            
+
             return new ResolutionGroup( artifacts, artifactRepositories );
         }
 
@@ -125,8 +132,10 @@
             {
                 Dependency d = (Dependency) i.next();
 
-                Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
-                                                                    d.getScope(), d.getType(), inheritedScope );
+                Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
+                                                                              new VersionRange( d.getVersion() ),
+                                                                              d.getType(), d.getScope(), 
+                                                                              inheritedScope );
                 if ( artifact != null )
                 {
                     projectArtifacts.add( artifact );
@@ -136,7 +145,7 @@
             return projectArtifacts;
         }
     }
-    
+
     public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
         throws ArtifactResolutionException
     {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org