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