2

I'd like to set an alternate JavaDoc location for all my modules in a multi-module maven project. Unfortunately, I have to rely on relative paths, or else use maven properties like ${basedir}, since this is a team project on subversion, and no absolute path will be the same for all of us.

What is the best way to do this? If I have a project structure

parent
   sub1
   sub2
   sub3
      docs

And I want to place the API in sub3/docs, then how can I point all my modules to output HTML files in sub3/docs, when the parent module will recognize a different path to it than the submodules?

Thanks in advance.

ktm5124
  • 11,861
  • 21
  • 74
  • 119

2 Answers2

1

You want to pollute your project build as little as possible, especially with repeated build tweaks. Instead, you're better off creating a separate build process that assembles the javadoc output from its standard location in all projects and publishes it somewhere desirable.

Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • I am doing this so we can conveniently browse our JavaDoc on our production server. What do you think would be a better way to do this? To create a docs/index.html file that links to all of the JavaDoc HTML pages in the submodule directories? – ktm5124 Jan 15 '13 at 16:00
  • Conceptually, it is best to run javadoc just once, over all the relevant sources that you want included in the documentation. That way, you will get a single unified index and other cross-reference pages. With JDK 9 javadoc, that also means you get a single searchable index. – Jonathan Gibbons Aug 30 '17 at 19:30
1

Add the following to the parent pom and make sure the child pom does not define their own javadoc plugin.

       <build>
       <plugins>
       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>

            <configuration>
                <outputDirectory>${project.parent.basedir}/sub3</outputDirectory>
                <reportOutputDirectory>${project.parent.basedir}/sub3</reportOutputDirectory>
                <destDir>docs</destDir>
            </configuration>
        </plugin>
        </plugins>
        </build>
Jintian DENG
  • 3,152
  • 20
  • 22
  • From what I've been reading, that may only work for Maven 2, not Maven 3. (That is, the project.parent.basedir property.) – ktm5124 Jan 15 '13 at 15:57