Search code examples
javamavenmaven-javadoc-plugin

How to create JavaDoc documentation by using command mvn install?


I have a question concerning the maven javadoc plugin? I have configured that plugin with this values:

<build>

 ....

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9</version>
    <configuration>
        <noqualifier>all</noqualifier>
        <reportOutputDirectory>${basedir}/MyDoc/javadoc</reportOutputDirectory>
        <destDir>javadoc</destDir>
    </configuration>
    <executions>
       <execution>
          <id>attach-javadocs</id>
          <goals>
             <goal>javadoc</goal>
           </goals>
        </execution>
     </executions>
 </plugin>      

 ...

</build>    

Is there a way to create some kind of documentation, if I use the command mvn clean install? I don´t want to create a Jar File with my JavaDoc documentation, I need a way to create the JavaDoc and put the created source file directly in my maven project.

Thanks !

Greetz Marwief


Solution

  • To execute plugin during certain phase, add <phase> to <execution>. Plugin should be fired:

    <executions>
       <execution>
          <id>attach-javadocs</id>
          <phase>install</phase>    <------ HERE
          <goals>
             <goal>javadoc</goal>
           </goals>
        </execution>
     </executions>
    

    More on maven lifecycle here