mirror of https://github.com/apache/maven.git
refactored the "single repository interface" to get rid of Project - replaced with sudo-repository interface to find reactor artifacts if any
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@747901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f2d3908905
commit
f4249d0a73
|
@ -68,6 +68,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
|||
import org.apache.maven.project.artifact.ActiveProjectArtifact;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.repository.MavenRepositoryWrapper;
|
||||
import org.apache.maven.repository.MavenRepositorySystem;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
@ -87,7 +88,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|||
* </ol>
|
||||
*/
|
||||
public class MavenProject
|
||||
implements Cloneable
|
||||
implements Cloneable, MavenRepositoryWrapper
|
||||
{
|
||||
public static final String EMPTY_PROJECT_GROUP_ID = "unknown";
|
||||
|
||||
|
@ -1705,6 +1706,11 @@ public class MavenProject
|
|||
{
|
||||
return getBuild() != null ? getBuild().getDefaultGoal() : null;
|
||||
}
|
||||
|
||||
public Artifact find( Artifact artifact )
|
||||
{
|
||||
return replaceWithActiveArtifact( artifact );
|
||||
}
|
||||
|
||||
public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
|
||||
{
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.maven.project.MavenProject;
|
|||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
import org.apache.maven.repository.MavenRepositoryWrapper;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
@ -461,7 +462,7 @@ public class MavenMetadataSource
|
|||
List<Dependency> dependencies,
|
||||
String inheritedScope,
|
||||
ArtifactFilter dependencyFilter,
|
||||
MavenProject project )
|
||||
MavenRepositoryWrapper reactor )
|
||||
throws InvalidDependencyVersionException
|
||||
{
|
||||
Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() );
|
||||
|
@ -486,7 +487,7 @@ public class MavenMetadataSource
|
|||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new InvalidDependencyVersionException( project.getId(), d, project.getFile(), e );
|
||||
throw new InvalidDependencyVersionException( reactor.getId(), d, reactor.getFile(), e );
|
||||
}
|
||||
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||
versionRange, d.getType(), d.getClassifier(),
|
||||
|
@ -527,9 +528,9 @@ public class MavenMetadataSource
|
|||
|
||||
artifact.setDependencyFilter( artifactFilter );
|
||||
|
||||
if ( project != null )
|
||||
if ( reactor != null )
|
||||
{
|
||||
artifact = project.replaceWithActiveArtifact( artifact );
|
||||
artifact = reactor.find( artifact );
|
||||
}
|
||||
|
||||
projectArtifacts.add( artifact );
|
||||
|
|
|
@ -181,7 +181,7 @@ public class LegacyMavenRepositorySystem
|
|||
return artifactFactory.createPluginArtifact( groupId, artifactId, versionRange );
|
||||
}
|
||||
|
||||
public Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project )
|
||||
public Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper project )
|
||||
throws InvalidDependencyVersionException
|
||||
{
|
||||
return MavenMetadataSource.createArtifacts( artifactFactory, dependencies, inheritedScope, dependencyFilter, project );
|
||||
|
|
|
@ -63,7 +63,7 @@ public interface MavenRepositorySystem
|
|||
|
||||
Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope, String inheritedScope );
|
||||
|
||||
Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project )
|
||||
Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenRepositoryWrapper reactor )
|
||||
throws InvalidDependencyVersionException;
|
||||
|
||||
// Repository creation
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
package org.apache.maven.repository;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
|
||||
/**
|
||||
* small repository implementation used to find artifact in a local source
|
||||
* instead of going out to the real repo. Used to search reactor for matches
|
||||
*
|
||||
* @author Oleg Gusakov
|
||||
* @version $Id$
|
||||
*
|
||||
*/
|
||||
public interface MavenRepositoryWrapper
|
||||
{
|
||||
/**
|
||||
* finds supplied artifact, if any, in the wrapped source
|
||||
*
|
||||
* @param artifact
|
||||
* @return
|
||||
*/
|
||||
Artifact find( Artifact artifact );
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
File getFile();
|
||||
}
|
Loading…
Reference in New Issue