o implement the find(Artifact) method in the default local repository

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@773769 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-05-12 02:43:26 +00:00
parent 3504931b37
commit 55ecfa65d6
8 changed files with 46 additions and 16 deletions

View File

@ -65,7 +65,7 @@ END SNIPPET: ant-bootstrap -->
<property name="maven.assembly" location="apache-maven/target/${maven.home.basename.expected}-bin.zip"/>
<property name="maven.repo.local" value="${user.home}/.m2/repository"/>
<property name="maven.debug" value="-e"/>
<property name="maven.test.skip" value="true"/> <!-- TODO: Change this default back to false once we're done -->
<property name="maven.test.skip" value="false"/> <!-- TODO: Change this default back to false once we're done -->
<property name="surefire.useFile" value="true"/>
<echo>maven.home = ${maven.home.effective}</echo>
<echo>maven.repo.local = ${maven.repo.local}</echo>

View File

@ -19,6 +19,8 @@
* under the License.
*/
import java.io.File;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
@ -192,6 +194,17 @@ public String toString()
public Artifact find( Artifact artifact )
{
return null;
File artifactFile = new File( getBasedir(), pathOf( artifact ) );
// We need to set the file here or the resolver will fail with an NPE, not fully equipped to deal
// with multiple local repository implementations yet.
artifact.setFile( artifactFile );
if( artifactFile.exists() )
{
artifact.setResolved( true );
}
return artifact;
}
}

View File

@ -42,8 +42,7 @@
// the layout used for a particular artifact type.
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @author Jason van Zyl
*/
public class ArtifactResolverTest
extends AbstractArtifactComponentTestCase

View File

@ -87,7 +87,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
MavenExecutionResult result = new DefaultMavenExecutionResult();
DelegatingLocalArtifactRepository delegatingLocalArtifactRepository = new DelegatingLocalArtifactRepository();
DelegatingLocalArtifactRepository delegatingLocalArtifactRepository = new DelegatingLocalArtifactRepository( request.getLocalRepository() );
delegatingLocalArtifactRepository.addToEndOfSearchOrder( new UserLocalArtifactRepository( request.getLocalRepository() ) );
if ( localArtifactRepositories != null && localArtifactRepositories.size() > 0 )

View File

@ -13,6 +13,13 @@ public class DelegatingLocalArtifactRepository
{
private List<LocalArtifactRepository> localRepositories;
private ArtifactRepository userLocalArtifactRepository;
public DelegatingLocalArtifactRepository( ArtifactRepository artifactRepository )
{
this.userLocalArtifactRepository = artifactRepository;
}
public void addToEndOfSearchOrder( LocalArtifactRepository localRepository )
{
if ( localRepositories == null )
@ -65,7 +72,7 @@ public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, Artifact
// This ID is necessary of the metadata lookup doesn't work correctly.
public String getId()
{
return "local";
return "delegating";
}
@Override
@ -83,4 +90,10 @@ public String pathOf( Artifact artifact )
return null;
}
@Override
public String getBasedir()
{
return userLocalArtifactRepository.getBasedir();
}
}

View File

@ -150,7 +150,7 @@ public void execute( MavenSession session )
// mojoDescriptor.isDependencyResolutionRequired() is actually the scope of the dependency resolution required, not a boolean ... yah.
try
{
downloadProjectDependencies( session, Artifact.SCOPE_COMPILE /**mojoDescriptor.isDependencyResolutionRequired()*/ );
downloadProjectDependencies( session, Artifact.SCOPE_TEST /**mojoDescriptor.isDependencyResolutionRequired()*/ );
}
catch ( ArtifactResolutionException e )
{
@ -732,9 +732,7 @@ private Xpp3Dom processConfiguration( MavenSession session, MojoExecution mojoEx
if ( !parameter.isEditable() )
{
}
}
try
{
@ -744,7 +742,6 @@ private Xpp3Dom processConfiguration( MavenSession session, MojoExecution mojoEx
String e = c.getAttribute( "default-value" );
if ( e != null )
{
System.out.println( ">> " + e );
value = expressionEvaluator.evaluate( e );
}
}

View File

@ -37,8 +37,6 @@
import org.apache.maven.model.DomainModel;
import org.apache.maven.model.Model;
import org.apache.maven.model.ModelEventListener;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.ProcessorContext;
import org.apache.maven.model.Profile;
import org.apache.maven.model.interpolator.Interpolator;
@ -58,7 +56,6 @@
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* @version $Id$

View File

@ -36,7 +36,6 @@
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
import org.apache.maven.artifact.versioning.ManagedVersionMap;
import org.apache.maven.model.Build;
@ -584,9 +583,10 @@ public List<String> getTestClasspathElements()
list.add( getBuild().getOutputDirectory() );
for ( Artifact a : getArtifacts() )
{
{
if ( a.getArtifactHandler().isAddedToClasspath() )
{
File file = a.getFile();
if ( file == null )
{
@ -595,9 +595,19 @@ public List<String> getTestClasspathElements()
list.add( file.getPath() );
}
}
/*
System.out.println( "TEST CLASSPATH: ");
for( String s : list )
{
System.out.println( ">>>>> " + s );
}
*/
return list;
}
@Deprecated
public List<Artifact> getTestArtifacts()
{
List<Artifact> list = new ArrayList<Artifact>( getArtifacts().size() );
@ -613,6 +623,7 @@ public List<Artifact> getTestArtifacts()
return list;
}
@Deprecated
public List<Dependency> getTestDependencies()
{
Set<Artifact> artifacts = getArtifacts();