Coverage Report - org.apache.maven.plugin.plugin.PluginReport
 
Classes in this File Line Coverage Branch Coverage Complexity
PluginReport
0%
0/46
0%
0/8
3.882
PluginReport$PluginOverviewRenderer
0%
0/178
0%
0/70
3.882
 
 1  
 package org.apache.maven.plugin.plugin;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.File;
 23  
 import java.io.IOException;
 24  
 import java.util.ArrayList;
 25  
 import java.util.Iterator;
 26  
 import java.util.List;
 27  
 import java.util.Locale;
 28  
 import java.util.Map;
 29  
 import java.util.ResourceBundle;
 30  
 
 31  
 import org.apache.maven.doxia.sink.Sink;
 32  
 import org.apache.maven.doxia.siterenderer.Renderer;
 33  
 import org.apache.maven.model.Plugin;
 34  
 import org.apache.maven.model.ReportPlugin;
 35  
 import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
 36  
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 37  
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 38  
 import org.apache.maven.project.MavenProject;
 39  
 import org.apache.maven.reporting.AbstractMavenReport;
 40  
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 41  
 import org.apache.maven.reporting.MavenReportException;
 42  
 import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
 43  
 import org.apache.maven.tools.plugin.PluginToolsRequest;
 44  
 import org.apache.maven.tools.plugin.extractor.ExtractionException;
 45  
 import org.apache.maven.tools.plugin.generator.PluginXdocGenerator;
 46  
 import org.apache.maven.tools.plugin.scanner.MojoScanner;
 47  
 import org.apache.maven.tools.plugin.util.PluginUtils;
 48  
 import org.codehaus.plexus.util.StringUtils;
 49  
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 50  
 
 51  
 /**
 52  
  * Generates the Plugin's documentation report.
 53  
  *
 54  
  * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
 55  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
 56  
  * @version $Id: PluginReport.java 1164587 2011-09-02 15:47:35Z bimargulies $
 57  
  * @since 2.0
 58  
  * @goal report
 59  
  * @execute phase="compile"
 60  
  */
 61  0
 public class PluginReport
 62  
     extends AbstractMavenReport
 63  
 {
 64  
     /**
 65  
      * Report output directory.
 66  
      *
 67  
      * @parameter default-value="${project.build.directory}/generated-site/xdoc"
 68  
      */
 69  
     private File outputDirectory;
 70  
 
 71  
     /**
 72  
      * Doxia Site Renderer.
 73  
      *
 74  
      * @component
 75  
      */
 76  
     private Renderer siteRenderer;
 77  
 
 78  
     /**
 79  
      * The Maven Project.
 80  
      *
 81  
      * @parameter expression="${project}"
 82  
      * @required
 83  
      * @readonly
 84  
      */
 85  
     private MavenProject project;
 86  
 
 87  
     /**
 88  
      * Mojo scanner tools.
 89  
      *
 90  
      * @component
 91  
      */
 92  
     protected MojoScanner mojoScanner;
 93  
 
 94  
    /**
 95  
     * The file encoding of the source files.
 96  
     *
 97  
     * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
 98  
     *
 99  
     * @since 2.7
 100  
     */
 101  
     private String encoding;
 102  
 
 103  
 
 104  
     /**
 105  
      * Specify some requirements to execute this plugin.
 106  
      * Example:
 107  
      * <pre>
 108  
      * &lt;requirements&gt;
 109  
      *   &lt;maven&gt;2.0&lt;/maven&gt;
 110  
      *   &lt;jdk&gt;1.4&lt;/jdk&gt;
 111  
      *   &lt;memory&gt;256m&lt;/memory&gt;
 112  
      *   &lt;diskSpace&gt;1m&lt;/diskSpace&gt;
 113  
      *   &lt;others&gt;
 114  
      *     &lt;property&gt;
 115  
      *       &lt;name&gt;SVN&lt;/name&gt;
 116  
      *       &lt;value&gt;1.4.6&lt;/value&gt;
 117  
      *     &lt;/property&gt;
 118  
      *   &lt;/others&gt;
 119  
      * &lt;/requirements&gt;
 120  
      * </pre>
 121  
      *
 122  
      * @parameter
 123  
      */
 124  
     private Requirements requirements;
 125  
 
 126  
     /**
 127  
      * The goal prefix that will appear before the ":". 
 128  
      * By default, this plugin applies a heuristic to derive a heuristic from 
 129  
      * the plugin's artifactId. 
 130  
      * 
 131  
      * It removes any occurrences of the regular expression <strong>-?maven-?</strong>,
 132  
      * and then removes any occurrences of <strong>-?plugin-?</strong>.
 133  
      * <p>
 134  
      * For example, horsefeature-maven-plugin becomes horsefeather.
 135  
      * </p>
 136  
      * <p>
 137  
      * (There is a special for maven-plugin-plugin; it is mapped to 'plugin'.
 138  
      * </p>
 139  
      *
 140  
      * @parameter expression="${goalPrefix}"
 141  
      * @since 2.4
 142  
      */
 143  
     protected String goalPrefix;
 144  
 
 145  
     /**
 146  
      * Set this to "true" to skip invoking any goals or reports of the plugin.
 147  
      *
 148  
      * @parameter default-value="false" expression="${maven.plugin.skip}"
 149  
      * @since 2.8
 150  
      */
 151  
     private boolean skip;
 152  
 
 153  
     /**
 154  
      * Set this to "true" to skip generating the report.
 155  
      *
 156  
      * @parameter default-value="false" expression="${maven.plugin.report.skip}"
 157  
      * @since 2.8
 158  
      */
 159  
     private boolean skipReport;
 160  
 
 161  
     /** {@inheritDoc} */
 162  
     protected Renderer getSiteRenderer()
 163  
     {
 164  0
         return siteRenderer;
 165  
     }
 166  
 
 167  
     /** {@inheritDoc} */
 168  
     protected String getOutputDirectory()
 169  
     {
 170  0
         return outputDirectory.getPath();
 171  
     }
 172  
 
 173  
     /** {@inheritDoc} */
 174  
     protected MavenProject getProject()
 175  
     {
 176  0
         return project;
 177  
     }
 178  
 
 179  
     /** {@inheritDoc} */
 180  
     public boolean canGenerateReport()
 181  
     {
 182  0
         return "maven-plugin".equals( project.getPackaging() );
 183  
     }
 184  
 
 185  
     /** {@inheritDoc} */
 186  
     @SuppressWarnings( "unchecked" )
 187  
     protected void executeReport( Locale locale )
 188  
         throws MavenReportException
 189  
     {
 190  0
         if ( !canGenerateReport() )
 191  
         {
 192  0
             return;
 193  
         }
 194  0
         if (skip || skipReport)
 195  
         {
 196  0
             getLog().info( "Maven Plugin Plugin Report generation skipped." );
 197  0
             return;
 198  
         }
 199  
 
 200  
         // Copy from AbstractGeneratorMojo#execute()
 201  0
         String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
 202  0
         if ( goalPrefix == null )
 203  
         {
 204  0
             goalPrefix = defaultGoalPrefix;
 205  
         }
 206  
         else
 207  
         {
 208  0
             getLog().warn(
 209  
                            "\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '"
 210  
                                + defaultGoalPrefix + "'.\n" );
 211  
         }
 212  
 
 213  
         // TODO: could use this more, eg in the writing of the plugin descriptor!
 214  0
         PluginDescriptor pluginDescriptor = new PluginDescriptor();
 215  
 
 216  0
         pluginDescriptor.setGroupId( project.getGroupId() );
 217  
 
 218  0
         pluginDescriptor.setArtifactId( project.getArtifactId() );
 219  
 
 220  0
         pluginDescriptor.setVersion( project.getVersion() );
 221  
 
 222  0
         pluginDescriptor.setGoalPrefix( goalPrefix );
 223  
 
 224  
         try
 225  
         {
 226  0
             pluginDescriptor.setDependencies( PluginUtils.toComponentDependencies( project.getRuntimeDependencies() ) );
 227  
             
 228  0
             PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
 229  0
             request.setEncoding( encoding );
 230  
 
 231  
             try 
 232  
             {
 233  0
                 mojoScanner.populatePluginDescriptor( request );
 234  
             }
 235  0
             catch ( InvalidPluginDescriptorException e )
 236  
             {
 237  
                 // this is OK, it happens to lifecycle plugins. Allow generation to proceed.
 238  0
                 getLog().debug( "Plugin without mojos.", e );
 239  
 
 240  0
             }
 241  
 
 242  
             // Generate the plugin's documentation
 243  0
             generatePluginDocumentation( pluginDescriptor, locale );
 244  
 
 245  
             // Write the overview
 246  0
             PluginOverviewRenderer r = new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor,
 247  
                                                                    locale );
 248  0
             r.render();
 249  
         }
 250  
         
 251  0
         catch ( ExtractionException e )
 252  
         {
 253  0
             throw new MavenReportException( "Error extracting plugin descriptor: \'" + e.getLocalizedMessage() + "\'",
 254  
                                             e );
 255  0
         }
 256  0
     }
 257  
 
 258  
     /** {@inheritDoc} */
 259  
     public String getDescription( Locale locale )
 260  
     {
 261  0
         return getBundle( locale ).getString( "report.plugin.description" );
 262  
     }
 263  
 
 264  
     /** {@inheritDoc} */
 265  
     public String getName( Locale locale )
 266  
     {
 267  0
         return getBundle( locale ).getString( "report.plugin.name" );
 268  
     }
 269  
 
 270  
     /** {@inheritDoc} */
 271  
     public String getOutputName()
 272  
     {
 273  0
         return "plugin-info";
 274  
     }
 275  
 
 276  
     /**
 277  
      * @param pluginDescriptor not null
 278  
      * @param locale not null
 279  
      * @throws MavenReportException if any
 280  
      */
 281  
     private void generatePluginDocumentation( PluginDescriptor pluginDescriptor, Locale locale )
 282  
         throws MavenReportException
 283  
     {
 284  
         try
 285  
         {
 286  0
             File outputDir = new File( getOutputDirectory() );
 287  0
             outputDir.mkdirs();
 288  
 
 289  0
             PluginXdocGenerator generator = new PluginXdocGenerator( project, locale );
 290  0
             generator.execute( outputDir, pluginDescriptor );
 291  
         }
 292  0
         catch ( IOException e )
 293  
         {
 294  0
             throw new MavenReportException( "Error writing plugin documentation", e );
 295  0
         }
 296  
 
 297  0
     }
 298  
 
 299  
     /**
 300  
      * @param locale not null
 301  
      * @return the bundle for this report
 302  
      */
 303  
     protected static ResourceBundle getBundle( Locale locale )
 304  
     {
 305  0
         return ResourceBundle.getBundle( "plugin-report", locale, PluginReport.class.getClassLoader() );
 306  
     }
 307  
 
 308  
     /**
 309  
      * Generates an overview page with the list of goals
 310  
      * and a link to the goal's page.
 311  
      */
 312  0
     static class PluginOverviewRenderer
 313  
         extends AbstractMavenReportRenderer
 314  
     {
 315  
         private final MavenProject project;
 316  
 
 317  
         private final Requirements requirements;
 318  
 
 319  
         private final PluginDescriptor pluginDescriptor;
 320  
 
 321  
         private final Locale locale;
 322  
 
 323  
         /**
 324  
          * @param project not null
 325  
          * @param requirements not null
 326  
          * @param sink not null
 327  
          * @param pluginDescriptor not null
 328  
          * @param locale not null
 329  
          */
 330  
         public PluginOverviewRenderer( MavenProject project, Requirements requirements, Sink sink,
 331  
                                        PluginDescriptor pluginDescriptor, Locale locale )
 332  
         {
 333  0
             super( sink );
 334  
 
 335  0
             this.project = project;
 336  
 
 337  0
             this.requirements = ( requirements == null ? new Requirements() : requirements );
 338  
 
 339  0
             this.pluginDescriptor = pluginDescriptor;
 340  
 
 341  0
             this.locale = locale;
 342  0
         }
 343  
 
 344  
         /** {@inheritDoc} */
 345  
         public String getTitle()
 346  
         {
 347  0
             return getBundle( locale ).getString( "report.plugin.title" );
 348  
         }
 349  
 
 350  
         /** {@inheritDoc} */
 351  
         @SuppressWarnings( { "unchecked", "rawtypes" } )
 352  
         public void renderBody()
 353  
         {
 354  0
             startSection( getTitle() );
 355  
 
 356  0
             if ( !( pluginDescriptor.getMojos() != null && pluginDescriptor.getMojos().size() > 0 ) )
 357  
             {
 358  0
                 paragraph( getBundle( locale ).getString( "report.plugin.goals.nogoal" ) );
 359  0
                 endSection();
 360  0
                 return;
 361  
             }
 362  
 
 363  0
             paragraph( getBundle( locale ).getString( "report.plugin.goals.intro" ) );
 364  
 
 365  
 
 366  0
             boolean hasMavenReport = false;
 367  0
             for ( Iterator<MojoDescriptor> i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
 368  
             {
 369  0
                 MojoDescriptor mojo = i.next();
 370  
 
 371  0
                 if ( PluginUtils.isMavenReport( mojo.getImplementation(), project ) )
 372  
                 {
 373  0
                     hasMavenReport = true;
 374  
                 }
 375  0
             }
 376  
 
 377  0
             startTable();
 378  
 
 379  0
             String goalColumnName = getBundle( locale ).getString( "report.plugin.goals.column.goal" );
 380  0
             String isMavenReport = getBundle( locale ).getString( "report.plugin.goals.column.isMavenReport" );
 381  0
             String descriptionColumnName = getBundle( locale ).getString( "report.plugin.goals.column.description" );
 382  0
             if ( hasMavenReport )
 383  
             {
 384  0
                 tableHeader( new String[] { goalColumnName, isMavenReport, descriptionColumnName } );
 385  
             }
 386  
             else
 387  
             {
 388  0
                 tableHeader( new String[] { goalColumnName, descriptionColumnName } );
 389  
             }
 390  
 
 391  0
             List<MojoDescriptor> mojos = new ArrayList<MojoDescriptor>();
 392  0
             mojos.addAll( pluginDescriptor.getMojos() );
 393  0
             PluginUtils.sortMojos( mojos );
 394  0
             for ( MojoDescriptor mojo : mojos )
 395  
             {
 396  0
                 String goalName = mojo.getFullGoalName();
 397  
 
 398  
                 /*
 399  
                  * Added ./ to define a relative path
 400  
                  * @see AbstractMavenReportRenderer#getValidHref(java.lang.String)
 401  
                  */
 402  0
                 String goalDocumentationLink = "./" + mojo.getGoal() + "-mojo.html";
 403  
 
 404  
                 String description;
 405  0
                 if ( StringUtils.isNotEmpty( mojo.getDeprecated() ) )
 406  
                 {
 407  0
                     description =
 408  
                         "<strong>" + getBundle( locale ).getString( "report.plugin.goal.deprecated" ) + "</strong> "
 409  
                             + PluginUtils.makeHtmlValid( mojo.getDeprecated() );
 410  
                 }
 411  0
                 else if ( StringUtils.isNotEmpty( mojo.getDescription() ) )
 412  
                 {
 413  0
                     description = PluginUtils.makeHtmlValid( mojo.getDescription() );
 414  
                 }
 415  
                 else
 416  
                 {
 417  0
                     description = getBundle( locale ).getString( "report.plugin.goal.nodescription" );
 418  
                 }
 419  
 
 420  0
                 sink.tableRow();
 421  0
                 tableCell( createLinkPatternedText( goalName, goalDocumentationLink ) );
 422  0
                 if ( hasMavenReport )
 423  
                 {
 424  0
                     if ( PluginUtils.isMavenReport( mojo.getImplementation(), project ) )
 425  
                     {
 426  0
                         sink.tableCell();
 427  0
                         sink.text( getBundle( locale ).getString( "report.plugin.isReport" ) );
 428  0
                         sink.tableCell_();
 429  
                     }
 430  
                     else
 431  
                     {
 432  0
                         sink.tableCell();
 433  0
                         sink.text( getBundle( locale ).getString( "report.plugin.isNotReport" ) );
 434  0
                         sink.tableCell_();
 435  
                     }
 436  
                 }
 437  0
                 tableCell( description, true );
 438  0
                 sink.tableRow_();
 439  0
             }
 440  
 
 441  0
             endTable();
 442  
 
 443  0
             startSection( getBundle( locale ).getString( "report.plugin.systemrequirements" ) );
 444  
 
 445  0
             paragraph( getBundle( locale ).getString( "report.plugin.systemrequirements.intro" ) );
 446  
 
 447  0
             startTable();
 448  
 
 449  0
             String maven = discoverMavenRequirement( project, requirements );
 450  0
             sink.tableRow();
 451  0
             tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.maven" ) );
 452  0
             tableCell( ( maven != null ? maven : getBundle( locale )
 453  
                 .getString( "report.plugin.systemrequirements.nominimum" ) ) );
 454  0
             sink.tableRow_();
 455  
 
 456  0
             String jdk = discoverJdkRequirement( project, requirements );
 457  0
             sink.tableRow();
 458  0
             tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.jdk" ) );
 459  0
             tableCell( ( jdk != null ? jdk : getBundle( locale )
 460  
                 .getString( "report.plugin.systemrequirements.nominimum" ) ) );
 461  0
             sink.tableRow_();
 462  
 
 463  0
             sink.tableRow();
 464  0
             tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.memory" ) );
 465  0
             tableCell( ( StringUtils.isNotEmpty( requirements.getMemory() )
 466  
                 ? requirements.getMemory()
 467  
                 : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
 468  0
             sink.tableRow_();
 469  
 
 470  0
             sink.tableRow();
 471  0
             tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.diskspace" ) );
 472  0
             tableCell( ( StringUtils.isNotEmpty( requirements.getDiskSpace() )
 473  
                 ? requirements.getDiskSpace()
 474  
                 : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
 475  0
             sink.tableRow_();
 476  
 
 477  0
             if ( requirements.getOthers() != null && requirements.getOthers().size() > 0 )
 478  
             {
 479  0
                 for ( Iterator it = requirements.getOthers().keySet().iterator(); it.hasNext(); )
 480  
                 {
 481  0
                     String key = it.next().toString();
 482  
 
 483  0
                     sink.tableRow();
 484  0
                     tableCell( key );
 485  0
                     tableCell( ( StringUtils.isNotEmpty( requirements.getOthers().getProperty( key ) ) ? requirements
 486  
                         .getOthers().getProperty( key ) : getBundle( locale )
 487  
                         .getString( "report.plugin.systemrequirements.nominimum" ) ) );
 488  0
                     sink.tableRow_();
 489  0
                 }
 490  
             }
 491  0
             endTable();
 492  
 
 493  0
             endSection();
 494  
 
 495  0
             renderUsageSection( hasMavenReport );
 496  
 
 497  0
             endSection();
 498  0
         }
 499  
 
 500  
         /**
 501  
          * Render the section about the usage of the plugin.
 502  
          *
 503  
          * @param hasMavenReport If the plugin has a report or not
 504  
          */
 505  
         private void renderUsageSection( boolean hasMavenReport )
 506  
         {
 507  0
             startSection( getBundle( locale ).getString( "report.plugin.usage" ) );
 508  
 
 509  
             // Configuration
 510  0
             sink.paragraph();
 511  0
             text( getBundle( locale ).getString( "report.plugin.usage.intro" ) );
 512  0
             sink.paragraph_();
 513  
 
 514  0
             StringBuffer sb = new StringBuffer();
 515  0
             sb.append( "<project>" ).append( '\n' );
 516  0
             sb.append( "  ..." ).append( '\n' );
 517  0
             sb.append( "  <build>" ).append( '\n' );
 518  0
             sb.append( "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.pluginManagement" ) + " -->" )
 519  
                 .append( '\n' );
 520  0
             sb.append( "    <pluginManagement>" ).append( '\n' );
 521  0
             sb.append( "      <plugins>" ).append( '\n' );
 522  0
             sb.append( "        <plugin>" ).append( '\n' );
 523  0
             sb.append( "          <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
 524  
                 .append( '\n' );
 525  0
             sb.append( "          <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
 526  
                 .append( '\n' );
 527  0
             sb.append( "          <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
 528  
                 .append( '\n' );
 529  0
             sb.append( "        </plugin>" ).append( '\n' );
 530  0
             sb.append( "        ..." ).append( '\n' );
 531  0
             sb.append( "      </plugins>" ).append( '\n' );
 532  0
             sb.append( "    </pluginManagement>" ).append( '\n' );
 533  0
             sb.append( "    <!-- " + getBundle( locale ).getString( "report.plugin.usage.plugins" ) + " -->" )
 534  
                 .append( '\n' );
 535  0
             sb.append( "    <plugins>" ).append( '\n' );
 536  0
             sb.append( "      <plugin>" ).append( '\n' );
 537  0
             sb.append( "        <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
 538  
                 .append( '\n' );
 539  0
             sb.append( "        <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
 540  
                 .append( '\n' );
 541  0
             sb.append( "        <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
 542  
             .append( '\n' );
 543  0
             sb.append( "      </plugin>" ).append( '\n' );
 544  0
             sb.append( "      ..." ).append( '\n' );
 545  0
             sb.append( "    </plugins>" ).append( '\n' );
 546  0
             sb.append( "  </build>" ).append( '\n' );
 547  
 
 548  0
             if ( hasMavenReport )
 549  
             {
 550  0
                 sb.append( "  ..." ).append( '\n' );
 551  0
                 sb.append( "  <!-- " + getBundle( locale ).getString( "report.plugin.usage.reporting" ) + " -->" )
 552  
                     .append( '\n' );
 553  0
                 sb.append( "  <reporting>" ).append( '\n' );
 554  0
                 sb.append( "    <plugins>" ).append( '\n' );
 555  0
                 sb.append( "      <plugin>" ).append( '\n' );
 556  0
                 sb.append( "        <groupId>" ).append( pluginDescriptor.getGroupId() ).append( "</groupId>" )
 557  
                     .append( '\n' );
 558  0
                 sb.append( "        <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append( "</artifactId>" )
 559  
                     .append( '\n' );
 560  0
                 sb.append( "        <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" )
 561  
                     .append( '\n' );
 562  0
                 sb.append( "      </plugin>" ).append( '\n' );
 563  0
                 sb.append( "      ..." ).append( '\n' );
 564  0
                 sb.append( "    </plugins>" ).append( '\n' );
 565  0
                 sb.append( "  </reporting>" ).append( '\n' );
 566  
             }
 567  
 
 568  0
             sb.append( "  ..." ).append( '\n' );
 569  0
             sb.append( "</project>" ).append( '\n' );
 570  
 
 571  0
             verbatimText( sb.toString() );
 572  
 
 573  0
             sink.paragraph();
 574  0
             linkPatternedText( getBundle( locale ).getString( "report.plugin.configuration.end" ) );
 575  0
             sink.paragraph_();
 576  
 
 577  0
             endSection();
 578  0
         }
 579  
 
 580  
         /**
 581  
          * Try to lookup on the Maven prerequisites property.
 582  
          * If not specified, uses the value defined by the user.
 583  
          *
 584  
          * @param project not null
 585  
          * @param requirements not null
 586  
          * @return the Maven version
 587  
          */
 588  
         private static String discoverMavenRequirement( MavenProject project, Requirements requirements )
 589  
         {
 590  0
             String maven = requirements.getMaven();
 591  0
             if ( maven == null )
 592  
             {
 593  0
                 maven = ( project.getPrerequisites() != null ? project.getPrerequisites().getMaven() : null );
 594  
             }
 595  0
             if ( maven == null )
 596  
             {
 597  0
                 maven = "2.0";
 598  
             }
 599  
 
 600  0
             return maven;
 601  
         }
 602  
 
 603  
         /**
 604  
          * Try to lookup on the <code>org.apache.maven.plugins:maven-compiler-plugin</code> plugin to
 605  
          * find the value of the <code>target</code> option.
 606  
          * If not specified, uses the value defined by the user.
 607  
          * If not specified, uses the value of the system property <code>java.specification.version</code>.
 608  
          *
 609  
          * @param project not null
 610  
          * @param requirements not null
 611  
          * @return the JDK version
 612  
          */
 613  
         private static String discoverJdkRequirement( MavenProject project, Requirements requirements )
 614  
         {
 615  0
             String jdk = requirements.getJdk();
 616  0
             if ( jdk == null )
 617  
             {
 618  0
                 jdk = discoverJdkRequirementFromPlugins( project.getBuild().getPluginsAsMap() );
 619  
             }
 620  0
             if ( jdk == null )
 621  
             {
 622  0
                 if ( project.getPluginManagement() != null )
 623  
                 {
 624  0
                     jdk = discoverJdkRequirementFromPlugins( project.getPluginManagement().getPluginsAsMap() );
 625  
                 }
 626  
             }
 627  0
             if ( jdk == null )
 628  
             {
 629  0
                 jdk = "Unknown";
 630  
             }
 631  
 
 632  0
             return jdk;
 633  
         }
 634  
 
 635  
         /**
 636  
          * @param pluginsAsMap could be null
 637  
          * @return the value of the <code>target</code> in the configuration of <code>maven-compiler-plugin</code>.
 638  
          */
 639  
         @SuppressWarnings( "rawtypes" )
 640  
         private static String discoverJdkRequirementFromPlugins( Map pluginsAsMap )
 641  
         {
 642  0
             if ( pluginsAsMap == null )
 643  
             {
 644  0
                 return null;
 645  
             }
 646  
 
 647  0
             String jdk = null;
 648  0
             String backupJdk = null;
 649  0
             for ( Iterator it = pluginsAsMap.keySet().iterator(); it.hasNext(); )
 650  
             {
 651  0
                 String key = it.next().toString();
 652  
 
 653  0
                 if ( !key.equals( "org.apache.maven.plugins:maven-compiler-plugin" ) )
 654  
                 {
 655  0
                     continue;
 656  
                 }
 657  
 
 658  0
                 Object value = pluginsAsMap.get( key );
 659  0
                 Xpp3Dom pluginConf = null;
 660  
 
 661  0
                 backupJdk = "Default version for maven-compiler-plugin";
 662  0
                 if ( value instanceof Plugin )
 663  
                 {
 664  0
                     Plugin plugin = (Plugin) value;
 665  0
                     backupJdk = "Default target for maven-compiler-plugin version " + plugin.getVersion();
 666  0
                     pluginConf = (Xpp3Dom) plugin.getConfiguration();
 667  
                 }
 668  
 
 669  0
                 if ( value instanceof ReportPlugin )
 670  
                 {
 671  0
                     ReportPlugin reportPlugin = (ReportPlugin) value;
 672  0
                     backupJdk = "Default target for maven-compiler-plugin version " + reportPlugin.getVersion();
 673  0
                     pluginConf = (Xpp3Dom) reportPlugin.getConfiguration();
 674  
                 }
 675  
 
 676  0
                 if ( pluginConf == null )
 677  
                 {
 678  0
                     continue;
 679  
                 }
 680  
 
 681  0
                 if ( pluginConf.getChild( "target" ) == null )
 682  
                 {
 683  0
                     continue;
 684  
                 }
 685  
 
 686  0
                 jdk = pluginConf.getChild( "target" ).getValue();
 687  0
             }
 688  
 
 689  0
             if ( jdk == null ) 
 690  
             {
 691  0
                 return backupJdk;
 692  
             }
 693  
             else 
 694  
             {
 695  0
                 return jdk;
 696  
             }
 697  
         }
 698  
     }
 699  
 }