d.setArtifactId( "b" );
d.setVersion( "0.1" );
d.setScope( Artifact.SCOPE_COMPILE );
Artifact artifact = repositorySystem.createDependencyArtifact( d );
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setArtifact( artifact )
.setResolveRoot( true )
.setResolveTransitively( true )
.setRemoteRepositories( getRemoteRepositories() )
.setLocalRepository( getLocalRepository() );
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
LocalRepository localRepo = new LocalRepository( request.getLocalRepository().getBasedir() );
session.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( session, localRepo ) );
LegacySupport legacySupport = lookup( LegacySupport.class );
legacySupport.setSession( new MavenSession( getContainer(), session, new DefaultMavenExecutionRequest(),
new DefaultMavenExecutionResult() ) );
ArtifactResolutionResult result = repositorySystem.resolve( request );
resolutionErrorHandler.throwErrors( request, result );
assertEquals( 2, result.getArtifacts().size() );
//
// System scoped version which should
//
d.setScope( Artifact.SCOPE_SYSTEM );
File file = new File( getBasedir(), "src/test/repository-system/maven-core-2.1.0.jar" );
assertTrue( file.exists() );
d.setSystemPath( file.getCanonicalPath() );
artifact = repositorySystem.createDependencyArtifact( d );
//
// The request has not set any local or remote repositories as the system scoped dependency being resolved should only
// give us the dependency off the disk and nothing more.
//
request = new ArtifactResolutionRequest()
.setArtifact( artifact )
.setResolveRoot( true )
.setResolveTransitively( true );
result = repositorySystem.resolve( request );
resolutionErrorHandler.throwErrors( request, result );
assertEquals( 1, result.getArtifacts().size() );
//
// Put in a bogus file to make sure missing files cause the resolution to fail.
//
file = new File( getBasedir(), "src/test/repository-system/maven-monkey-2.1.0.jar" );
assertFalse( file.exists() );
d.setSystemPath( file.getCanonicalPath() );
artifact = repositorySystem.createDependencyArtifact( d );
//
// The request has not set any local or remote repositories as the system scoped dependency being resolved should only
// give us the dependency off the disk and nothing more.
//
request = new ArtifactResolutionRequest()
.setArtifact( artifact )
.setResolveRoot( true )
.setResolveTransitively( true );
try