Search code examples
javamavenmaven-site-plugin

plugin-info.html file not being generated when running Maven site


I have a custom Maven plugin that has a few goals/Mojos in it that I'd like to generate documentation for. According to the Maven guide to plugin documentation, I am supposed to use the Maven plugin plugin in combination with the Maven site plugin to generate a plugin-info.html file that contains information about my goals.

Unfortunately, I can't seem to generate this file. I can generate a site, it just doesn't contain information about my goals/Mojos.

As the guide suggested, I updated my pom.xml file to include the Maven plugin plugin in the reporting section:

<reporting>
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-plugin-plugin</artifactId>
            <version>3.9.0</version>
        </plugin>
    </plugins>
</reporting>

I also have this plugin along with the site plugin in my <build>/<plugins> section:

<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.12.1</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-plugin-plugin</artifactId>
            <version>3.9.0</version>
            <executions>
                <execution>
                   <id>generate-helpmojo</id>
                   <goals>
                       <goal>helpmojo</goal>
                   </goals>
               </execution>
            </executions>
        </plugin> 
    <plugins>
</build>

When I run mvn clean site or mvn site:site, a target/site directory is generated with various files in it: target/site directory

I expected to see a plugin-info.html file in there that includes information on my goals such as their names and descriptions. Unfortunately, I don't see that file anywhere.

I'm pretty sure I've set up my goals/Mojos correctly. Here's an example of one of them:

/**
 * Run the configured recipes and apply the changes locally.
 * <p>
 * This variant of rewrite:run will fork the maven life cycle and can be run as a "stand-alone" goal. It will
 * execute the maven build up to the process-test-classes phase.
 */
@Mojo(name = "run", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true,
        defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES)
@Execute(phase = LifecyclePhase.PROCESS_TEST_CLASSES)
public class RewriteRunMojo extends AbstractRewriteRunMojo {
}

When I run mvn process-classes, I correctly get a target/classes/META-INF/maven/.../plugin-help.xml file that includes the information about my goals:

...
<mojo>
  <goal>run</goal>
  <description>Run the configured recipes and apply the changes locally. 
This variant of rewrite:run will fork the maven life cycle and can be run as a stand-alone goal. It will execute the maven build up to the process-test-classes phase.
  </description>
  ...
</mojo>

Yet, that information doesn't seem to get used by the Maven site plugin.

Is there some command or configuration I'm missing to generate documentation for my goals? Is there any other information I can provide that's relevant to this question?

Thanks for your time!


Solution

  • Mentioned documentation is out of date - should be updated (thanks for point).

    Reporting was removed from maven-plugin-plugin in version 3.9.0 - MPLUGIN-467
    now is dedicated reporting plugin - maven-plugin-report-plugin.

    So please use:

    <reporting>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-plugin-report-plugin</artifactId>
            <version>3.9.0</version>
          </plugin>
        </plugins>
      </reporting>
    

    References: