1 | |
package org.apache.maven.plugin.plugin; |
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.Artifact; |
23 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
24 | |
import org.apache.maven.doxia.sink.Sink; |
25 | |
import org.apache.maven.doxia.siterenderer.Renderer; |
26 | |
import org.apache.maven.model.Plugin; |
27 | |
import org.apache.maven.model.ReportPlugin; |
28 | |
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException; |
29 | |
import org.apache.maven.plugin.descriptor.MojoDescriptor; |
30 | |
import org.apache.maven.plugin.descriptor.PluginDescriptor; |
31 | |
import org.apache.maven.project.MavenProject; |
32 | |
import org.apache.maven.reporting.AbstractMavenReport; |
33 | |
import org.apache.maven.reporting.AbstractMavenReportRenderer; |
34 | |
import org.apache.maven.reporting.MavenReportException; |
35 | |
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest; |
36 | |
import org.apache.maven.tools.plugin.PluginToolsRequest; |
37 | |
import org.apache.maven.tools.plugin.extractor.ExtractionException; |
38 | |
import org.apache.maven.tools.plugin.generator.GeneratorException; |
39 | |
import org.apache.maven.tools.plugin.generator.GeneratorUtils; |
40 | |
import org.apache.maven.tools.plugin.generator.PluginXdocGenerator; |
41 | |
import org.apache.maven.tools.plugin.scanner.MojoScanner; |
42 | |
import org.apache.maven.tools.plugin.util.PluginUtils; |
43 | |
import org.codehaus.plexus.util.StringUtils; |
44 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
45 | |
|
46 | |
import java.io.File; |
47 | |
import java.util.ArrayList; |
48 | |
import java.util.Iterator; |
49 | |
import java.util.List; |
50 | |
import java.util.Locale; |
51 | |
import java.util.Map; |
52 | |
import java.util.ResourceBundle; |
53 | |
import java.util.Set; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | 0 | public class PluginReport |
66 | |
extends AbstractMavenReport |
67 | |
{ |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
private File outputDirectory; |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
private Renderer siteRenderer; |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
private MavenProject project; |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
protected MojoScanner mojoScanner; |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
private String encoding; |
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
private Requirements requirements; |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
protected String goalPrefix; |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
private boolean skip; |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
private boolean skipReport; |
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
protected Set<Artifact> dependencies; |
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
protected List<ArtifactRepository> remoteRepos; |
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
protected ArtifactRepository local; |
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
protected Renderer getSiteRenderer() |
198 | |
{ |
199 | 0 | return siteRenderer; |
200 | |
} |
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
protected String getOutputDirectory() |
206 | |
{ |
207 | 0 | return outputDirectory.getPath(); |
208 | |
} |
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
protected MavenProject getProject() |
214 | |
{ |
215 | 0 | return project; |
216 | |
} |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
public boolean canGenerateReport() |
222 | |
{ |
223 | 0 | return "maven-plugin".equals( project.getPackaging() ); |
224 | |
} |
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
@SuppressWarnings( "unchecked" ) |
230 | |
protected void executeReport( Locale locale ) |
231 | |
throws MavenReportException |
232 | |
{ |
233 | 0 | if ( !canGenerateReport() ) |
234 | |
{ |
235 | 0 | return; |
236 | |
} |
237 | 0 | if ( skip || skipReport ) |
238 | |
{ |
239 | 0 | getLog().info( "Maven Plugin Plugin Report generation skipped." ); |
240 | 0 | return; |
241 | |
} |
242 | |
|
243 | |
|
244 | 0 | String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() ); |
245 | 0 | if ( goalPrefix == null ) |
246 | |
{ |
247 | 0 | goalPrefix = defaultGoalPrefix; |
248 | |
} |
249 | |
else |
250 | |
{ |
251 | 0 | getLog().warn( "\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '" |
252 | |
+ defaultGoalPrefix + "'.\n" ); |
253 | |
} |
254 | |
|
255 | |
|
256 | 0 | PluginDescriptor pluginDescriptor = new PluginDescriptor(); |
257 | |
|
258 | 0 | pluginDescriptor.setGroupId( project.getGroupId() ); |
259 | |
|
260 | 0 | pluginDescriptor.setArtifactId( project.getArtifactId() ); |
261 | |
|
262 | 0 | pluginDescriptor.setVersion( project.getVersion() ); |
263 | |
|
264 | 0 | pluginDescriptor.setGoalPrefix( goalPrefix ); |
265 | |
|
266 | |
try |
267 | |
{ |
268 | 0 | pluginDescriptor.setDependencies( GeneratorUtils.toComponentDependencies( project.getRuntimeDependencies() ) ); |
269 | |
|
270 | 0 | PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor ); |
271 | 0 | request.setEncoding( encoding ); |
272 | 0 | request.setSkipErrorNoDescriptorsFound( true ); |
273 | 0 | request.setDependencies( dependencies ); |
274 | 0 | request.setLocal( this.local ); |
275 | 0 | request.setRemoteRepos( this.remoteRepos ); |
276 | |
|
277 | |
|
278 | |
try |
279 | |
{ |
280 | 0 | mojoScanner.populatePluginDescriptor( request ); |
281 | |
} |
282 | 0 | catch ( InvalidPluginDescriptorException e ) |
283 | |
{ |
284 | |
|
285 | 0 | getLog().debug( "Plugin without mojos.", e ); |
286 | |
|
287 | 0 | } |
288 | |
|
289 | |
|
290 | 0 | generatePluginDocumentation( pluginDescriptor, locale ); |
291 | |
|
292 | |
|
293 | 0 | PluginOverviewRenderer r = |
294 | |
new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor, locale ); |
295 | 0 | r.render(); |
296 | |
} |
297 | |
|
298 | 0 | catch ( ExtractionException e ) |
299 | |
{ |
300 | 0 | throw new MavenReportException( "Error extracting plugin descriptor: \'" + e.getLocalizedMessage() + "\'", |
301 | |
e ); |
302 | 0 | } |
303 | 0 | } |
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
public String getDescription( Locale locale ) |
309 | |
{ |
310 | 0 | return getBundle( locale ).getString( "report.plugin.description" ); |
311 | |
} |
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
public String getName( Locale locale ) |
317 | |
{ |
318 | 0 | return getBundle( locale ).getString( "report.plugin.name" ); |
319 | |
} |
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
public String getOutputName() |
325 | |
{ |
326 | 0 | return "plugin-info"; |
327 | |
} |
328 | |
|
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
private void generatePluginDocumentation( PluginDescriptor pluginDescriptor, Locale locale ) |
335 | |
throws MavenReportException |
336 | |
{ |
337 | |
try |
338 | |
{ |
339 | 0 | File outputDir = new File( getOutputDirectory() ); |
340 | 0 | outputDir.mkdirs(); |
341 | |
|
342 | 0 | PluginXdocGenerator generator = new PluginXdocGenerator( project, locale ); |
343 | 0 | PluginToolsRequest pluginToolsRequest = new DefaultPluginToolsRequest( project, pluginDescriptor ); |
344 | 0 | generator.execute( outputDir, pluginToolsRequest ); |
345 | |
} |
346 | 0 | catch ( GeneratorException e ) |
347 | |
{ |
348 | 0 | throw new MavenReportException( "Error writing plugin documentation", e ); |
349 | 0 | } |
350 | |
|
351 | 0 | } |
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
|
357 | |
protected static ResourceBundle getBundle( Locale locale ) |
358 | |
{ |
359 | 0 | return ResourceBundle.getBundle( "plugin-report", locale, PluginReport.class.getClassLoader() ); |
360 | |
} |
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | 0 | static class PluginOverviewRenderer |
367 | |
extends AbstractMavenReportRenderer |
368 | |
{ |
369 | |
private final MavenProject project; |
370 | |
|
371 | |
private final Requirements requirements; |
372 | |
|
373 | |
private final PluginDescriptor pluginDescriptor; |
374 | |
|
375 | |
private final Locale locale; |
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
public PluginOverviewRenderer( MavenProject project, Requirements requirements, Sink sink, |
385 | |
PluginDescriptor pluginDescriptor, Locale locale ) |
386 | |
{ |
387 | 0 | super( sink ); |
388 | |
|
389 | 0 | this.project = project; |
390 | |
|
391 | 0 | this.requirements = ( requirements == null ? new Requirements() : requirements ); |
392 | |
|
393 | 0 | this.pluginDescriptor = pluginDescriptor; |
394 | |
|
395 | 0 | this.locale = locale; |
396 | 0 | } |
397 | |
|
398 | |
|
399 | |
|
400 | |
|
401 | |
public String getTitle() |
402 | |
{ |
403 | 0 | return getBundle( locale ).getString( "report.plugin.title" ); |
404 | |
} |
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
@SuppressWarnings( { "unchecked", "rawtypes" } ) |
410 | |
public void renderBody() |
411 | |
{ |
412 | 0 | startSection( getTitle() ); |
413 | |
|
414 | 0 | if ( !( pluginDescriptor.getMojos() != null && pluginDescriptor.getMojos().size() > 0 ) ) |
415 | |
{ |
416 | 0 | paragraph( getBundle( locale ).getString( "report.plugin.goals.nogoal" ) ); |
417 | 0 | endSection(); |
418 | 0 | return; |
419 | |
} |
420 | |
|
421 | 0 | paragraph( getBundle( locale ).getString( "report.plugin.goals.intro" ) ); |
422 | |
|
423 | 0 | boolean hasMavenReport = false; |
424 | 0 | for ( Iterator<MojoDescriptor> i = pluginDescriptor.getMojos().iterator(); i.hasNext(); ) |
425 | |
{ |
426 | 0 | MojoDescriptor mojo = i.next(); |
427 | |
|
428 | 0 | if ( GeneratorUtils.isMavenReport( mojo.getImplementation(), project ) ) |
429 | |
{ |
430 | 0 | hasMavenReport = true; |
431 | |
} |
432 | 0 | } |
433 | |
|
434 | 0 | startTable(); |
435 | |
|
436 | 0 | String goalColumnName = getBundle( locale ).getString( "report.plugin.goals.column.goal" ); |
437 | 0 | String isMavenReport = getBundle( locale ).getString( "report.plugin.goals.column.isMavenReport" ); |
438 | 0 | String descriptionColumnName = getBundle( locale ).getString( "report.plugin.goals.column.description" ); |
439 | 0 | if ( hasMavenReport ) |
440 | |
{ |
441 | 0 | tableHeader( new String[]{ goalColumnName, isMavenReport, descriptionColumnName } ); |
442 | |
} |
443 | |
else |
444 | |
{ |
445 | 0 | tableHeader( new String[]{ goalColumnName, descriptionColumnName } ); |
446 | |
} |
447 | |
|
448 | 0 | List<MojoDescriptor> mojos = new ArrayList<MojoDescriptor>(); |
449 | 0 | mojos.addAll( pluginDescriptor.getMojos() ); |
450 | 0 | PluginUtils.sortMojos( mojos ); |
451 | 0 | for ( MojoDescriptor mojo : mojos ) |
452 | |
{ |
453 | 0 | String goalName = mojo.getFullGoalName(); |
454 | |
|
455 | |
|
456 | |
|
457 | |
|
458 | |
|
459 | 0 | String goalDocumentationLink = "./" + mojo.getGoal() + "-mojo.html"; |
460 | |
|
461 | |
String description; |
462 | 0 | if ( StringUtils.isNotEmpty( mojo.getDeprecated() ) ) |
463 | |
{ |
464 | 0 | description = |
465 | |
"<strong>" + getBundle( locale ).getString( "report.plugin.goal.deprecated" ) + "</strong> " |
466 | |
+ GeneratorUtils.makeHtmlValid( mojo.getDeprecated() ); |
467 | |
} |
468 | 0 | else if ( StringUtils.isNotEmpty( mojo.getDescription() ) ) |
469 | |
{ |
470 | 0 | description = GeneratorUtils.makeHtmlValid( mojo.getDescription() ); |
471 | |
} |
472 | |
else |
473 | |
{ |
474 | 0 | description = getBundle( locale ).getString( "report.plugin.goal.nodescription" ); |
475 | |
} |
476 | |
|
477 | 0 | sink.tableRow(); |
478 | 0 | tableCell( createLinkPatternedText( goalName, goalDocumentationLink ) ); |
479 | 0 | if ( hasMavenReport ) |
480 | |
{ |
481 | 0 | if ( GeneratorUtils.isMavenReport( mojo.getImplementation(), project ) ) |
482 | |
{ |
483 | 0 | sink.tableCell(); |
484 | 0 | sink.text( getBundle( locale ).getString( "report.plugin.isReport" ) ); |
485 | 0 | sink.tableCell_(); |
486 | |
} |
487 | |
else |
488 | |
{ |
489 | 0 | sink.tableCell(); |
490 | 0 | sink.text( getBundle( locale ).getString( "report.plugin.isNotReport" ) ); |
491 | 0 | sink.tableCell_(); |
492 | |
} |
493 | |
} |
494 | 0 | tableCell( description, true ); |
495 | 0 | sink.tableRow_(); |
496 | 0 | } |
497 | |
|
498 | 0 | endTable(); |
499 | |
|
500 | 0 | startSection( getBundle( locale ).getString( "report.plugin.systemrequirements" ) ); |
501 | |
|
502 | 0 | paragraph( getBundle( locale ).getString( "report.plugin.systemrequirements.intro" ) ); |
503 | |
|
504 | 0 | startTable(); |
505 | |
|
506 | 0 | String maven = discoverMavenRequirement( project, requirements ); |
507 | 0 | sink.tableRow(); |
508 | 0 | tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.maven" ) ); |
509 | 0 | tableCell( ( maven != null |
510 | |
? maven |
511 | |
: getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) ); |
512 | 0 | sink.tableRow_(); |
513 | |
|
514 | 0 | String jdk = discoverJdkRequirement( project, requirements ); |
515 | 0 | sink.tableRow(); |
516 | 0 | tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.jdk" ) ); |
517 | 0 | tableCell( |
518 | |
( jdk != null ? jdk : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) ); |
519 | 0 | sink.tableRow_(); |
520 | |
|
521 | 0 | sink.tableRow(); |
522 | 0 | tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.memory" ) ); |
523 | 0 | tableCell( ( StringUtils.isNotEmpty( requirements.getMemory() ) |
524 | |
? requirements.getMemory() |
525 | |
: getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) ); |
526 | 0 | sink.tableRow_(); |
527 | |
|
528 | 0 | sink.tableRow(); |
529 | 0 | tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.diskspace" ) ); |
530 | 0 | tableCell( ( StringUtils.isNotEmpty( requirements.getDiskSpace() ) |
531 | |
? requirements.getDiskSpace() |
532 | |
: getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) ); |
533 | 0 | sink.tableRow_(); |
534 | |
|
535 | 0 | if ( requirements.getOthers() != null && requirements.getOthers().size() > 0 ) |
536 | |
{ |
537 | 0 | for ( Iterator it = requirements.getOthers().keySet().iterator(); it.hasNext(); ) |
538 | |
{ |
539 | 0 | String key = it.next().toString(); |
540 | |
|
541 | 0 | sink.tableRow(); |
542 | 0 | tableCell( key ); |
543 | 0 | tableCell( ( StringUtils.isNotEmpty( requirements.getOthers().getProperty( key ) ) |
544 | |
? requirements.getOthers().getProperty( key ) |
545 | |
: getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) ); |
546 | 0 | sink.tableRow_(); |
547 | 0 | } |
548 | |
} |
549 | 0 | endTable(); |
550 | |
|
551 | 0 | endSection(); |
552 | |
|
553 | 0 | renderUsageSection( hasMavenReport ); |
554 | |
|
555 | 0 | endSection(); |
556 | 0 | } |
557 | |
|
558 | |
|
559 | |
|
560 | |
|
561 | |
|
562 | |
|
563 | |
private void renderUsageSection( boolean hasMavenReport ) |
564 | |
{ |
565 | 0 | startSection( getBundle( locale ).getString( "report.plugin.usage" ) ); |
566 | |
|
567 | |
|
568 | 0 | sink.paragraph(); |
569 | 0 | text( getBundle( locale ).getString( "report.plugin.usage.intro" ) ); |
570 | 0 | sink.paragraph_(); |
571 | |
|
572 | 0 | StringBuilder sb = new StringBuilder(); |
573 | 0 | sb.append( "<project>" ).append( '\n' ); |
574 | 0 | sb.append( " ..." ).append( '\n' ); |
575 | 0 | sb.append( " <build>" ).append( '\n' ); |
576 | 0 | sb.append( |
577 | |
" <!-- " + getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) + " -->" ).append( |
578 | |
'\n' ); |
579 | 0 | sb.append( " <pluginManagement>" ).append( '\n' ); |
580 | 0 | sb.append( " <plugins>" ).append( '\n' ); |
581 | 0 | sb.append( " <plugin>" ).append( '\n' ); |
582 | 0 | sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append( |
583 | |
'\n' ); |
584 | 0 | sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( |
585 | |
"</artifactId>" ).append( '\n' ); |
586 | 0 | sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append( |
587 | |
'\n' ); |
588 | 0 | sb.append( " </plugin>" ).append( '\n' ); |
589 | 0 | sb.append( " ..." ).append( '\n' ); |
590 | 0 | sb.append( " </plugins>" ).append( '\n' ); |
591 | 0 | sb.append( " </pluginManagement>" ).append( '\n' ); |
592 | 0 | sb.append( " <!-- " + getBundle( locale ).getString( "report.plugin.usage.plugins" ) + " -->" ).append( |
593 | |
'\n' ); |
594 | 0 | sb.append( " <plugins>" ).append( '\n' ); |
595 | 0 | sb.append( " <plugin>" ).append( '\n' ); |
596 | 0 | sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append( |
597 | |
'\n' ); |
598 | 0 | sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( |
599 | |
"</artifactId>" ).append( '\n' ); |
600 | 0 | sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append( |
601 | |
'\n' ); |
602 | 0 | sb.append( " </plugin>" ).append( '\n' ); |
603 | 0 | sb.append( " ..." ).append( '\n' ); |
604 | 0 | sb.append( " </plugins>" ).append( '\n' ); |
605 | 0 | sb.append( " </build>" ).append( '\n' ); |
606 | |
|
607 | 0 | if ( hasMavenReport ) |
608 | |
{ |
609 | 0 | sb.append( " ..." ).append( '\n' ); |
610 | 0 | sb.append( |
611 | |
" <!-- " + getBundle( locale ).getString( "report.plugin.usage.reporting" ) + " -->" ).append( |
612 | |
'\n' ); |
613 | 0 | sb.append( " <reporting>" ).append( '\n' ); |
614 | 0 | sb.append( " <plugins>" ).append( '\n' ); |
615 | 0 | sb.append( " <plugin>" ).append( '\n' ); |
616 | 0 | sb.append( " <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" ).append( |
617 | |
'\n' ); |
618 | 0 | sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( |
619 | |
"</artifactId>" ).append( '\n' ); |
620 | 0 | sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append( |
621 | |
'\n' ); |
622 | 0 | sb.append( " </plugin>" ).append( '\n' ); |
623 | 0 | sb.append( " ..." ).append( '\n' ); |
624 | 0 | sb.append( " </plugins>" ).append( '\n' ); |
625 | 0 | sb.append( " </reporting>" ).append( '\n' ); |
626 | |
} |
627 | |
|
628 | 0 | sb.append( " ..." ).append( '\n' ); |
629 | 0 | sb.append( "</project>" ).append( '\n' ); |
630 | |
|
631 | 0 | verbatimText( sb.toString() ); |
632 | |
|
633 | 0 | sink.paragraph(); |
634 | 0 | linkPatternedText( getBundle( locale ).getString( "report.plugin.configuration.end" ) ); |
635 | 0 | sink.paragraph_(); |
636 | |
|
637 | 0 | endSection(); |
638 | 0 | } |
639 | |
|
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
|
645 | |
|
646 | |
|
647 | |
|
648 | |
private static String discoverMavenRequirement( MavenProject project, Requirements requirements ) |
649 | |
{ |
650 | 0 | String maven = requirements.getMaven(); |
651 | 0 | if ( maven == null ) |
652 | |
{ |
653 | 0 | maven = ( project.getPrerequisites() != null ? project.getPrerequisites().getMaven() : null ); |
654 | |
} |
655 | 0 | if ( maven == null ) |
656 | |
{ |
657 | 0 | maven = "2.0"; |
658 | |
} |
659 | |
|
660 | 0 | return maven; |
661 | |
} |
662 | |
|
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
|
672 | |
|
673 | |
private static String discoverJdkRequirement( MavenProject project, Requirements requirements ) |
674 | |
{ |
675 | 0 | String jdk = requirements.getJdk(); |
676 | 0 | if ( jdk == null ) |
677 | |
{ |
678 | 0 | jdk = discoverJdkRequirementFromPlugins( project.getBuild().getPluginsAsMap() ); |
679 | |
} |
680 | 0 | if ( jdk == null ) |
681 | |
{ |
682 | 0 | if ( project.getPluginManagement() != null ) |
683 | |
{ |
684 | 0 | jdk = discoverJdkRequirementFromPlugins( project.getPluginManagement().getPluginsAsMap() ); |
685 | |
} |
686 | |
} |
687 | 0 | if ( jdk == null ) |
688 | |
{ |
689 | 0 | jdk = "Unknown"; |
690 | |
} |
691 | |
|
692 | 0 | return jdk; |
693 | |
} |
694 | |
|
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
@SuppressWarnings( "rawtypes" ) |
700 | |
private static String discoverJdkRequirementFromPlugins( Map pluginsAsMap ) |
701 | |
{ |
702 | 0 | if ( pluginsAsMap == null ) |
703 | |
{ |
704 | 0 | return null; |
705 | |
} |
706 | |
|
707 | 0 | String jdk = null; |
708 | 0 | String backupJdk = null; |
709 | 0 | for ( Iterator it = pluginsAsMap.keySet().iterator(); it.hasNext(); ) |
710 | |
{ |
711 | 0 | String key = it.next().toString(); |
712 | |
|
713 | 0 | if ( !key.equals( "org.apache.maven.plugins:maven-compiler-plugin" ) ) |
714 | |
{ |
715 | 0 | continue; |
716 | |
} |
717 | |
|
718 | 0 | Object value = pluginsAsMap.get( key ); |
719 | 0 | Xpp3Dom pluginConf = null; |
720 | |
|
721 | 0 | backupJdk = "Default version for maven-compiler-plugin"; |
722 | 0 | if ( value instanceof Plugin ) |
723 | |
{ |
724 | 0 | Plugin plugin = (Plugin) value; |
725 | 0 | backupJdk = "Default target for maven-compiler-plugin version " + plugin.getVersion(); |
726 | 0 | pluginConf = (Xpp3Dom) plugin.getConfiguration(); |
727 | |
} |
728 | |
|
729 | 0 | if ( value instanceof ReportPlugin ) |
730 | |
{ |
731 | 0 | ReportPlugin reportPlugin = (ReportPlugin) value; |
732 | 0 | backupJdk = "Default target for maven-compiler-plugin version " + reportPlugin.getVersion(); |
733 | 0 | pluginConf = (Xpp3Dom) reportPlugin.getConfiguration(); |
734 | |
} |
735 | |
|
736 | 0 | if ( pluginConf == null ) |
737 | |
{ |
738 | 0 | continue; |
739 | |
} |
740 | |
|
741 | 0 | if ( pluginConf.getChild( "target" ) == null ) |
742 | |
{ |
743 | 0 | continue; |
744 | |
} |
745 | |
|
746 | 0 | jdk = pluginConf.getChild( "target" ).getValue(); |
747 | 0 | } |
748 | |
|
749 | 0 | if ( jdk == null ) |
750 | |
{ |
751 | 0 | return backupJdk; |
752 | |
} |
753 | |
else |
754 | |
{ |
755 | 0 | return jdk; |
756 | |
} |
757 | |
} |
758 | |
} |
759 | |
} |