maven-plugins/repository/plugin.jelly
dion a242b819c4 Buggy but working deploy snapshot jar target.
Warning: the jar to deploy must be in the same directory as you run the goal


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113006 13f79535-47bb-0310-9956-ffa450edef68
2003-02-27 15:29:50 +00:00

264 lines
11 KiB
XML

<?xml version="1.0"?>
<project
xmlns:define="jelly:define"
xmlns:j="jelly:core"
xmlns:repository="repository"
xmlns:u="jelly:util"
xmlns:x="jelly:xml">
<define:taglib uri="repository">
<!--
! tag for executing a command on the remote repo
! @param command the command to execute
!-->
<define:tag name="exec">
<exec dir="." executable="${maven.ssh.executable}">
<arg line="${maven.repo.central} -l ${maven.username} '${command}'"/>
</exec>
</define:tag>
<!--
! parse the locally available repository audit file
! and make it available to the caller via a variable
! @param var the name of the variable
!-->
<define:tag name="parseAudit">
<u:file name="${plugin.resources}/repository-audit.xml" var="auditFile" />
<x:parse xml="${auditFile}" var="audit" />
<!-- make available to caller -->
<j:set var="${var}" scope="parent" value="${audit}"/>
</define:tag>
<!--
! copy a local file to the remote repository
! @param from the local file to copy
! @param toFileOrDir the remote directory or file to copy to
!-->
<define:tag name="copy">
<u:file name="${from}" var="fromFile"/>
<echo>Copying '${fromFile.canonicalFile.name}' in '${fromFile.canonicalFile.parent}' to directory '${toFileOrDir}'</echo>
<exec dir="${fromFile.canonicalFile.parent}" executable="${maven.scp.executable}">
<arg value="${fromFile.canonicalFile.name}"/>
<arg value="${maven.username}@${maven.repo.central}:${toFileOrDir}/"/>
</exec>
</define:tag>
<!--
! copy a license file from a URL the remote repository
! @param url the license file to copy
! @param groupId the groupId the license is for
!-->
<define:tag name="copyLicense">
<repository:urlFileName url="${url}" var="fileName" />
<j:set var="localFileName">${systemScope['java.io.tmpdir']}${fileName}</j:set>
<delete file="${localFileName}"/>
<get src="${url}" dest="${localFileName}"/>
<!-- copy the license -->
<j:set var="directory" value="${maven.repo.central.directory}/${groupId}/licenses/" />
<repository:copy from="${localFileName}" toFileOrDir="${directory}" />
<!-- set permissions -->
<echo>Setting permissions and group ownership in ${directory}'</echo>
<j:set var="command" value="cd ${directory}" />
<j:set var="command" value="${command};chmod -R g+ws *" />
<j:set var="command" value="${command};chmod -R a+r *" />
<j:set var="command" value="${command};chgrp -R maven *" />
<j:set var="command" value="${command};rm ${groupId}.license" />
<j:set var="command" value="${command};ln -s ${fileName} ${groupId}.license" />
<repository:exec command="${command}" />
</define:tag>
<!--
! place the file name portion of a url into a variable
! @param url the URL to process
! @param var the variable to place the filename into
!-->
<define:tag name="urlFileName">
<u:tokenize var="preQuery" delim="?">${url}</u:tokenize>
<u:tokenize var="preHash" delim="#">${preQuery[0]}</u:tokenize>
<u:tokenize var="slashes" delim="/">${preHash[0]}</u:tokenize>
<j:set var="${var}" scope="parent" value="${slashes[size(slashes)-1]}" />
</define:tag>
</define:taglib>
<goal name="repository:audit-create-licenses"
description="create the license directories, for all groups in the audit file, in the repository">
<!--
! parse audit file
! run ssh to create each <groupId>/licenses directory.
!-->
<repository:parseAudit var="audit"/>
<x:forEach var="group" select="$audit/licenses/project/groupId">
<echo>Processing project ${group.text}</echo>
<j:set var="directory" value="${maven.repo.central.directory}/${group.text}/licenses" />
<j:set var="command" value="mkdir -p ${directory}; chmod g+ws ${directory}; chgrp maven ${directory}" />
<echo>Checking directory '${directory}'</echo>
<repository:exec command="${command}"/>
</x:forEach>
</goal>
<goal name="repository:audit-copy-licenses"
description="copy all licenses in the audit file to the repository">
<!--
! parse audit file
! get the file (using http) and copy to <groupId>/licenses directory.
!-->
<repository:parseAudit var="audit"/>
<!-- see if the user specified a starting project -->
<j:set var="processing" value="true" />
<j:if test="${!empty(startProject)}">
<j:set var="processing" value="false"/>
</j:if>
<x:forEach var="project" select="$audit/licenses/project">
<j:set var="group"><x:expr select="$project/groupId"/></j:set>
<echo>Processing project ${group}</echo>
<j:if test="${!processing and group.equals(startProject)}">
<j:set var="processing" value="true"/>
</j:if>
<!-- get file and don't let the &amp; get reescaped -->
<x:set var="xfile" select="string($project/file)" />
<j:set var="file" value="${xfile}"/>
<j:if test="${file != '' and processing}">
<repository:copyLicense url="${file}" groupId="${group}" />
</j:if>
</x:forEach>
</goal>
<goal name="repository:audit-rename-licenses"
description="rename/link all licenses from their original name to ${groupId}.license">
<repository:parseAudit var="audit"/>
<!-- see if the user specified a starting project -->
<j:set var="processing" value="true" />
<j:if test="${!empty(startProject)}">
<j:set var="processing" value="false"/>
</j:if>
<x:forEach var="project" select="$audit/licenses/project">
<j:set var="group"><x:expr select="$project/groupId"/></j:set>
<echo>Processing project ${group}</echo>
<j:if test="${!processing and group.equals(startProject)}">
<j:set var="processing" value="true"/>
</j:if>
<j:set var="directory" value="${maven.repo.central.directory}/${group}/licenses/" />
<!-- get file and don't let the &amp; get reescaped -->
<x:set var="xfile" select="string($project/file)" />
<j:set var="file" value="${xfile}"/>
<j:if test="${file != '' and processing}">
<repository:urlFileName url="${file}" var="fileName"/>
<j:set var="command" value="cd ${directory}"/>
<j:set var="command" value="${command};ln -s ${fileName} ${group}.license"/>
<echo>Executing '${command}' remotely</echo>
<repository:exec command="${command}" />
</j:if>
</x:forEach>
</goal>
<!-- expects groupId to be set -->
<goal name="repository:audit-copy-license"
description="copy the license for the specified groupId to the repository">
<j:if test="${empty(groupId)}">
<fail>groupId must be specified</fail>
</j:if>
<!--
! parse audit file
! get the file (using http) and copy to <groupId>/licenses directory.
!-->
<repository:parseAudit var="audit"/>
<x:forEach var="project" select="$audit/licenses/project">
<j:set var="group"><x:expr select="$project/groupId"/></j:set>
<j:if test="${group.equals(groupId)}">
<echo>Copying license for ${group}</echo>
<!-- get file and don't let the &amp; get reescaped -->
<x:set var="xfile" select="string($project/file)" />
<j:set var="file" value="${xfile}"/>
<j:if test="${file != ''}">
<repository:copyLicense url="${file}" groupId="${group}" />
</j:if>
</j:if>
</x:forEach>
</goal>
<!-- expects groupId to be set -->
<goal name="repository:create-project"
description="create a project, specified by groupId, in the repository">
<j:if test="${empty(groupId)}">
<fail>groupId must be specified</fail>
</j:if>
<j:set var="command" value="cd ${maven.repo.central.directory}"/>
<j:set var="command" value="${command};mkdir ${groupId}" />
<j:set var="command" value="${command};chgrp maven ${groupId}"/>
<j:set var="command" value="${command};chmod g+s ${groupId}"/>
<j:set var="command" value="${command};mkdir ${groupId}/distributions"/>
<j:set var="command" value="${command};mkdir ${groupId}/jars"/>
<j:set var="command" value="${command};mkdir ${groupId}/licenses"/>
<j:set var="command" value="${command};mkdir ${groupId}/poms"/>
<j:set var="command" value="${command};chmod -R g+ws ${groupId}"/>
<j:set var="command" value="${command};chmod -R a+r ${groupId}"/>
<echo>executing '${command}' remotely</echo>
<repository:exec command="${command}" />
</goal>
<!-- expects groupId to be set -->
<goal name="repository:delete-project"
description="delete a project, specified by groupId, in the repository">
<j:if test="${empty(groupId)}">
<fail>groupId must be specified</fail>
</j:if>
<j:set var="command" value="cd ${maven.repo.central.directory}"/>
<j:set var="command" value="${command};rm -rf ${groupId}" />
<echo>executing '${command}' remotely</echo>
<repository:exec command="${command}" />
</goal>
<!-- this is pretty much a copy of whats in jar:deploy-snapshot -->
<goal name="repository:deploy-snapshot-jar"
description="deploy a snapshot jar, specified by file, to the repository">
<j:if test="${empty(artifact)}">
<fail>artifact must be specified</fail>
</j:if>
<j:if test="${empty(groupId)}">
<fail>groupId must be specified</fail>
</j:if>
<j:if test="${empty(artifactId)}">
<fail>artifactId must be specified</fail>
</j:if>
<!-- work out snapshotVersion from artifact -->
<!-- artifact is format blah-yyyymmdd.hhmmss.jar -->
<u:tokenize var="jarDotBits" delim="-">${artifact}</u:tokenize>
<u:tokenize var="snapAndJar" delim=".">${jarDotBits[size(jarDotBits)-1]}</u:tokenize>
<j:set var="snapshotVersion" value="${snapAndJar[0]}.${snapAndJar[1]}"/>
<echo>snapshotVersion = '${snapshotVersion}'</echo>
<j:set var="directory" value="${maven.repo.central.directory}/${groupId}/jars/" />
<repository:copy from="${artifact}" toFileOrDir="${directory}" />
<j:set var="command" value="cd ${directory}"/>
<j:set var="command" value="${command};ln -sf ${artifact} ${artifactId}-SNAPSHOT.jar"/>
<j:set var="command" value="${command};echo ${snapshotVersion} > ${artifactId}-snapshot-version"/>
<j:set var="command" value="${command};chmod g+w *"/>
<j:set var="command" value="${command};chgrp maven *"/>
<echo>Executing '${command}' remotely</echo>
<repository:exec command="${command}" />
</goal>
</project>