1

I added maven source and javadoc plugins to an application pom.xml which is built in Intellij, in order to deploy the sources and javadocs to nexus along with the jar files. But the Javadoc plugin would not run, gave this error

Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:jar (attach-javadocs) on project ced-spark-spring-components: MavenReportException: Error while generating Javadoc: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set.

I am unable to have JAVA_HOME set on my laptop ( unexplained company policy ) , so I concentrated on getting it set in intellij and maven. After a lot of mucking around I got it to work by adding in pom.xml adding <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable> to the configuration of the plugin and by setting up this property
<java.home>c:/Program Files/Java/jdk1.8.0_181</java.home>

This worked but no pleasing, eventually stumbled across the intellij maven jdk setting File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner which was defaulting to the internal intellij jdk and which doesn't have javadoc. I changed it to use a full jdk with javadoc external to intellij.

The javadoc plugin then failed the build because of javadoc errors which I was able to configure off by add doclint:none to the plugin congig in pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
        <additionalOptions>-Xdoclint:none</additionalOptions>
    </configuration>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <goals>
                <goal>jar</goal>
            </goals>
         </execution>
    </executions>
</plugin>
stephen newman
  • 533
  • 4
  • 17
  • I have a similar issue (in my case, the javadoc plugin is using the wrong JDK). I think what we both need is a way to have IntelliJ execute maven builds with `JAVA_HOME` pointing at the project JDK. – Daniel Flower Feb 16 '21 at 05:02

0 Answers0