Search code examples
javamavenmaven-javadoc-plugin

maven-javadoc-plugin - target directory for jar file


Is there a way to specify the output directory for the generated jar for maven-javadoc-plugin? (Clarification: say to a subdirectory of the default target folder.)

This is with reference to the generated jar file. Not the output directory of the generated javadoc html files (specified by the <outputDirectory> parameter).

Have seen references to the maven-assembly-plugin on some similar posts. IMHO, seems like to have to take a pretty long winded approach to use maven-assembly-plugin just to have the javadoc jar generated in a different folder?


Solution

  • In Maven you can define the output directory for javadoc:jar directly. You could try to give it a specific value for jarOutputDirectory in the config for the execution of javadoc goal: <jarOutputDirectory>target/docfoldername</jarOutputDirectory>

    Alternatively you could also use a different profile in maven where you call the javadoc:jar specifically, as it might be easier depending on the requirements. Perhaps for instance:

        <reporting>
            <plugins>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                    <configuration>
                        <jarOutputDirectory>Target/docs</jarOutputDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </reporting>