Files
maven-plugins/site/plugin.jelly
brett faedfc8cf0 - 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
2005-01-10 11:48:53 +00:00

265 lines
9.9 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<project
xmlns:j="jelly:core"
xmlns:maven="jelly:maven">
<!-- ================================================================== -->
<!-- S I T E G E N E R A T I O N -->
<!-- ================================================================== -->
<goal name="site:generate" prereqs="site"/>
<goal name="site:init" prereqs="xdoc:init">
<j:set var="docsDest" value="${maven.docs.dest}"/>
</goal>
<goal
name="site"
description="Generate the web site">
<attainGoal name="site:run-reports"/>
<attainGoal name="xdoc"/>
</goal>
<goal name="site:run-reports" prereqs="xdoc:register-reports">
<maven:pluginVar var="reports" plugin="maven-xdoc-plugin" property="reports" />
<j:forEach var="report" items="${reports}">
<j:set var="reportName" value="${report.get('pluginName')}"/>
<j:if test="${!empty(reportName)}">
<echo>Generating the ${report.get('name')}...</echo>
<attainGoal name="${reportName}:report"/>
</j:if>
</j:forEach>
</goal>
<!-- ================================================================== -->
<!-- S I T E D E P L O Y -->
<!-- ================================================================== -->
<goal
name="site:deploy"
description="deploy the generated site docs">
<!--
|
| Generate the site documentation if it has not already been generated.
| We need some markers or timestamps for this so we don't repeat work
| if it's not necessary.
|
-->
<attainGoal name="site"/>
<!--
|
| Deploy the site using the maven.site.deploy.method property (right
| now possible variants are 'fs' and 'ssh')
|
-->
<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,site:remote-deploy-init"
description="Deploy the generated site docs using ftp">
<!-- FTP to the server -->
<ftp server="${siteAddress}"
userid="${siteUsername}"
password="${maven.password}"
remotedir="${siteDirectory}">
<fileset dir="${docsDest}" includes="**/*.*"/>
</ftp>
</goal>
<!-- ================================================================== -->
<!-- S I T E S S H D E P L O Y -->
<!-- Deploys the site using SSH -->
<!-- ================================================================== -->
<goal name="site:sshdeploy"
prereqs="site:init,site:remote-deploy-init"
description="Deploy the generated site docs using ssh">
<!-- This needs to taken from the project properties -->
<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"/>
<delete file="${maven.build.dir}/${maven.final.name}-site.tar"/>
<!-- Make sure the destination directory exists before trying to copy -->
<exec dir="." executable="${maven.ssh.executable}">
<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 ${siteUsername}@${siteAddress}:${maven.homepage}"/>
</exec>
<exec dir="." executable="${maven.ssh.executable}">
<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"/>
</goal>
<!-- ================================================================== -->
<!-- S I T E F S D E P L O Y -->
<!-- Deploys the site by copying to another file system -->
<!-- ================================================================== -->
<goal name="site:fsdeploy"
prereqs="site:init,site:local-deploy-init"
description="Deploy the generated site by copying to the site directory">
<!-- copy the site to the directory specified in the project.xml file -->
<copy todir="${siteDirectory}">
<fileset dir="${docsDest}">
<include name="**"/>
</fileset>
</copy>
</goal>
<goal name="site:war" description="Create a WAR File from the generated site"
prereqs="site:init, site">
<mkdir dir="${docsDest}/WEB-INF" />
<war destfile="${maven.build.dir}/${maven.final.name}-site.war"
webxml="${plugin.resources}/web.xml">
<fileset dir="${docsDest}" />
</war>
</goal>
<goal name="site:ear" prereqs="site:war"
description="Create an EAR File from the generated site">
<j:set var="docType1" value="&lt;" />
<j:set var="docType2">!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN' 'http://java.sun.com/j2ee/dtds/application_1_2.dtd'</j:set>
<j:set var="docType3" value="&gt;" />
<mkdir dir="${maven.build.dir}/${plugin.artifactId}" />
<j:set var="warName" value="${maven.final.name}-site.war" />
<copy file="${plugin.resources}/application.xml"
tofile="${maven.build.dir}/${plugin.artifactId}/application.xml"/>
<replace file="${maven.build.dir}/${plugin.artifactId}/application.xml">
<replacefilter token="@name@" value="${pom.artifactId}"/>
<replacefilter token="@shortDescription@"
value="${pom.shortDescription}"/>
<replacefilter token="@warName@" value="${warName}" />
<replacefilter token="@contextRoot@" value="${maven.final.name}" />
</replace>
<ear destfile="${maven.build.dir}/${maven.final.name}-site.ear"
appxml="${maven.build.dir}/${plugin.artifactId}/application.xml">
<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>