Sunday, 19 August 2012

Conditional Javadoc Generation in Maven

Generating Javadoc at each build process can be very time consuming and pretty unnecessary. One can tackle this issue by moving Javadoc generation in a profile in the pom.xml:
<profiles>
  <profile>
    <id>JavadocGeneration</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.8.1</version>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>
The above create a profile called JavadocGeneration. The Javadoc will be generated if and only if it is invoked:
mvn groupId:artifactId:goal -P JavadocGeneration

No comments:

Post a Comment