Maven has a handy site plugin which can generate a website about your Maven project. Once the website is generated, normally it needs to be published to somewhere. A simple web server using Apache httpd or Nginx will be enough. Use a SSH/SCP wagon to upload website files to the server. Or website can be published to AWS S3 using wagon provided by community. Nexus can also host Maven websites. So if you are already using Nexus as internal Maven server, then it's a better choice to use Nexus to host the Maven site.

Add a new site in Nexus

First a new Hosted repository with Provider Site.

!Add a new site in Nexus.

Once new site is added, go to Summary tab and find out the URL of the new site, i.e. http://nexus:8081/nexus/content/sites/myproject.

Update POM file

Maven project's pom.xml needs to be updated to use this site configuration. Add <site> configuration in <distributionManagement> element. See code below:

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

Please note the protocol dav: before the site URL. WebDAV is used to upload content to the site.

Update Maven settings

Usually Nexus has user authentication. The user's credentials should be added in Maven's settings.xml file. See code below:

<servers>  
  <server>
    <id>myproject-site</id>
    <username>username</username>
    <password>password</password>
  </server>
</servers>  

The id of <server> must match the id in <distributionManagement>.

Configure Maven site plugin

In the <pluginManagement>, configure Maven site plugin, see code below:

<plugin>  
  <artifactId>maven-site-plugin</artifactId>
  <version>3.4</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-webdav-jackrabbit</artifactId>
      <version>2.6</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.7</version>
    </dependency>
  </dependencies>
</plugin>  

Dependencies wagon-webdav-jackrabbit and slf4j-simple are required.

In <build> configuration, add the WebDAV extension as below:

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

Publish site

To generate and publish site, run mvn site:site site:stage site:deploy. site:stage goal is required if you project has multiple modules. After publish, you should be able to access the site using the URL.