1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.jxr.stubs;
20
21 import java.io.FileReader;
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.model.Model;
27 import org.apache.maven.model.ReportPlugin;
28 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
29 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
30
31
32
33
34 public class DefaultConfigurationMavenProjectStub extends MavenProjectStub {
35 private List<ReportPlugin> reportPlugins = new ArrayList<>();
36
37 public DefaultConfigurationMavenProjectStub() {
38 MavenXpp3Reader pomReader = new MavenXpp3Reader();
39 Model model = null;
40
41 try {
42 model = pomReader.read(new FileReader(getBasedir()
43 + "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml"));
44 setModel(model);
45 } catch (Exception ignored) {
46
47 }
48
49 setArtifactId(model.getArtifactId());
50 setGroupId(model.getGroupId());
51 setVersion(model.getVersion());
52 setPackaging(model.getPackaging());
53 setInceptionYear(model.getInceptionYear());
54
55 String basedir = getBasedir().getAbsolutePath();
56 List<String> compileSourceRoots = new ArrayList<>();
57 compileSourceRoots.add(basedir + "/src/test/resources/unit/default-configuration/def/configuration");
58 setCompileSourceRoots(compileSourceRoots);
59
60
61 reportPlugins = new ArrayList<>(model.getReporting().getPlugins());
62
63 Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
64 artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
65 setArtifact(artifact);
66 }
67
68 @Override
69 public List<ReportPlugin> getReportPlugins() {
70 return reportPlugins;
71 }
72 }