Automatically checking JavaDoc with Maven

During refactoring, it often happens that the JavaDoc is deprecated. It describes method arguments that are no longer present or some new ones are missing to give examples.

It would be nice if there is a Maven plugin that automatically checks the existing JavaDoc and stops the build if there are any "JavaDoc violations". I saw Maven-JavaDoc-Plugin and maven-doccheck, but both seem to only be able to fix the existing JavaDoc automatically in case of violations, instead of bringing some error or warning.

Does anyone know how, if there is a Maven plugin like this, and how to do it?

+4
source share
1 answer

As far as I know, this is currently not possible with the maven-javadoc-plugin. There is javadoc: fix mojo for the JavaDoc plugin, but this automatically fixes the problems.

I recently created a JIRA entry for this problem: MJAVADOC-374 (which is literally a duplicate of MJAVADOC-314 ).

Update : You can use Checkstyle to verify the correct JavaDoc. Configuration options are described here . Use maven-checkstyle-plugin and check -Mojo to integrate this into your maven assembly.

An example maven configuration might look like this:

 <project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.15</version> <configuration> <logViolationsToConsole>true</logViolationsToConsole> <checkstyleRules> <module name="JavadocMethod"> <property name="scope" value="public"/> <property name="allowUndeclaredRTE" value="true"/> <property name="allowMissingParamTags" value="false"/> </module> </checkstyleRules> </configuration> </plugin> </plugins> </build> ... </project> 
+1
source

Source: https://habr.com/ru/post/1496109/


All Articles