Search code examples
javamavenmaven-3javadocmaven-javadoc-plugin

Setting javadocExecutable from command line does not work


I am execution a project with Java 6 (latest public Oracle release) and Maven 3.2.5. I want the Javadoc generated with Java 8. When configuring with this setup, everything works fine:

<plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.10.3</version>
    <configuration>
        ...
        <javadocExecutable>/usr/lib/jvm/java-8-oracle/bin/javadoc</javadocExecutable>
        <additionalparam>-Xdoclint:none</additionalparam>
    </configuration>
</plugin>

However, if I omit the <javadocExecutable> element and try the same from the command line, it fails (Java 6 is used as reported by Maven):

$ mvn release:prepare -DjavadocExecutable=/usr/lib/jvm/java-8-oracle/bin/javadoc

Solution

  • That's because the prepare goal of maven-release-plugin runs a forked build and the system properties are not copied in the fork.

    You need to use the arguments attribute, like this:

    mvn release:prepare -Darguments="-DjavadocExecutable=/usr/lib/jvm/java-8-oracle/bin/javadoc"
    

    Quoting from its documentation:

    Additional arguments to pass to the Maven executions, separated by spaces.