Deploying Your Project Web Site

Once your project’s documentation has been written and you’ve created a site to be proud of, you will want to deploy it a server. To deploy your site, you’ll use the Maven Site plugin, which can take care of deploying your project’s site to a remote server using a number of methods, including File Transfer Protocol (FTP), Secure Copy (SCP), and Distributed Authoring and Versioning (DAV). To deploy the site using DAV, configure the site entry of the distributionManagement section in the POM, as shown in Example 15-7.

Example 15-7. Configuring site deployment

<project>
  ...
  <distributionManagement>
    <site>
      <id>sample-project.website</id>
      <url>dav:https://dav.sample.com/sites/sample-project</url>
    </site>
  </distributionManagement>
  ...
</project>

The url in distribution management has a leading indicator dav, which tells the Maven Site plugin to deploy the site to a URL that is able to understand WebDAV. Once you have added the distributionManagement section to the sample-project POM, you can try deploying the site:

$ mvn clean site-deploy

If you have a properly configured server that can understand WebDAV, Maven will deploy your project’s web site to the remote server. If you are deploying this project to a site and server visible to the public, you are going to want to configure your web server to access for credentials. If your web server asks for a username and password (or other credentials), you can configure these values in your ~/.m2/settings.xml ...

Get Maven: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.