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 web site:

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>

Note

In Distribution Management for Site Deployment to Nexus, there is a Nexus installation running on localhost port 8081. In your environment you will need to customize this URL to point to your own Nexus instance.

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 you can 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 release 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, you will want to add the following build element that will configure Maven to use version 3.2 of the Maven Site plugin.

Configuring Version 3.2 of the Maven Site Plugin. 

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