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