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.File;
22 import java.io.FileInputStream;
23 import java.io.InputStream;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import org.apache.maven.artifact.Artifact;
28 import org.apache.maven.model.Model;
29 import org.apache.maven.model.ReportPlugin;
30 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
31
32
33
34
35 public class DefaultConfigurationMavenProjectStub extends JxrProjectStub {
36 private List<ReportPlugin> reportPlugins = new ArrayList<>();
37
38 public DefaultConfigurationMavenProjectStub() {
39 MavenXpp3Reader pomReader = new MavenXpp3Reader();
40 Model model = null;
41
42 try (InputStream is = new FileInputStream(new File(getBasedir() + "/" + getPOM()))) {
43 model = pomReader.read(is);
44 setModel(model);
45 } catch (Exception ignored) {
46 }
47
48 setArtifactId(model.getArtifactId());
49 setGroupId(model.getGroupId());
50 setVersion(model.getVersion());
51 setPackaging(model.getPackaging());
52 setInceptionYear(model.getInceptionYear());
53
54 String basedir = getBasedir().getAbsolutePath();
55 List<String> compileSourceRoots = new ArrayList<>();
56 compileSourceRoots.add(basedir + "/def/configuration");
57 setCompileSourceRoots(compileSourceRoots);
58
59
60 reportPlugins = new ArrayList<>(model.getReporting().getPlugins());
61
62 Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging());
63 artifact.setArtifactHandler(new DefaultArtifactHandlerStub());
64 setArtifact(artifact);
65 }
66
67 @Override
68 public List<ReportPlugin> getReportPlugins() {
69 return reportPlugins;
70 }
71
72 @Override
73 public File getBasedir() {
74 return new File(super.getBasedir() + "/default-configuration");
75 }
76
77 @Override
78 protected String getPOM() {
79 return "default-configuration-plugin-config.xml";
80 }
81 }