Click here to lend your support to: scala-maven-plugin and make a donation at www.pledgie.com !

Generating API with ScalaDoc

Prerequis : common usages

Configuration

to generate apidocs / scaladoc for your scala sources, add this to your pom.xml

with maven 2.x

<project>
  ...
  <reporting>
    <plugins>
      ...
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>3.3.1</version>
      </plugin>
      ...
    </plugins>
  </reporting>
  ...
</project>

with maven 3.x

<project>
  ...
  <build>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <reportPlugins>
            <plugin>
              <artifactId>maven-project-info-reports-plugin</artifactId>
              <version>2.2</version>
            </plugin>
            <plugin>
              <groupId>net.alchim31.maven</groupId>
              <artifactId>scala-maven-plugin</artifactId>
              <version>3.3.1</version>
              <configuration>
                <jvmArgs>
                  <jvmArg>-Xms64m</jvmArg>
                  <jvmArg>-Xmx1024m</jvmArg>
                </jvmArgs>
              </configuration>
            </plugin>
            ...
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

To generate api

Place scala sources files in :

src/main/scala

Then use the standard maven phases :

          
# generate a site
mvn site
       
        

Or the plugin specifics goal :

          
# generate only the doc
mvn scala:doc
        
        

See the result under target/site/scaladocs/

To use a custom api generator

You need to declare the main class to call (with the same parameter as scaladoc). And you need to list the additional artifact(jar) to use :

<configuration>
  <scaladocClassName>org.scala_tools.vscaladoc.Main</scaladocClassName>
  <scalaJars>
    <scalaJar>
      <groupId>org.scala-tools</groupId>
      <artifactId>vscaladoc</artifactId>
      <version>1.0</version>
    </scalaJar>
  </scalaJars>
</configuration>
        

Then use the standard maven phases :

          
# generate a site
mvn site
# or generate only the doc
mvn scala:doc
       
        

See the result under target/site/scaladocs/

To use vscaladoc

vscaladoc have a shortcut way to use it (instead of using the custom way describe above) :

<configuration>
  <vscalaVersion>1.0</vscalaVersion>
</configuration>
        

Then use the standard maven phases :

          
# generate a site
mvn site
# or generate only the doc
mvn scala:doc
       
        

See the result under target/site/scaladocs/

Attaching Scaladoc

to attach scaladoc JAR files with your project

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>3.3.1</version>
        <execution>
          <id>attach-javadocs</id>
          <goals>
            <goal>doc-jar</goal>
          </goals>
        </execution>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>