I have a question concerning the Maven javadoc plugin in Apache Maven. My current configuration allows to create a complete new java doc of my maven project, if the install phase will be executed. If I called the command "mvn clean install", the java doc files will be deleted completly (to do this, I have customoized the Maven clean plugin). And during the install phase, the java doc files will be generated again!

Is there a way to customized the java doc plugin in that way, that only the changed java source code sections will be updated in the existing java doc? And not the complete java doc will be generated again?

My maven-javadoc-configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9</version>
    <configuration>
        <noqualifier>all</noqualifier>
        <reportOutputDirectory>myJavaDocOutputDirectory</reportOutputDirectory>
    </configuration>
    <executions>
        <execution>
            <id>create-myjavadoc</id>
            <phase>install</phase>
            <goals>
                <goal>javadoc</goal>
            </goals>
        </execution>
    </executions>
</plugin>

My maven-clean-plugin configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.4.1</version>
    <configuration>
        <filesets>
            <fileset>
                <directory>target</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <followSymlinks>false</followSymlinks>
            </fileset>
            <fileset>
                <directory>MySourcefolder</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <followSymlinks>false</followSymlinks>
            </fileset>
        </filesets>
    </configuration>
</plugin>
1

There are 1 answers

2
gclaussn On BEST ANSWER

Maybe the JavaDoc must not be generated in a snapshot build - depending on your requirements. If so, add a profile for release or special builds, which includes the maven-javadoc-plugin configuration, and remove the plugin from your default build/plugins section. When you want to generate the JavaDoc run the profile with "mvn clean install -P <profile>". Otherwise just run "mvn clean install" to avoid the JavaDoc generation. Such a profile can look like this:

<profiles>
  <profile>
    <id>release-build</id>

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.9</version>
          <configuration>
            <noqualifier>all</noqualifier>
            <reportOutputDirectory>myJavaDocOutputDirectory</reportOutputDirectory>
          </configuration>
          <executions>
            <execution>
              <id>create-myjavadoc</id>
              <phase>install</phase>
              <goals>
                <goal>javadoc</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

You can run it with: "mvn clean install -P release-build"