1 package org.apache.maven.plugin.javadoc.stubs;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.FileReader;
24 import java.util.ArrayList;
25 import java.util.Collections;
26 import java.util.List;
27 import java.util.Set;
28
29 import org.apache.maven.artifact.Artifact;
30 import org.apache.maven.artifact.factory.ArtifactFactory;
31 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
32 import org.apache.maven.model.Build;
33 import org.apache.maven.model.Model;
34 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
35 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
36 import org.apache.maven.project.MavenProject;
37 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
38
39
40
41
42 public class AggregateResourcesProject2TestMavenProjectStub
43 extends MavenProjectStub
44 {
45 private Build build;
46
47 public AggregateResourcesProject2TestMavenProjectStub()
48 {
49 MavenXpp3Reader pomReader = new MavenXpp3Reader();
50 Model model = null;
51
52 try
53 {
54 model = pomReader.read( new FileReader( new File( getBasedir(), "pom.xml" ) ) );
55 setModel( model );
56 }
57 catch ( Exception e )
58 {
59 throw new RuntimeException( e );
60 }
61
62 setGroupId( model.getGroupId() );
63 setArtifactId( model.getArtifactId() );
64 setVersion( model.getVersion() );
65 setName( model.getName() );
66 setUrl( model.getUrl() );
67 setPackaging( model.getPackaging() );
68
69 setExecutionRoot( true );
70
71 Artifact artifact = new JavadocPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() );
72 artifact.setArtifactHandler( new DefaultArtifactHandlerStub() );
73 setArtifact( artifact );
74
75 Build build = new Build();
76 build.setFinalName( model.getArtifactId() );
77 build.setSourceDirectory( getBasedir() + "/src/main/java" );
78 build.setDirectory( super.getBasedir() + "/target/test/unit/aggregate-resources-test/project2/target" );
79 setBuild( build );
80
81 List compileSourceRoots = new ArrayList();
82 compileSourceRoots.add( getBasedir() + "/src/main/java" );
83 setCompileSourceRoots( compileSourceRoots );
84 }
85
86
87
88
89 public Build getBuild()
90 {
91 return build;
92 }
93
94
95
96
97 public void setBuild( Build build )
98 {
99 this.build = build;
100 }
101
102
103
104
105 public File getBasedir()
106 {
107 return new File( super.getBasedir() + "/src/test/resources/unit/aggregate-resources-test/project2" );
108 }
109
110
111
112
113
114 public Set createArtifacts( ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter )
115 throws InvalidDependencyVersionException
116 {
117 return Collections.EMPTY_SET;
118 }
119
120
121
122
123 public MavenProject getExecutionProject()
124 {
125 return this;
126 }
127 }