3636)
3737public class RefactorFirstMavenReport extends AbstractMojo {
3838
39+ private static final String THE_BEGINNING =
40+ "<html xmlns=\" http://www.w3.org/1999/xhtml\" xml:lang=\" en\" lang=\" en\" >\n " +
41+ " <head>\n " +
42+ " <meta charset=\" UTF-8\" />\n " +
43+ " <meta name=\" viewport\" content=\" width=device-width, initial-scale=1.0\" />\n " +
44+ " <meta name=\" generator\" content=\" Apache Maven Doxia Site Renderer 1.9.2\" />" ;
45+
46+ private static final String THE_END =
47+ "</div>\n " +
48+ " </div>\n " +
49+ " <div class=\" clear\" >\n " +
50+ " <hr/>\n " +
51+ " </div>\n " +
52+ " <div id=\" footer\" >\n " +
53+ " <div class=\" xright\" >\n " +
54+ " Copyright © 2002–2021<a href=\" https://www.apache.org/\" >The Apache Software Foundation</a>.\n " +
55+ ". </div>\n " +
56+ " <div class=\" clear\" >\n " +
57+ " <hr/>\n " +
58+ " </div>\n " +
59+ " </div>\n " +
60+ " </body>\n " +
61+ "</html>\n " ;
62+
3963 @ Parameter (property = "showDetails" )
4064 private boolean showDetails = false ;
4165
@@ -105,17 +129,13 @@ public void execute() {
105129 .withZone ( ZoneId .systemDefault () );
106130
107131 StringBuilder stringBuilder = new StringBuilder ();
108- stringBuilder .append (
109- "<html xmlns=\" http://www.w3.org/1999/xhtml\" xml:lang=\" en\" lang=\" en\" >\n " +
110- " <head>\n " +
111- " <meta charset=\" UTF-8\" />\n " +
112- " <meta name=\" viewport\" content=\" width=device-width, initial-scale=1.0\" />\n " +
113- " <meta name=\" generator\" content=\" Apache Maven Doxia Site Renderer 1.9.2\" />" );
132+
133+ stringBuilder .append (THE_BEGINNING );
114134
115135
116136 stringBuilder .append ("<title>Refactor First Report for " ).append (projectName ).append (" " ).append (projectVersion ).append (" </title>" );
117137
118- stringBuilder .append (" <link rel=\" stylesheet\" href=\" ./css/maven-base.css\" />\n " +
138+ stringBuilder .append ("<link rel=\" stylesheet\" href=\" ./css/maven-base.css\" />\n " +
119139 " <link rel=\" stylesheet\" href=\" ./css/maven-theme.css\" />\n " +
120140 " <link rel=\" stylesheet\" href=\" ./css/site.css\" />\n " +
121141 " <link rel=\" stylesheet\" href=\" ./css/print.css\" media=\" print\" />\n " +
@@ -130,9 +150,9 @@ public void execute() {
130150 " <div class=\" xleft\" >" );
131151
132152 stringBuilder .append ("<span id=\" publishDate\" >Last Published: " ).append (formatter .format (Instant .now ())).append ("</span>" );
133- stringBuilder .append ("<span id=\" projectVersion\" >Version: " ).append (projectVersion ).append ("</span>" );
153+ stringBuilder .append ("<span id=\" projectVersion\" > Version: " ).append (projectVersion ).append ("</span>" );
134154
135- stringBuilder .append ("/div>\n " +
155+ stringBuilder .append ("< /div>\n " +
136156 " <div class=\" xright\" > </div>\n " +
137157 " <div class=\" clear\" >\n " +
138158 " <hr/>\n " +
@@ -156,27 +176,14 @@ public void execute() {
156176 Optional <File > optionalGitDir = Optional .ofNullable (gitLogReader .getGitDir (project .getBasedir ()));
157177 File gitDir ;
158178
179+
159180 if (optionalGitDir .isPresent ()) {
160181 gitDir = optionalGitDir .get ();
161182 } else {
162183 log .info ("Done! No Git repository found! Please initialize a Git repository and perform an initial commit." );
163184 stringBuilder .append ("No Git repository found in project " ).append (projectName ).append (" " ).append (projectVersion ).append (". " );
164185 stringBuilder .append ("Please initialize a Git repository and perform an initial commit." );
165- stringBuilder .append ("</div>\n " +
166- " </div>\n " +
167- " <div class=\" clear\" >\n " +
168- " <hr/>\n " +
169- " </div>\n " +
170- " <div id=\" footer\" >\n " +
171- " <div class=\" xright\" >\n " +
172- " Copyright © 2002–2021<a href=\" https://www.apache.org/\" >The Apache Software Foundation</a>.\n " +
173- ". </div>\n " +
174- " <div class=\" clear\" >\n " +
175- " <hr/>\n " +
176- " </div>\n " +
177- " </div>\n " +
178- " </body>\n " +
179- "</html>\n " );
186+ stringBuilder .append (THE_END );
180187 writeReportToDisk (filename , stringBuilder );
181188 return ;
182189 }
@@ -188,21 +195,7 @@ public void execute() {
188195 if (!projectBaseDir .equals (parentOfGitDir )) {
189196 log .warn ("Project Base Directory does not match Git Parent Directory" );
190197 stringBuilder .append ("Project Base Directory does not match Git Parent Directory. Please refer to the report at the root of the site directory." );
191- stringBuilder .append ("</div>\n " +
192- " </div>\n " +
193- " <div class=\" clear\" >\n " +
194- " <hr/>\n " +
195- " </div>\n " +
196- " <div id=\" footer\" >\n " +
197- " <div class=\" xright\" >\n " +
198- " Copyright © 2002–2021<a href=\" https://www.apache.org/\" >The Apache Software Foundation</a>.\n " +
199- ". </div>\n " +
200- " <div class=\" clear\" >\n " +
201- " <hr/>\n " +
202- " </div>\n " +
203- " </div>\n " +
204- " </body>\n " +
205- "</html>\n " );
198+ stringBuilder .append (THE_END );
206199 return ;
207200 }
208201
@@ -214,21 +207,7 @@ public void execute() {
214207 if (rankedDisharmonies .isEmpty ()) {
215208 stringBuilder .append ("Congratulations! " ).append (projectName ).append (" " ).append (projectVersion ).append (" has no God classes!" );
216209 log .info ("Done! No God classes found!" );
217- stringBuilder .append ("</div>\n " +
218- " </div>\n " +
219- " <div class=\" clear\" >\n " +
220- " <hr/>\n " +
221- " </div>\n " +
222- " <div id=\" footer\" >\n " +
223- " <div class=\" xright\" >\n " +
224- " Copyright © 2002–2021<a href=\" https://www.apache.org/\" >The Apache Software Foundation</a>.\n " +
225- ". </div>\n " +
226- " <div class=\" clear\" >\n " +
227- " <hr/>\n " +
228- " </div>\n " +
229- " </div>\n " +
230- " </body>\n " +
231- "</html>\n " );
210+ stringBuilder .append (THE_END );
232211 writeReportToDisk (filename , stringBuilder );
233212 return ;
234213 }
@@ -282,27 +261,12 @@ public void execute() {
282261 stringBuilder .append ("</tr>" );
283262 }
284263
285- stringBuilder .append ("/< tbody>" );
264+ stringBuilder .append ("</ tbody>" );
286265
287266 log .info ("Done! View the report at target/site/{}" , filename );
288267
289- stringBuilder .append (
290- "</table></section>" +
291- "</div>\n " +
292- " </div>\n " +
293- " <div class=\" clear\" >\n " +
294- " <hr/>\n " +
295- " </div>\n " +
296- " <div id=\" footer\" >\n " +
297- " <div class=\" xright\" >\n " +
298- " Copyright © 2002–2021<a href=\" https://www.apache.org/\" >The Apache Software Foundation</a>.\n " +
299- ". </div>\n " +
300- " <div class=\" clear\" >\n " +
301- " <hr/>\n " +
302- " </div>\n " +
303- " </div>\n " +
304- " </body>\n " +
305- "</html>\n " );
268+ stringBuilder .append ("</table></section>" );
269+ stringBuilder .append (THE_END );
306270
307271 log .info (stringBuilder .toString ());
308272
0 commit comments