diff --git a/maven-core/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java b/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java
similarity index 81%
rename from maven-core/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java
rename to maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java
index 6f0e710bf5..b1689997cc 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.java
@@ -17,18 +17,13 @@ package org.apache.maven.artifact.factory;
*/
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Dependency;
-
-import java.util.List;
-import java.util.Set;
public interface ArtifactFactory
{
static String ROLE = ArtifactFactory.class.getName();
- Set createArtifacts( List dependencies, String inheritedScope );
-
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 );
}
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/construction/ArtifactConstructionSupport.java b/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
similarity index 95%
rename from maven-artifact/src/main/java/org/apache/maven/artifact/construction/ArtifactConstructionSupport.java
rename to maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
index 164b7bb10c..2c392ad199 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/construction/ArtifactConstructionSupport.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
@@ -1,4 +1,4 @@
-package org.apache.maven.artifact.construction;
+package org.apache.maven.artifact.factory;
/*
* Copyright 2001-2005 The Apache Software Foundation.
@@ -19,12 +19,9 @@ package org.apache.maven.artifact.construction;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
-/**
- * @author jdcasey
- */
-public class ArtifactConstructionSupport
+public class DefaultArtifactFactory
+ implements ArtifactFactory
{
-
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
{
return createArtifact( groupId, artifactId, version, scope, type, null, null );
@@ -70,7 +67,7 @@ public class ArtifactConstructionSupport
}
DefaultArtifact artifact = new DefaultArtifact( groupId, artifactId, version, desiredScope, type, classifier );
-
+
return artifact;
}
}
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
index d3883e89f1..5a4df6525b 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
@@ -17,7 +17,7 @@ package org.apache.maven.artifact.resolver;
*/
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
+import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
@@ -48,8 +48,6 @@ public class DefaultArtifactResolver
extends AbstractLogEnabled
implements ArtifactResolver
{
- private final ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
-
// ----------------------------------------------------------------------
// Components
// ----------------------------------------------------------------------
@@ -60,6 +58,8 @@ public class DefaultArtifactResolver
private List artifactTransformations;
+ private ArtifactFactory artifactFactory;
+
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
@@ -275,11 +275,10 @@ public class DefaultArtifactResolver
// TODO: Artifact factory?
// TODO: [jc] Is this a better way to centralize artifact construction here?
- Artifact artifact = artifactConstructionSupport.createArtifact( knownArtifact.getGroupId(),
- knownArtifact.getArtifactId(),
- knownVersion,
- newArtifact.getScope(),
- knownArtifact.getType() );
+ Artifact artifact = artifactFactory.createArtifact( knownArtifact.getGroupId(),
+ knownArtifact.getArtifactId(),
+ knownVersion, newArtifact.getScope(),
+ knownArtifact.getType() );
resolvedArtifacts.put( artifact.getConflictId(), artifact );
}
}
diff --git a/maven-artifact/src/main/resources/META-INF/plexus/components.xml b/maven-artifact/src/main/resources/META-INF/plexus/components.xml
index 6e9dd90eb3..ab3dcc2bff 100644
--- a/maven-artifact/src/main/resources/META-INF/plexus/components.xml
+++ b/maven-artifact/src/main/resources/META-INF/plexus/components.xml
@@ -49,6 +49,9 @@
org.apache.maven.artifact.transform.ArtifactTransformation
artifactTransformations
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
@@ -173,5 +176,9 @@
org.apache.maven.artifact.handler.WarHandler
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+ org.apache.maven.artifact.factory.DefaultArtifactFactory
+
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java
index b6a177c58d..5b81af932e 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java
@@ -23,6 +23,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.project.MavenProject;
@@ -34,6 +35,8 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -131,6 +134,25 @@ public class MavenMetadataSource
IoUtils.close( reader );
}
}
- return artifactFactory.createArtifacts( dependencies, artifact.getScope() );
+ return createArtifacts( dependencies, artifact.getScope() );
+ }
+
+ protected Set createArtifacts( List dependencies, String inheritedScope )
+ {
+ Set projectArtifacts = new HashSet();
+
+ for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+ {
+ Dependency d = (Dependency) i.next();
+
+ Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
+ d.getScope(), d.getType(), inheritedScope );
+ if ( artifact != null )
+ {
+ projectArtifacts.add( artifact );
+ }
+ }
+
+ return projectArtifacts;
}
}
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java b/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
deleted file mode 100644
index 1b76e0c641..0000000000
--- a/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.maven.artifact.factory;
-
-/*
- * 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.
- */
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Dependency;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-public class DefaultArtifactFactory
- extends ArtifactConstructionSupport
- implements ArtifactFactory
-{
- public Set createArtifacts( List dependencies, String inheritedScope )
- {
- Set projectArtifacts = new HashSet();
-
- for ( Iterator i = dependencies.iterator(); i.hasNext(); )
- {
- Dependency d = (Dependency) i.next();
-
- Artifact artifact = createArtifact( d, inheritedScope );
- if ( artifact != null )
- {
- projectArtifacts.add( artifact );
- }
- }
-
- return projectArtifacts;
- }
-
- private Artifact createArtifact( Dependency dependency, String inheritedScope )
- {
- return createArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(),
- dependency.getScope(), dependency.getType(), inheritedScope );
- }
-
-}
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
index c904e58c8c..f12005d30a 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
@@ -760,7 +760,7 @@ public class DefaultPluginManager
context.getLocalRepository(),
sourceReader, filter );
- project.addArtifacts( result.getArtifacts().values() );
+ project.addArtifacts( result.getArtifacts().values(), artifactFactory );
}
// ----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
index f52f49c2e5..4b14d0dd4c 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
@@ -30,6 +30,7 @@ import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Repository;
+import org.apache.maven.model.Dependency;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
import org.apache.maven.project.injection.ModelDefaultsInjector;
@@ -62,6 +63,8 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
/**
* @version $Id: DefaultMavenProjectBuilder.java,v 1.37 2005/03/08 01:55:22
@@ -75,7 +78,6 @@ public class DefaultMavenProjectBuilder
private ArtifactResolver artifactResolver;
- // TODO: comes from Maven CORE
private ArtifactFactory artifactFactory;
private ModelInheritanceAssembler modelInheritanceAssembler;
@@ -251,7 +253,7 @@ public class DefaultMavenProjectBuilder
project.setParent( parentProject );
project.setRemoteArtifactRepositories( remoteRepositories );
- project.setArtifacts( artifactFactory.createArtifacts( project.getDependencies(), null ) );
+ project.setArtifacts( createArtifacts( project.getDependencies() ) );
// ----------------------------------------------------------------------
// Typically when the project builder is being used from maven proper
@@ -274,7 +276,7 @@ public class DefaultMavenProjectBuilder
remoteRepositories,
localRepository, sourceReader );
- project.addArtifacts( result.getArtifacts().values() );
+ project.addArtifacts( result.getArtifacts().values(), artifactFactory );
}
ModelValidationResult validationResult = validator.validate( model );
@@ -477,6 +479,25 @@ public class DefaultMavenProjectBuilder
return groupId + ":" + artifactId + ":" + version;
}
+ protected Set createArtifacts( List dependencies )
+ {
+ Set projectArtifacts = new HashSet();
+
+ for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+ {
+ Dependency d = (Dependency) i.next();
+
+ Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
+ d.getScope(), d.getType(), null );
+ if ( artifact != null )
+ {
+ projectArtifacts.add( artifact );
+ }
+ }
+
+ return projectArtifacts;
+ }
+
public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository )
throws ProjectBuildingException
{
diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index 8a934759cb..811aafd887 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -19,7 +19,7 @@ package org.apache.maven.project;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
+import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Build;
import org.apache.maven.model.CiManagement;
@@ -77,8 +77,6 @@ public class MavenProject
private List collectedProjects = Collections.EMPTY_LIST;
- private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
-
public MavenProject( Model model )
{
this.model = model;
@@ -633,7 +631,7 @@ public class MavenProject
this.collectedProjects = collectedProjects;
}
- public void addArtifacts( Collection newArtifacts )
+ public void addArtifacts( Collection newArtifacts, ArtifactFactory artifactFactory )
{
// project.getArtifacts().addAll( result.getArtifacts().values() );
// We need to override the scope if one declared it higher
@@ -668,10 +666,10 @@ public class MavenProject
{
// TODO: Artifact factory?
// TODO: [jc] Is this a better way to centralize artifact construction here?
- Artifact artifact = artifactConstructionSupport.createArtifact( existing.getGroupId(),
- existing.getArtifactId(),
- existing.getVersion(),
- a.getScope(), existing.getType() );
+ Artifact artifact = artifactFactory.createArtifact( existing.getGroupId(),
+ existing.getArtifactId(),
+ existing.getVersion(), a.getScope(),
+ existing.getType() );
artifact.setFile( existing.getFile() );
artifact.setBaseVersion( existing.getBaseVersion() );
diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml
index c7acd3e0df..5b8e124b9f 100644
--- a/maven-core/src/main/resources/META-INF/plexus/components.xml
+++ b/maven-core/src/main/resources/META-INF/plexus/components.xml
@@ -226,13 +226,6 @@
-
-
- org.apache.maven.artifact.factory.ArtifactFactory
- org.apache.maven.artifact.factory.DefaultArtifactFactory
-
diff --git a/maven-core/src/main/resources/META-INF/plexus/plexus.xml b/maven-core/src/main/resources/META-INF/plexus/plexus.xml
index 4db9d83e68..a48b21967e 100644
--- a/maven-core/src/main/resources/META-INF/plexus/plexus.xml
+++ b/maven-core/src/main/resources/META-INF/plexus/plexus.xml
@@ -58,6 +58,8 @@
${user.home}/.m2/settings.xml
+
+
org.apache.maven.artifact.factory.ArtifactFactory
org.apache.maven.artifact.factory.DefaultArtifactFactory
diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java b/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java
index 6557f120ff..a1953f91a3 100644
--- a/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java
+++ b/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java
@@ -77,7 +77,7 @@ public class ProjectClasspathArtifactResolver
{
IOUtil.close( r );
}
- return artifactFactory.createArtifacts( model.getDependencies(), artifact.getScope() );
+ return createArtifacts( model.getDependencies(), artifact.getScope() );
}
}
diff --git a/maven-core/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml b/maven-core/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
index 65ec9d3ebb..44f6336f15 100644
--- a/maven-core/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
+++ b/maven-core/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
@@ -11,6 +11,9 @@
org.apache.maven.artifact.handler.manager.ArtifactHandlerManager
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
-->
@@ -24,6 +27,9 @@
org.apache.maven.artifact.handler.manager.ArtifactHandlerManager
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
diff --git a/maven-plugins/pom.xml b/maven-plugins/pom.xml
index a8d1d808c1..8cb4edb761 100644
--- a/maven-plugins/pom.xml
+++ b/maven-plugins/pom.xml
@@ -67,9 +67,7 @@
-
maven-clean-plugin
maven-compiler-plugin
maven-deploy-plugin