Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to build Maven project due to Javadoc error?

Tags:

maven

javadoc

Has anyone come across a similar Maven error as below?

I am unable to build my project due to the error below. All was working previously fine before I started working on the code.

I did not even work on the below defined interfaces and it seems to be related to Javadoc?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (attach-javadocs) on project jonney-project: MavenReportException: Error while creating archive:

[ERROR] Exit code: 1 - /Users/me/Work/myProject/library/src/main/java/com/me/someInterface.java:45: warning: no @return
[ERROR] public abstract boolean searchForDevce();
[ERROR] ^
[ERROR] /Users/me/Work/myProject/src/main/java/com/me/someInterfaceAgain.java:52: warning: no @return
[ERROR] public abstract boolean selectDevice(int pos);
[ERROR] ^
like image 765
Jonathan Avatar asked May 08 '14 13:05

Jonathan


People also ask

How to run a bin/Javadoc command in Maven?

The Build, Execution, Deployment > Build Tools > Maven > Runner setting is set to Use Project JDK, which points to a jdk containing a bin/javadoc command which can be run properly. Adding the following to the below configuration does not solve the issue

How do I fix Maven projects that won't start?

How to fix problems with Maven projects that won't start 1 Edit the hosts file. On some systems you need to edit the hosts file so that localhost resolves correctly. ... 2 Check the user settings file. In the Settings/Preferences dialog Ctrl+Alt+S, go to Build, Execution, Deployment | Build Tools | Maven. 3 Update Maven repositories. ...

How to fix Maven could not calculate build plan error?

How To Fix The Could Not Calculate Build Plan Error. Right-click the error maven project in the eclipse editor. Click the Maven —> Update Project… menu item in the popup menu list, then it will popup the Update Maven Project dialog... Check the error maven project in the Available Maven Codebases ...

What's wrong with JavaDocs in Java 8?

Java 8 is a bit more strict in JavaDoc parsing. This can lead to build failures in Maven when building the repo with warnings like: Sure, the good solution would be to fix the JavaDocs. But in cases where you just clone a foreign repo, you probably just want to get it run and not start fixing it.


6 Answers

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

like image 132
Absurd-Mind Avatar answered Oct 05 '22 21:10

Absurd-Mind


With maven-javadoc-plugin version 3.0.0 <additionalparam/> has been replaced by <additionalOptions/>. To reduce the errors to warnings this pom.xml entry worked for me:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <additionalOptions>
                    <additionalOption>-Xdoclint:none</additionalOption>
                </additionalOptions>
            </configuration>
        </plugin>
    </plugins>
</build>
like image 40
Jens Piegsa Avatar answered Oct 05 '22 21:10

Jens Piegsa


UPDATE FOR THOSE WHO GOOGLED THIS BUG: If the project uses source/target 8, adding 8 in javadoc configuration should make the project buildable on jdk {11, 12, 13}:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
  <source>8</source>
</configuration>
 ...

like image 22
Saurabh Tyagi Avatar answered Oct 05 '22 21:10

Saurabh Tyagi


Just update your pom.xml with the properties tag, given below.

<properties>
    <additionalparam>-Xdoclint:none</additionalparam>
</properties>
like image 30
Nirbhay Rana Avatar answered Oct 05 '22 19:10

Nirbhay Rana


None of the above options seemed to work for me when using version 3.2.0. Instead I noticed the failOnError option. Setting this tags value to false seemed to do the trick for allowing my build to succeed even when there were javadoc errors.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven.javadoc.plugin.version}</version>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <failOnError>false</failOnError>
            </configuration>
        </plugin>

This will stop the javadoc jar from being generated for the maven project. This was okay in my case as I was only wanting to build without errors during ongoing development. The other options may still allow for the javadoc jar to be generated when there are errors.

like image 39
ZachSand Avatar answered Oct 05 '22 19:10

ZachSand


As mentioned by @turbanoff since version 3.0.0 the maven-javadoc-plugin config setting <additionalparam> has been replaced by <additionalOptions>

So the plugin defintion in your pom.xml can look like this:

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

This configuration will still generate the warnings. So you can and should fix them in your code. But it will now no longer break the maven build.

like image 24
Ralph Avatar answered Oct 05 '22 21:10

Ralph