mirror of https://github.com/apache/maven.git
move artifact factory to maven-artifact
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@164178 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
21d261f503
commit
c98b557ac8
|
@ -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 );
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
@ -173,5 +176,9 @@
|
|||
<implementation>org.apache.maven.artifact.handler.WarHandler</implementation>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -760,7 +760,7 @@ public class DefaultPluginManager
|
|||
context.getLocalRepository(),
|
||||
sourceReader, filter );
|
||||
|
||||
project.addArtifacts( result.getArtifacts().values() );
|
||||
project.addArtifacts( result.getArtifacts().values(), artifactFactory );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -226,13 +226,6 @@
|
|||
</configuration>
|
||||
</component>
|
||||
|
||||
<!-- ********************* FIXME *******************************************
|
||||
| I realize this is duplicated but allows the project builder to work by itself
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
|
||||
</component>
|
||||
<!-- ********************* FIXME *******************************************
|
||||
| I realize this is duplicated but allows the project builder to work by itself
|
||||
-->
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
<settingsPath>${user.home}/.m2/settings.xml</settingsPath>
|
||||
</configuration>
|
||||
</component>
|
||||
|
||||
<!-- Duplicated from Maven artifact as it is used in the plugin manager -->
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ProjectClasspathArtifactResolver
|
|||
{
|
||||
IOUtil.close( r );
|
||||
}
|
||||
return artifactFactory.createArtifacts( model.getDependencies(), artifact.getScope() );
|
||||
return createArtifacts( model.getDependencies(), artifact.getScope() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
-->
|
||||
|
@ -24,6 +27,9 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
</components>
|
||||
|
|
|
@ -67,9 +67,7 @@
|
|||
</repository>
|
||||
</distributionManagement>
|
||||
<modules>
|
||||
<!--
|
||||
<module>maven-assembly-plugin</module>
|
||||
-->
|
||||
<module>maven-clean-plugin</module>
|
||||
<module>maven-compiler-plugin</module>
|
||||
<module>maven-deploy-plugin</module>
|
||||
|
|
Loading…
Reference in New Issue