1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.report.projectinfo;
20
21 import java.util.List;
22 import java.util.Locale;
23
24 import org.apache.maven.artifact.repository.ArtifactRepository;
25 import org.apache.maven.doxia.sink.Sink;
26 import org.apache.maven.doxia.tools.SiteTool;
27 import org.apache.maven.plugin.logging.Log;
28 import org.apache.maven.plugins.annotations.Mojo;
29 import org.apache.maven.project.MavenProject;
30 import org.apache.maven.project.ProjectBuilder;
31 import org.apache.maven.project.ProjectBuildingRequest;
32 import org.codehaus.plexus.i18n.I18N;
33
34
35
36
37
38
39
40
41 @Mojo(name = "index")
42 public class IndexReport extends AbstractProjectInfoReport {
43
44
45
46
47 @Override
48 public String getName(Locale locale) {
49 return getI18nString(locale, "title");
50 }
51
52 @Override
53 public String getDescription(Locale locale) {
54 String desc;
55 if (project.getDescription() != null) {
56
57 desc = project.getDescription();
58 } else {
59 return getI18nString(locale, "nodescription");
60 }
61 return desc;
62 }
63
64 @Override
65 public void executeReport(Locale locale) {
66 ProjectIndexRenderer r = new ProjectIndexRenderer(
67 project,
68 getReactorProjects(),
69 projectBuilder,
70 getSession().getProjectBuildingRequest(),
71 localRepository,
72 getName(locale),
73 getDescription(locale),
74 getSink(),
75 getI18N(locale),
76 locale,
77 getLog(),
78 siteTool);
79
80 r.render();
81 }
82
83
84 public String getOutputName() {
85 return "index";
86 }
87
88 @Override
89 protected String getI18Nsection() {
90 return "index";
91 }
92
93
94
95
96
97
98
99
100 private static class ProjectIndexRenderer extends ModulesReport.ModulesRenderer {
101 private final String title;
102
103 private final String description;
104
105 private boolean modules = false;
106
107 ProjectIndexRenderer(
108 MavenProject project,
109 List<MavenProject> reactorProjects,
110 ProjectBuilder projectBuilder,
111 ProjectBuildingRequest buildingRequest,
112 ArtifactRepository localRepository,
113 String title,
114 String description,
115 Sink sink,
116 I18N i18n,
117 Locale locale,
118 Log log,
119 SiteTool siteTool) {
120 super(
121 sink,
122 project,
123 reactorProjects,
124 projectBuilder,
125 buildingRequest,
126 localRepository,
127 i18n,
128 locale,
129 log,
130 siteTool);
131
132 this.title = title;
133
134 this.description = description;
135 }
136
137 @Override
138 public String getTitle() {
139 return modules ? super.getTitle() : title;
140 }
141
142 @Override
143 protected void renderBody() {
144 startSection(title.trim() + " " + project.getName());
145
146 paragraph(description);
147
148 if (!project.getModel().getModules().isEmpty()) {
149 modules = true;
150 super.renderBody();
151 }
152
153 endSection();
154 }
155 }
156 }