1 package org.apache.maven.project;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import java.io.File;
19 import java.io.FileNotFoundException;
20 import java.util.Collections;
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.artifact.repository.ArtifactRepository;
24 import org.codehaus.plexus.component.annotations.Component;
25
26 @Component(role=ProjectBuilder.class,hint="classpath")
27 public class TestProjectBuilder
28 extends DefaultProjectBuilder
29 {
30
31 @Override
32 public ProjectBuildingResult build( Artifact artifact, ProjectBuildingRequest request )
33 throws ProjectBuildingException
34 {
35 if ( "maven-test".equals( artifact.getGroupId() ) )
36 {
37 String scope = artifact.getArtifactId().substring( "scope-".length() );
38
39 try
40 {
41 artifact.setFile( ProjectClasspathTest.getFileForClasspathResource( ProjectClasspathTest.dir + "transitive-" + scope + "-dep.xml" ) );
42 }
43 catch ( FileNotFoundException e )
44 {
45 throw new IllegalStateException( "Missing test POM for " + artifact );
46 }
47 }
48 if ( artifact.getFile() == null )
49 {
50 MavenProject project = new MavenProject();
51 project.setArtifact( artifact );
52 return new DefaultProjectBuildingResult( project, null, null );
53 }
54 return build( artifact.getFile(), request );
55 }
56
57 @Override
58 public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest configuration )
59 throws ProjectBuildingException
60 {
61 ProjectBuildingResult result = super.build( pomFile, configuration );
62
63 result.getProject().setRemoteArtifactRepositories( Collections.<ArtifactRepository> emptyList() );
64
65 return result;
66 }
67
68 }