From a1b3723559d77fe9440a3ff52a242eba69cbbc90 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Sun, 14 Dec 2014 15:41:22 +0000 Subject: [PATCH] code organization git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1645462 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/plugin/PluginReport.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java index 145d90b..6e5ff47 100644 --- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java +++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java @@ -60,7 +60,8 @@ import java.util.ResourceBundle; import java.util.Set; /** - * Generates the Plugin's documentation report. + * Generates the Plugin's documentation report: plugin-info.html plugin overview page, + * and one goal-mojo.html per goal. * * @author Stephane Nicoll * @author Vincent Siveton @@ -73,7 +74,7 @@ public class PluginReport extends AbstractMavenReport { /** - * Report output directory for mojo pages. + * Report output directory for mojos' documentation. */ @Parameter( defaultValue = "${project.build.directory}/generated-site/xdoc" ) private File outputDirectory; @@ -234,6 +235,20 @@ public class PluginReport return; } + PluginDescriptor pluginDescriptor = extractPluginDescriptor(); + + // Generate the mojos' documentation + generateMojosDocumentation( pluginDescriptor, locale ); + + // Write the overview + PluginOverviewRenderer r = + new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor, locale ); + r.render(); + } + + private PluginDescriptor extractPluginDescriptor() + throws MavenReportException + { // Copy from AbstractGeneratorMojo#execute() String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() ); if ( goalPrefix == null ) @@ -269,7 +284,6 @@ public class PluginReport request.setLocal( this.local ); request.setRemoteRepos( this.remoteRepos ); - try { mojoScanner.populatePluginDescriptor( request ); @@ -278,23 +292,14 @@ public class PluginReport { // this is OK, it happens to lifecycle plugins. Allow generation to proceed. getLog().debug( "Plugin without mojos.", e ); - } - - // Generate the plugin's documentation - generatePluginDocumentation( pluginDescriptor, locale ); - - // Write the overview - PluginOverviewRenderer r = - new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor, locale ); - r.render(); } - catch ( ExtractionException e ) { throw new MavenReportException( "Error extracting plugin descriptor: \'" + e.getLocalizedMessage() + "\'", e ); } + return pluginDescriptor; } /** @@ -322,11 +327,13 @@ public class PluginReport } /** + * Generate the mojos documentation, as xdoc files. + * * @param pluginDescriptor not null * @param locale not null * @throws MavenReportException if any */ - private void generatePluginDocumentation( PluginDescriptor pluginDescriptor, Locale locale ) + private void generateMojosDocumentation( PluginDescriptor pluginDescriptor, Locale locale ) throws MavenReportException { try