- implement rsync deployment method

- implement staging intermediate deployment area
- implement publish goal from staging to live


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@124793 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
brett
2005-01-10 11:48:53 +00:00
parent fbe6244ad0
commit faedfc8cf0
5 changed files with 149 additions and 34 deletions

View File

@@ -82,28 +82,51 @@
<attainGoal name="site:${maven.site.deploy.method}deploy"/>
</goal>
<goal name="site:local-deploy-init">
<j:set var="deployToLive" value="${maven.site.deploy.live}"/>
<j:set var="siteDirectory" value="${maven.site.stage.directory}" />
<j:if test="${empty(siteDirectory) or deployToLive}">
<j:set var="siteDirectory" value="${pom.siteDirectory}" />
</j:if>
<echo>
siteDirectory = ${siteDirectory}
</echo>
</goal>
<goal name="site:remote-deploy-init" prereqs="site:local-deploy-init">
<j:set var="siteUsername" value="${maven.site.stage.username}" />
<j:if test="${empty(siteUsername) or deployToLive}">
<j:set var="siteUsername" value="${maven.username}" />
</j:if>
<maven:user-check user="${siteUsername}"/>
<j:set var="siteAddress" value="${maven.site.stage.address}" />
<j:if test="${empty(siteAddress) or deployToLive}">
<j:set var="siteAddress" value="${pom.siteAddress}" />
</j:if>
<echo>
siteAddress = ${siteAddress}
siteUsername = ${siteUsername}
</echo>
</goal>
<!-- ================================================================== -->
<!-- S I T E F T P D E P L O Y -->
<!-- Deploys the site using FTP -->
<!-- ================================================================== -->
<goal name="site:ftpdeploy"
prereqs="site:init"
prereqs="site:init,site:remote-deploy-init"
description="Deploy the generated site docs using ftp">
<maven:user-check user="${maven.username}"/>
<echo>
siteAddress = ${pom.siteAddress}
siteDirectory = ${pom.siteDirectory}
siteUser = ${maven.username}
</echo>
<!-- FTP to the server -->
<ftp server="${pom.siteAddress}"
userid="${maven.username}"
<ftp server="${siteAddress}"
userid="${siteUsername}"
password="${maven.password}"
remotedir="${pom.siteDirectory}">
remotedir="${siteDirectory}">
<fileset dir="${docsDest}" includes="**/*.*"/>
</ftp>
@@ -115,19 +138,11 @@
<!-- ================================================================== -->
<goal name="site:sshdeploy"
prereqs="site:init"
prereqs="site:init,site:remote-deploy-init"
description="Deploy the generated site docs using ssh">
<maven:user-check user="${maven.username}"/>
<echo>
siteAddress = ${pom.siteAddress}
siteDirectory = ${pom.siteDirectory}
siteUser = ${maven.username}
</echo>
<!-- This needs to taken from the project properties -->
<property name="maven.homepage" value="${pom.siteDirectory}"/>
<property name="maven.homepage" value="${siteDirectory}"/>
<tar tarfile="${maven.build.dir}/${maven.final.name}-site.tar" basedir="${docsDest}"/>
<gzip zipfile="${maven.build.dir}/${maven.final.name}-site.tar.gz" src="${maven.build.dir}/${maven.final.name}-site.tar"/>
@@ -135,15 +150,15 @@
<!-- Make sure the destination directory exists before trying to copy -->
<exec dir="." executable="${maven.ssh.executable}">
<arg line="${maven.ssh.args} -l ${maven.username} ${pom.siteAddress} 'mkdir -p ${maven.homepage}'"/>
<arg line="${maven.ssh.args} -l ${siteUsername} ${siteAddress} 'mkdir -p ${maven.homepage}'"/>
</exec>
<exec dir="${maven.build.dir}" executable="${maven.scp.executable}">
<arg line="${maven.scp.args} ${maven.final.name}-site.tar.gz ${maven.username}@${pom.siteAddress}:${maven.homepage}"/>
<arg line="${maven.scp.args} ${maven.final.name}-site.tar.gz ${siteUsername}@${siteAddress}:${maven.homepage}"/>
</exec>
<exec dir="." executable="${maven.ssh.executable}">
<arg line="${maven.ssh.args} -l ${maven.username} ${pom.siteAddress} 'cd ${maven.homepage};${maven.site.gunzip.executable} ${maven.final.name}-site.tar.gz;${maven.site.tar.executable} ${maven.site.tar.options} ${maven.final.name}-site.tar;chmod -R g+u * .;rm ${maven.final.name}-site.tar'"/>
<arg line="${maven.ssh.args} -l ${siteUsername} ${siteAddress} 'cd ${maven.homepage};${maven.site.gunzip.executable} ${maven.final.name}-site.tar.gz;${maven.site.tar.executable} ${maven.site.tar.options} ${maven.final.name}-site.tar;chmod -R g+u * .;rm ${maven.final.name}-site.tar'"/>
</exec>
<delete file="${maven.build.dir}/${maven.final.name}-site.tar.gz"/>
@@ -156,17 +171,12 @@
<!-- ================================================================== -->
<goal name="site:fsdeploy"
prereqs="site:init"
prereqs="site:init,site:local-deploy-init"
description="Deploy the generated site by copying to the site directory">
<echo>
siteAddress = ${pom.siteAddress}
siteDirectory = ${pom.siteDirectory}
</echo>
<!-- copy the site to the directory specified in the project.xml file -->
<copy todir="${pom.siteDirectory}">
<copy todir="${siteDirectory}">
<fileset dir="${docsDest}">
<include name="**"/>
</fileset>
@@ -208,4 +218,47 @@
<fileset dir="${maven.build.dir}" includes="${maven.final.name}-site.war" />
</ear>
</goal>
<goal name="site:publish" description="Synchronize the staged site to the live site" prereqs="site:remote-deploy-init">
<j:set var="destSiteAddress" value="${pom.siteAddress}" />
<j:set var="destSiteDirectory" value="${pom.siteDirectory}" />
<j:set var="destSiteUsername" value="${maven.username}" />
<echo>
source site address: ${siteAddress}
source site directory: ${siteDirectory}
source site username: ${siteUsername}
destination site address: ${destSiteAddress}
destination site directory: ${destSiteDirectory}
destination site username: ${destSiteUsername}
</echo>
<j:if test="${siteAddress == destSiteAddress and
siteDirectory == destSiteDirectory and
siteUsername == destSiteUsername}">
<fail>Source and destination is identical</fail>
</j:if>
<!-- TODO: support local FS copy -->
<exec dir="." executable="${maven.ssh.executable}">
<arg line="${siteUsername}@${siteAddress} 'mkdir -p ${destSiteDirectory}; ${maven.rsync.executable} -avz ${siteDirectory}/* ${destSiteUsername}@${destSiteAddress}:${destSiteDirectory}'" />
</exec>
<!-- TODO: implement optional -delete -->
</goal>
<goal name="site:rsyncdeploy"
description="Deploy the generated site using rsync"
prereqs="site:init,site:remote-deploy-init">
<exec dir="." executable="${maven.ssh.executable}">
<arg line="${siteUsername}@${siteAddress} 'mkdir -p ${siteDirectory}'" />
</exec>
<maven:makeRelativePath var="relativeDocsDest" path="${docsDest}" separator="/" basedir="${basedir}" />
<exec dir="." executable="${maven.rsync.executable}">
<arg line="-avz ${relativeDocsDest}/* ${siteUsername}@${siteAddress}:${siteDirectory}" />
</exec>
<!-- TODO: implement optional -delete -->
</goal>
</project>

View File

@@ -30,5 +30,7 @@ maven.site.tar.executable=tar
maven.site.tar.options=xUvf
maven.site.gunzip.executable=gunzip
maven.rsync.executable=rsync
maven.username=USERNAME_NOT_SET

View File

@@ -24,6 +24,9 @@
<author email="dion@multitask.com.au">dIon Gillard</author>
</properties>
<body>
<release version="1.6-SNAPSHOT" date="in SVN">
<action dev="brett" type="add">Add the ability to have an intermediate staging publish step for the site</action>
</release>
<release version="1.5.2" date="2004-10-23">
<action dev="dion" type="update" issue="MPSITE-15" due-to="M. Sean Gilligan">Allow tar options as a property</action>
</release>

View File

@@ -60,7 +60,17 @@
Generates the site using the <code>site:generate</code>, and then
deploys the site using either <code>ssh</code> or copying via the
file system, depending on the <code>maven.site.deploy.method</code>
property.
property. If the <code>maven.site.stage.address</code> or <code>maven.site.stage.directory</code>
properties are set then the site is deployed there instead for later publishing with
<code>site:publish</code>
</td>
</tr>
<tr>
<td>site:publish</td>
<td>
This will synchronize the stage directory to the live directory, using rsync.
If rsync is not available on either of the machines, you should use the <code>site:deploy</code>
goal again instead, with <code>maven.site.deploy.live</code> set to <code>true</code>.
</td>
</tr>
<tr>
@@ -71,12 +81,25 @@
and then unpacking them into the <code>pom.siteDirectory</code>
</td>
</tr>
<tr>
<td>site:ftpdeploy</td>
<td>
Deploys the site by FTP'ing the docs to the <code>pom.siteDirectory</code>
directory on the <code>pom.siteAddress</code> server.
</td>
</tr>
<tr>
<td>site:fsdeploy</td>
<td>
Deploys the site by coping the docs to the <code>pom.siteDirectory</code>
</td>
</tr>
<tr>
<td>site:rsyncdeploy</td>
<td>
Deploys the site by rsyncing the docs to the <code>pom.siteDirectory</code>
</td>
</tr>
</table>
</section>
</body>

View File

@@ -28,6 +28,29 @@
<body>
<section name="Site Properties">
<table>
<tr>
<td>maven.site.stage.address</td>
<td>Yes</td>
<td>
Specifies the site address to use when publishing to staging. If not specified, the same address
is used as live.
</td>
</tr>
<tr>
<td>maven.site.stage.directory</td>
<td>Yes</td>
<td>
Specifies the site directory to use when publishing to staging. If not specified, the same directory
is used as live.
</td>
</tr>
<tr>
<td>maven.site.deploy.live</td>
<td>Yes</td>
<td>
Force the use of the live deployment parameters, even if the staging ones are specified
</td>
</tr>
<tr>
<td>maven.scp.executable</td>
<td>Yes</td>
@@ -56,6 +79,17 @@
named <code>ssh</code> must be in your path).
</td>
</tr>
<tr>
<td>maven.rsync.executable</td>
<td>Yes</td>
<td>
Specifies the name (and possibly location) of the remote rsync
executable to use. This is used by the "site:publish" and
"site:rsyncdeploy" goal.
The default value is <code>rsync</code> (i.e. an executable
named <code>rsync</code> must be in your path).
</td>
</tr>
<tr>
<td>maven.ssh.args</td>
<td>Yes</td>
@@ -67,7 +101,7 @@
<td>maven.site.deploy.method</td>
<td>Yes</td>
<td>
Specifies the method to use when deploying the site. Possible values are:
Specifies the method to use when deploying the site. Possible values are: <code>ftp</code>, <code>rsync</code>,
<code>fs</code> and <code>ssh</code>. The ssh method is the good old
method which has always been used within Maven. When you specify
<code>fs</code> the site will be deployed on a local file system.