Inheritance of the Site Distribution Management

Inside your POM you can not only configure the distributionManagement for the releases and snapshots of your project, but also where to deploy your site when using the site:deploy goal. The following configuration would deploy the project's site to a local directory called bar.

<distributionManagement>
  <site>
      <id>local</id>
      <url>file:///C:/foo/bar</url>
  </site>
</distributionManagement>

The content of this directory would look similar to the following after your deployment:

bar/ (root of site)
├── css
└── report.html

You see that all files are placed directly inside the directory and that no subdirectory named after the artifactId is created. That's a small, but important difference in comparison how the regular deploy phase of the build lifecycle works where always a subdirectory is created for each project. So you have to be aware not to use the exact same value for the site for multiple projects, as otherwise files of the first deployed project will be overwritten by the files of the second deployed one and so on.

To handle this easily you can use a the same parent POM with each of your projects. When using a parent POM with a project, the site configuration is inherited from the parent, but each child project is located in a subdirectory with its artifactId name, resulting in a structure like in the following example:

bar/ (root of site)
├── css
├── project-A
│   ├── css
│   └── report.html
├── project-B
│   ├── css
│   └── report.html
└── report.html

As you can see the site content of the parent POM is located in the root of the site directory, while the content of each project using the parent POM (called "project-A" and "project-B" in the example) is located inside a subdirectory.