Deploying a site

Once a site report is generated, it needs to be published. While this can be done manually, Maven also provides facilities to do this. Let us see how.

Getting ready

To publish a site, you need to have access to the web server where the site has to be deployed.

How to do it...

To deploy a site, use the following steps:

  1. Add the following code to your pom.xml file. This could also be added in settings.xml:
      <distributionManagement>
        <site>
          <id>myorg</id>
          <url>scp://www.myorg.com/project/</url>
        </site>
      </distributionManagement>
  2. For the corresponding ID, add the relevant username and password in your settings.xml file:
    <servers>
        <server>
          <id>myorg</id>
          <username>username</username>
          <password>password</password>
          <filePermissions>664</filePermissions>
          <directoryPermissions>775</directoryPermissions>
        </server>
      </servers>
  3. Run the following Maven command:
    mvn site-deploy
    

How it works...

When the site-deploy goal is run, Maven first builds the site. Then, it uses the entry set in the distributionManagement element to determine how the site needs to be deployed. The first part of the URL is the protocol to be used to transfer the file. In this case, it is scp. It uses the credentials specified in the settings.xml file and transfers the file to the destination.

There's more...

If you want to test your site before deploying, you can easily do so in the following way:

  1. Run the following Maven command:
    mvn site:run
    
  2. Open the browser and go to http://localhost:8080:
    There's more...

The run goal of the Maven Site plugin deploys the site in a jetty server, which is started by default by port 8080. This allows you to view the site report and verify it before publishing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.20