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.codehaus.plexus.i18n.I18N;
32
33
34
35
36
37
38
39
40 @Mojo(name = "index")
41 public class IndexReport extends AbstractProjectInfoReport {
42
43
44
45
46 @Override
47 public String getName(Locale locale) {
48 return getI18nString(locale, "title");
49 }
50
51 @Override
52 public String getDescription(Locale locale) {
53 String desc;
54 if (project.getDescription() != null) {
55
56 desc = project.getDescription();
57 } else {
58 return getI18nString(locale, "nodescription");
59 }
60 return desc;
61 }
62
63 @Override
64 public void executeReport(Locale locale) {
65 ProjectIndexRenderer r = new ProjectIndexRenderer(
66 project,
67 getReactorProjects(),
68 projectBuilder,
69 localRepository,
70 getName(locale),
71 getDescription(locale),
72 getSink(),
73 getI18N(locale),
74 locale,
75 getLog(),
76 siteTool);
77
78 r.render();
79 }
80
81
82 public String getOutputName() {
83 return "index";
84 }
85
86 @Override
87 protected String getI18Nsection() {
88 return "index";
89 }
90
91
92
93
94
95
96
97
98 private static class ProjectIndexRenderer extends ModulesReport.ModulesRenderer {
99 private final String title;
100
101 private final String description;
102
103 private boolean modules = false;
104
105 ProjectIndexRenderer(
106 MavenProject project,
107 List<MavenProject> reactorProjects,
108 ProjectBuilder projectBuilder,
109 ArtifactRepository localRepository,
110 String title,
111 String description,
112 Sink sink,
113 I18N i18n,
114 Locale locale,
115 Log log,
116 SiteTool siteTool) {
117 super(sink, project, reactorProjects, projectBuilder, localRepository, i18n, locale, log, siteTool);
118
119 this.title = title;
120
121 this.description = description;
122 }
123
124 @Override
125 public String getTitle() {
126 return modules ? super.getTitle() : title;
127 }
128
129 @Override
130 protected void renderBody() {
131 startSection(title.trim() + " " + project.getName());
132
133 paragraph(description);
134
135 if (!project.getModel().getModules().isEmpty()) {
136 modules = true;
137 super.renderBody();
138 }
139
140 endSection();
141 }
142 }
143 }