Maven Is Not Working in Java 8 When Javadoc Tags Are Incomplete

Maven is not working in Java 8 when Javadoc tags are incomplete

The best solution would be to fix the javadoc errors. If for some reason that is not possible (ie: auto generated source code) then you can disable this check.

DocLint is a new feature in Java 8, which is summarized as:

Provide a means to detect errors in Javadoc comments early in the
development cycle and in a way that is easily linked back to the
source code.

This is enabled by default, and will run a whole lot of checks before generating Javadocs. You need to turn this off for Java 8 as specified in this thread. You'll have to add this to your maven configuration:

<profiles>
<profile>
<id>java8-doclint-disabled</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<javadoc.opts>-Xdoclint:none</javadoc.opts>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>${javadoc.opts}</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>${javadoc.opts}</additionalparam>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>

For maven-javadoc-plugin 3.0.0+:
Replace

<additionalparam>-Xdoclint:none</additionalparam>

with

<doclint>none</doclint>

Maven site fails with Java 8 when code has incomplete java doc tags

Add the below additional param tag the the maven-javadoc-plugin configuration

    <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>

Reference: http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html

Unable to build Maven project due to Javadoc error?

I'm guessing you switched to Java 8. In this version Javadoc is stricter on the requirements.

You have three choices:

  1. Fix the errors
  2. disable the strict checking
  3. skip Javadoc when building

To disable the strict checking, add this to your pom.xml

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>

to skip Javadoc while building, use this:

mvn -Dmaven.javadoc.skip=true verify

Further Information

How to work around the stricter Java 8 Javadoc when using Maven

For now, the easiest way I know to work around the stricter Java 8 Javadoc when using Maven is deactivating it.

Since the parameter -Xdoclint:none only exists in Java 8, defining this parameter breaks the build for any other Java. To prevent this, we can create a profile that will be active only for Java 8, making sure our solution works regardless of the Java version.

<profiles>
<profile>
<id>disable-java8-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
</profiles>

Just add that to your POM and you're good to go.



For maven-javadoc-plugin 3.0.0 users:

Replace

<additionalparam>-Xdoclint:none</additionalparam>

by

<doclint>none</doclint>

Thanks @banterCZ!

Fixing Javadoc Errors for Java 8

Javadoc checks for valid HTMLs at Java 8. So, you should not need to escape anything, just obey the rules for a valid HTML style.

maven-javadoc-plugin not accepting additionalparam-Xdoclint:none/additionalparam

You should use the doclint option instead:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<doclint>none</doclint>
</configuration>
</plugin>

This will skip all checks. Generally, I would recommend to run all checks except for missing @return and @param. So instead of none, you could use:

        <doclint>all,-missing</doclint>

Individual groups of checks can be switched on or off (like the -missing above). A detailed description of the groups can be found in the javadoc documentation (at the bottom of the page).

JavaDoc 18 in Eclipse

Make sure that in the dialog that is shown for Project > Generate Javadoc..., the field Javadoc command refers to the Javadoc executable of a Java 18 JDK.

Jar not downloading from maven

I think there is a problem with pom.xml of test.jar or jar uploaded to the remote repo incorrectly.

In that case, if you have control over test.jar codebase or remote repo, you can figure out what is wrong and fix it. If you don't have control over them, you can treat like it is 3rd party jar. Using below command you can populate the jar into your local maven repository.

mvn install:install-file

Basically, this command reads this dependency and installs into your local maven repository within the constraints you provided as a parameter.

Below example have been taken from Apache Maven Documentation.

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

But keep in mind, it is just a workaround for your local development. In the long run, the actual problem needs to be resolved. As mentioned earlier, either pom.xml of test.jar should be fixed or structure of remote repository should be corrected by re-uploading the jar.



Related Topics



Leave a reply



Submit