Repository Management with Nexus

17.3. Configuring Maven for Site Deployment

To deploy a site to a Nexus Site repository, you will need to configure the project’s distribution management settings, add site deployment information, and then update your Maven settings to include the appropriate credentials for Nexus.

Add the following section to sample-site/pom.xml before the dependencies element. This section will tell Maven where to publish the Maven-generated project website:

Distribution Management for Site Deployment to Nexus. 

<distributionManagement>
  <site>
    <id>nexus-site</id>
    <url>dav:http://localhost:8081/nexus/content/sites/site/</url>
  </site>
</distributionManagement>

The URL in the distribution management is not parameterized, which means that any redeployment overwrites old content and potentially leaves old stale files behind. To have a new deployment directory for each version, change the URL to a parameterized setup.

Parameterized Distribution Management for Site Deployment. 

<url>
dav:http://localhost:8081/nexus/content/sites/site/${project.groupId}/${project.artifactId}/${project.version}
</url>

If you combine this approach with a redirector or a static page that links to the different copies of your site, you can e.g., maintain separate sites hosting your javadoc and other documentation for different releases of your software.

The dav protocol used by for deployment to Nexus requires that you add the implementing library as a build extension to your Maven project:

Build Extension for DAV Support. 

 <build>
   <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-webdav-jackrabbit</artifactId>
        <version>2.6</version>
      </extension>
    </extensions>

In addition to the distributionManagement element and the build extension, add the following build element that will configure Maven to use version 3.4 of the Maven Site plugin.

Configuring Version 3.4 of the Maven Site Plugin. 

<build>
  <plugins>
    <plugin>
      <artifactId>maven-site-plugin</artifactId>
      <version>3.4</version>
    </plugin>
  </plugins>
</build>