Section 4.11. Publishing a Project Web Site


4.11. Publishing a Project Web Site

You have generated lots of reports in this chapter. These reports will not do any good if they're not made available by publishing them. Let's remedy this!

4.11.1. How do I do that?

Publishing to a single project web site is different from publishing to a multiproject web site only in terms of the goal to call: you call multiproject:site-deploy for multiprojects and site:deploy for single projects. In practice, the multiproject:site-deploy goal simply starts by calling the multiproject:site goal that we saw in Chapter 3, and then it calls site:deploy on it to upload the site to the remote server.


Tip: At the time of this writing the Site plug-in does not use the Artifact plug-in to deploy the web site as an artifact. This will certainly happen in future versions of Maven, and at that time you'll be able to practice your newly acquired knowledge of publishing project artifacts.

The Site plug-in supports four protocols for deploying a web site: File System (fs), SSH (ssh), FTP (ftp), and RSync (rsync). SSH is the default one, but if you wish to choose another one, define the maven.site.deploy.method property in your properties file (either project.properties or build.properties, depending on whether you wish to share this property with other team members):

maven.site.deploy.method = ssh

Let's publish the QOTD web site to http://www.mavenbook.org/mdn/qotd using SSH.

To use the SSH method you need to have SSH and SCP clients installed, and the maven.ssh.executable and maven.scp.executable properties must point to them. For example, if you're on Windows and have installed PuTTY's Plink and Pscp (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) and they're in your PATH, you would write the following in your build.properties file:

maven.ssh.executable = plink maven.scp.executable = pscp

You also need to specify the username under which you wish to deploy the site. Specify it in your build.properties file. For example:

maven.username = vmassol


Tip: Most of the problems you will have when publishing a web site using SSH will be due to authentication. It's strongly recommended to use a public/private key scheme. If you don't use one, your SSH executable will want to prompt you to enter the password but Maven will not propagate this prompt. It'll thus appear to hang. You should always use your SSH client first to ensure you can connect to the remote host automatically, without having to type anything.

Now you need to tell the Site plug-in where to deploy to by defining the siteAddress and siteDirectory elements in the QOTD POM. As these properties are shared by all subprojects, define them in qotd/common/project.xml:

[...]   <url>http://www.mavenbook.org/projects/${pom.groupId}/${pom.artifactId}</url>      <siteAddress>www.mavenbook.org</siteAddress>   <siteDirectory>     /var/www/html/mavenbook/projects/${pom.groupId}/${pom.artifactId}   </siteDirectory> [...]

Publish the QOTD web site by typing multiproject:site-deploy:

C:\dev\mavenbook\code\reporting>maven multiproject:site-deploy [...] site:local-deploy-init:     [echo]       site clean = false       siteDirectory = /var/www/html/mavenbook/projects/mdn/qotd       site:remote-deploy-init:     [echo]       siteAddress = www.mavenbook.org       siteUsername = vmassol    site:sshdeploy:     [tar] Building tar: C:\dev\mavenbook\code\reporting\target\qotd-1.0-site.tar     [gzip] Building: C:\dev\mavenbook\code\reporting\target\qotd-1.0-site.tar.gz     [delete] Deleting: C:\dev\mavenbook\code\reporting\target\qotd-1.0-site.tar [...]

Open a browser and point it to http://www.mavenbook.org/mdn/qotd. Enjoy!


Tip: If you have made a configuration mistake and you do not wish to regenerate the full web site (which multiproject:site-deploy does), simply run site:sshdeploy in qotd/.

4.11.2. What about...

...using another deployment method?

Refer to the Site plug-in reference documentation at http://maven.apache.org/reference/plugins/site/. For example, to use the FTP protocol you would use the same properties as defined earlier, and simply tell the site:deploy goal that you're using FTP by setting the following:

maven.site.deploy.method = ssh



Maven. A Developer's Notebook
Maven: A Developers Notebook (Developers Notebooks)
ISBN: 0596007507
EAN: 2147483647
Year: 2003
Pages: 125

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net