maven-plugins/deploy/plugin.jelly
2003-03-13 15:53:57 +00:00

188 lines
6.7 KiB
XML

<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:maven="jelly:maven"
xmlns:define="jelly:define"
xmlns:deploy="deploy"
xmlns:util="jelly:util"
xmlns:log="jelly:log"
xmlns:m="maven">
<!--
|
| FIX ME: It is the additional siteCommand options that is causing the
| deploy:artifact tag to hang indefinitely.
|
-->
<!-- ================================================================== -->
<!-- D E P L O Y A R T I F A C T T A G -->
<!-- ================================================================== -->
<!-- The deploy-artifact tag is a dynamic tag that allows the -->
<!-- consistent deployment of artifacts generated by Maven. -->
<!-- -->
<!-- The following parameters can be used with the deploy-artifact -->
<!-- tag by setting the appropriate attribute when invoking the tag: -->
<!-- -->
<!-- @param artifact -->
<!-- @param type -->
<!-- @param assureDirectoryCommand -->
<!-- ================================================================== -->
<define:taglib uri="deploy">
<define:tag name="artifact">
<!--
||
|| If the ${maven.username} value isn't set then the deployment
|| process fails.
||
-->
<j:set var="username" value='${context.getVariable("maven.username")}'/>
<m:user-check user="${username}"/>
<j:set var="copier" value='${context.getVariable("maven.scp.executable")}'/>
<j:set var="commander" value='${context.getVariable("maven.ssh.executable")}'/>
<j:set var="distributionSiteX" value="${pom.distributionSite}X"/>
<j:choose>
<j:when test="${distributionSiteX != 'X'}">
<j:set var="siteAddress" value="${pom.distributionSite}"/>
<j:set var="siteDirectory" value="${pom.distributionDirectory}"/>
</j:when>
<j:otherwise>
<j:set var="siteAddress" value='${context.getVariable("maven.repo.central")}'/>
<j:set var="siteDirectory" value='${context.getVariable("maven.repo.central.directory")}'/>
</j:otherwise>
</j:choose>
<j:set var="typeX" value="${type}X"/>
<j:choose>
<j:when test="${typeX != 'X'}">
<property
name="resolvedDirectory"
value="${siteDirectory}/${pom.artifactDirectory}/${type}"
/>
</j:when>
<j:otherwise>
<property
name="resolvedDirectory"
value="${siteDirectory}/${pom.artifactDirectory}"
/>
</j:otherwise>
</j:choose>
<echo>
Moving ${artifact} to the ${resolvedDirectory} on ${siteAddress}
</echo>
<!--
||
|| Make sure the destination directory exists.
||
-->
<j:set var="assureDirectoryCommandX" value="${assureDirectoryCommand}X"/>
<j:if test="${assureDirectoryCommandX != 'X'}">
<exec dir="." executable="${commander}">
<arg line="-l ${username} ${siteAddress} '${assureDirectoryCommand} ${resolvedDirectory}'"/>
</exec>
</j:if>
<exec dir="." executable="${copier}">
<arg value="${artifact}"/>
<arg value="${username}@${siteAddress}:${resolvedDirectory}"/>
</exec>
<!--
||
|| Execute a command on the server if one is specified.
||
-->
<j:set var="siteCommandX" value="${siteCommand}X"/>
<j:if test="${siteCommandX != 'X'}">
<j:useBean var="strings" class="org.apache.commons.lang.StringUtils"/>
<j:set
var="siteCommand"
value='${strings.replace(siteCommand, "@deployDirectory@", resolvedDirectory)}'
/>
<echo>
Executing ${siteCommand} with the username ${username} on ${siteAddress}
</echo>
<exec dir="." executable="${commander}">
<arg line="-l ${username} ${siteAddress} '${siteCommand}'"/>
</exec>
</j:if>
</define:tag>
<!-- ================================================================== -->
<!-- C O P Y D E P S -->
<!-- ================================================================== -->
<define:tag name="copy-deps">
<!--
|
| If a POM descriptor has been specified then use it.
|
-->
<j:if test="${projectDescriptor != null}">
<maven:pom var="pom" projectDescriptor="${projectDescriptor}"/>
</j:if>
<j:set var="mavenRepoLocal" value='${context.getVariable("maven.repo.local")}'/>
<mkdir dir="${todir}"/>
<copy todir="${todir}" flatten="true">
<fileset dir="${mavenRepoLocal}">
<j:forEach var="dep" items="${pom.dependencies}">
<include name="${dep.artifactDirectory}/jars/${dep.artifact}"/>
</j:forEach>
<j:if test="${excludes != ''}">
<!-- The excludes are a list of dep ids -->
<util:tokenize var="excludeItems" delim=",">${excludes}</util:tokenize>
<j:forEach var="exclude" items="${excludeItems}">
<j:set var="depToExclude" value="${pom.getDependency(exclude)}"/>
<exclude name="${depToExclude.artifactDirectory}/jars/${depToExclude.artifact}"/>
</j:forEach>
</j:if>
</fileset>
</copy>
</define:tag>
</define:taglib>
<!-- ========================================================================== -->
<!-- D E P L O Y P O M -->
<!-- ========================================================================== -->
<!-- POMs are deployed in the form ${pom.artifactId}-${pom.currentVersion}.pom -->
<!-- to match the same versioning convention as JARs. Having the POMs -->
<!-- deployed during each release will allow someone to build any -->
<!-- version of a project reliably. -->
<!-- ========================================================================== -->
<goal name="deploy:pom"
description="Deploy POM to the central repository.">
<copy file="project.xml" tofile="${pom.artifactId}-${pom.currentVersion}.pom"/>
<deploy:artifact
artifact="${pom.artifactId}-${pom.currentVersion}.pom"
type="poms"
assureDirectoryCommand="mkdir -p"
/>
<delete file="${pom.artifactId}-${pom.currentVersion}.pom"/>
</goal>
</project>