Wednesday, September 10, 2014

How to generate javaDoc through mvn plugin

How to generate javaDoc through mvn plugin

  • Add below snip to generate source jar

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-source-plugin</artifactId>
  <version>2.1.2</version>
  <executions>
   <execution>
    <id>bundle-sources</id>
    <phase>package</phase>
    <goals>
     <goal>jar</goal>
    </goals>
   </execution>
  </executions>
</plugin>

  • Add below snip to parent pom to unzip generated source

          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-artifact-sources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.intel.ase.osg</groupId>
                                    <artifactId>com.intel.ase.osg.core</artifactId>
                                    <version>${ase.osg.version}</version>
                                    <classifier>sources</classifier>
                                    <overWrite>true</overWrite>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/unpack_sources</outputDirectory>
                        </configuration>
                    </execution>
                    <!-- add more unpack-executions here -->
                </executions>
            </plugin>

  • Add below snip to generate javaDoc from unzip source files
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <sourcepath>${project.build.directory}/unpack_sources</sourcepath>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>javadoc</goal>
                    </goals>
                    <phase>process-resources</phase>
                </execution>
            </executions>
        </plugin> 


When you call mvn clean install at this point you will end up with a site folder inside your target folder. In this site folder you'll find your apidocs.  



Reference:- 
http://stackoverflow.com/questions/4947215/maven-3-generate-javadoc-for-defined-artifacts

No comments:

Post a Comment