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.doxia.sink.Sink;
23 import org.apache.maven.model.Organization;
24 import org.apache.maven.reporting.MavenReportException;
25 import org.codehaus.plexus.util.StringUtils;
26
27 import java.util.Locale;
28
29
30
31
32
33
34
35
36
37
38 public class ProjectSummaryReport
39 extends AbstractProjectInfoReport
40 {
41
42
43
44
45
46 protected void executeReport( Locale locale )
47 throws MavenReportException
48 {
49 new ProjectSummaryRenderer( getSink(), locale ).render();
50 }
51
52
53 public String getOutputName()
54 {
55 return "project-summary";
56 }
57
58 protected String getI18Nsection()
59 {
60 return "summary";
61 }
62
63
64
65
66
67
68
69
70 private class ProjectSummaryRenderer
71 extends AbstractProjectInfoRenderer
72 {
73 ProjectSummaryRenderer( Sink sink, Locale locale )
74 {
75 super( sink, i18n, locale );
76 }
77
78 protected String getI18Nsection()
79 {
80 return "summary";
81 }
82
83
84 protected void renderBody()
85 {
86 startSection( getTitle() );
87
88
89 String name = project.getName();
90 if ( name == null )
91 {
92 name = "";
93 }
94 String description = project.getDescription();
95 if ( description == null )
96 {
97 description = "";
98 }
99 String homepage = project.getUrl();
100 if ( homepage == null )
101 {
102 homepage = "";
103 }
104
105 startSection( getI18nString( "general.title" ) );
106 startTable();
107 tableHeader( new String[]{getI18nString( "field" ), getI18nString( "value" )} );
108 tableRow( new String[]{getI18nString( "general.name" ), name} );
109 tableRow( new String[]{getI18nString( "general.description" ), description} );
110 tableRowWithLink( new String[]{getI18nString( "general.homepage" ), homepage} );
111 endTable();
112 endSection();
113
114
115 startSection( getI18nString( "organization.title" ) );
116 Organization organization = project.getOrganization();
117 if ( organization == null )
118 {
119 paragraph( getI18nString( "noorganization" ) );
120 }
121 else
122 {
123 if ( organization.getName() == null )
124 {
125 organization.setName( "" );
126 }
127 if ( organization.getUrl() == null )
128 {
129 organization.setUrl( "" );
130 }
131
132 startTable();
133 tableHeader( new String[]{getI18nString( "field" ), getI18nString( "value" )} );
134 tableRow( new String[] { getI18nString( "organization.name" ), organization.getName() } );
135 tableRowWithLink( new String[]{getI18nString( "organization.url" ), organization.getUrl()} );
136 endTable();
137 }
138 endSection();
139
140
141 startSection( getI18nString( "build.title" ) );
142 startTable();
143 tableHeader( new String[]{getI18nString( "field" ), getI18nString( "value" )} );
144 tableRow( new String[]{getI18nString( "build.groupid" ), project.getGroupId()} );
145 tableRow( new String[]{getI18nString( "build.artifactid" ), project.getArtifactId()} );
146 tableRow( new String[]{getI18nString( "build.version" ), project.getVersion()} );
147 tableRow( new String[]{getI18nString( "build.type" ), project.getPackaging()} );
148 endTable();
149 endSection();
150
151 endSection();
152 }
153
154
155 private void tableRowWithLink( String[] content )
156 {
157 sink.tableRow();
158
159 for ( int ctr = 0; ctr < content.length; ctr++ )
160 {
161 String cell = content[ctr];
162
163 sink.tableCell();
164
165 if ( StringUtils.isEmpty( cell ) )
166 {
167 sink.text( "-" );
168 }
169 else
170 {
171 if ( ctr == content.length - 1 && cell.length() > 0 )
172 {
173 sink.link( cell );
174 sink.text( cell );
175 sink.link_();
176 }
177 else
178 {
179 sink.text( cell );
180 }
181 }
182 sink.tableCell_();
183 }
184
185 sink.tableRow_();
186 }
187 }
188 }