git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114566 13f79535-47bb-0310-9956-ffa450edef68
408 lines
15 KiB
XML
408 lines
15 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<project
|
|
xmlns:ant="jelly:ant"
|
|
xmlns:define="jelly:define"
|
|
xmlns:dummy="dummy"
|
|
xmlns:j="jelly:core"
|
|
xmlns:maven="jelly:maven"
|
|
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">
|
|
<!-- allow either command attribute or use body of exec tag -->
|
|
<j:if test="${empty(command)}">
|
|
<j:set var="command" trim="yes"><define:invokeBody/></j:set>
|
|
</j:if>
|
|
<echo>Executing '${command}' remotely</echo>
|
|
<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 var="fileName" url="${url}" />
|
|
|
|
<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>
|
|
<repository:exec>
|
|
cd ${directory};
|
|
rm ${groupId}.license;
|
|
ln -s ${fileName} ${groupId}.license;
|
|
chmod -R g+w,a+r ${fileName};
|
|
chgrp -R ${maven.repository.group} *;
|
|
</repository:exec>
|
|
</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>
|
|
|
|
<!--
|
|
! set a variable called ${var} with the snapshot version
|
|
! of the given file
|
|
! @file the file to extract the snapshot version from
|
|
! @var the variable name to store the result in
|
|
!-->
|
|
<define:tag name="snapshotVersion">
|
|
<!-- artifact is format blah-blah-blah-yyyymmdd.hhmmss.jar -->
|
|
<u:tokenize var="jarDotBits" delim="-">${file}</u:tokenize>
|
|
<u:tokenize var="snapAndJar" delim=".">${jarDotBits[size(jarDotBits)-1]}</u:tokenize>
|
|
<j:set var="${var}" value="${snapAndJar[0]}.${snapAndJar[1]}" scope="parent"/>
|
|
</define:tag>
|
|
|
|
</define:taglib>
|
|
|
|
<goal name="create-upload-bundle">
|
|
<!-- Create the artifact in question. -->
|
|
<attainGoal name="jar:jar"/>
|
|
|
|
<!-- Delete/create the bundle holding tank -->
|
|
<ant:delete dir="${maven.build.dir}/bundle"/>
|
|
<ant:mkdir dir="${maven.build.dir}/bundle"/>
|
|
|
|
<!-- Copy in the artifact -->
|
|
<ant:copy file="${maven.build.dir}/${maven.final.name}.jar" todir="${maven.build.dir}/bundle"/>
|
|
|
|
<!-- Copy in the POM -->
|
|
<ant:copy file="${basedir}/project.xml" todir="${maven.build.dir}/bundle"/>
|
|
|
|
<!-- Copy in the license, if there is no license this will fail. -->
|
|
<ant:copy file="${basedir}/LICENSE.txt" todir="${maven.build.dir}/bundle"/>
|
|
|
|
<ant:jar
|
|
jarfile="${maven.build.dir}/${maven.final.name}-bundle.jar"
|
|
basedir="${maven.build.dir}/bundle"/>
|
|
|
|
</goal>
|
|
|
|
<goal name="repository:audit-create-licenses"
|
|
description="create the license directories, for all groups in the audit file, in the repository">
|
|
|
|
<j:set var="directoryName" value="licenses"/>
|
|
<attainGoal name="repository:audit-create-directory" />
|
|
</goal>
|
|
|
|
<goal name="repository:audit-create-directory"
|
|
description="create the directory, specified by directoryName, for all groups in the audit file">
|
|
<!--
|
|
! parse audit file
|
|
! run ssh to create each <groupId>/licenses directory.
|
|
!-->
|
|
<maven:param-check value="${directoryName}" fail="true" message="'directoryName' must be specified"/>
|
|
<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="group" select="$audit/licenses/project/groupId">
|
|
<echo>Processing project ${group.text}</echo>
|
|
<j:if test="${!processing and group.text.equals(startProject)}">
|
|
<j:set var="processing" value="true"/>
|
|
</j:if>
|
|
|
|
<j:if test="${processing}">
|
|
<j:set var="directory"
|
|
value="${maven.repo.central.directory}/${group.text}/${directoryName}" />
|
|
<echo>Ensuring directory '${directory}' exists</echo>
|
|
<repository:exec
|
|
command="mkdir -p ${directory};chmod g+ws ${directory};chgrp ${maven.repository.group} ${directory};" />
|
|
</j:if>
|
|
</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 & 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 & 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"/>
|
|
<repository:exec>
|
|
cd ${directory};
|
|
ln -s ${fileName} ${group}.license;
|
|
</repository:exec>
|
|
</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">
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
|
|
|
|
<!--
|
|
! 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 & 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>
|
|
|
|
<goal name="repository:audit-generate-pom"
|
|
description="generate a pom for the groupId provided, based on the audit file">
|
|
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
|
|
|
|
<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)}">
|
|
|
|
<ant:echo>Creating pom for ${group}</ant:echo>
|
|
<x:set var="url" select="string($project/url)"/>
|
|
<x:set var="comments" select="string($project/comments)"/>
|
|
<!-- get file and don't let the & get reescaped -->
|
|
<x:set var="xfile" select="string($project/file)" />
|
|
<j:file name="${maven.build.dir}/${group}.pom" prettyPrint="yes">
|
|
<j:import file="${plugin.resources}/pom-template.jelly" inherit="true"/>
|
|
</j:file>
|
|
</j:if>
|
|
</x:forEach>
|
|
</goal>
|
|
|
|
<goal name="repository:audit-generate-poms"
|
|
description="generate a pom for all the groupId's in the audit file">
|
|
|
|
<repository:parseAudit var="audit"/>
|
|
<x:forEach var="project" select="$audit/licenses/project">
|
|
<j:set var="group"><x:expr select="$project/groupId"/></j:set>
|
|
<j:set var="groupId" value="${group}"/>
|
|
<ant:echo>Creating pom for ${group}</ant:echo>
|
|
<x:set var="url" select="string($project/url)"/>
|
|
<x:set var="comments" select="string($project/comments)"/>
|
|
<!-- get file and don't let the & get reescaped -->
|
|
<x:set var="xfile" select="string($project/file)" />
|
|
<j:file name="${maven.build.dir}/${group}.pom" prettyPrint="yes">
|
|
<j:import file="${plugin.resources}/pom-template.jelly" inherit="true"/>
|
|
</j:file>
|
|
</x:forEach>
|
|
</goal>
|
|
|
|
<!-- expects groupId to be set -->
|
|
<goal name="repository:create-project"
|
|
description="create a project, specified by groupId, in the repository">
|
|
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
|
|
|
|
<repository:exec>
|
|
cd ${maven.repo.central.directory};
|
|
mkdir ${groupId};
|
|
chgrp ${maven.repository.group} ${groupId};
|
|
chmod g+s ${groupId};
|
|
mkdir ${groupId}/distributions;
|
|
mkdir ${groupId}/jars;
|
|
mkdir ${groupId}/licenses;
|
|
mkdir ${groupId}/poms;
|
|
chmod g+ws ${groupId};
|
|
chmod -R g+w,a+r ${groupId};
|
|
</repository:exec>
|
|
</goal>
|
|
|
|
<!-- expects groupId to be set -->
|
|
<goal name="repository:delete-project"
|
|
description="delete a project, specified by groupId, in the repository">
|
|
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
|
|
|
|
<repository:exec>
|
|
cd ${maven.repo.central.directory};
|
|
rm -rf ${groupId};
|
|
</repository:exec>
|
|
</goal>
|
|
|
|
<!--
|
|
! this is pretty much a copy of whats in jar:deploy-snapshot, except
|
|
! this uses any old file for copying, not just the output of the project
|
|
!-->
|
|
<goal name="repository:copy-snapshot-jar"
|
|
description="copy a snapshot jar, specified by groupId and artifact, to the repository">
|
|
|
|
<maven:param-check value="${artifact}" fail="true" message="'artifact' must be specified"/>
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
|
|
|
|
<j:if test="${empty(artifactId)}">
|
|
<j:set var="artifactId">${groupId}</j:set>
|
|
</j:if>
|
|
|
|
<repository:snapshotVersion var="snapshotVersion" file="${artifact}" />
|
|
<echo>snapshotVersion = '${snapshotVersion}'</echo>
|
|
|
|
<attainGoal name="repository:copy-jar" />
|
|
|
|
<j:set var="directory" value="${maven.repo.central.directory}/${groupId}/jars/" />
|
|
|
|
<u:file name="${artifact}" var="artifactFile"/>
|
|
<j:set var="artifactName">${artifactFile.canonicalFile.name}</j:set>
|
|
|
|
<echo>Setting up SNAPSHOT entries</echo>
|
|
<repository:exec>
|
|
cd ${directory};
|
|
ln -sf ${artifactName} ${artifactId}-SNAPSHOT.jar;
|
|
ln -sf ${artifactName}.md5 ${artifactId}-SNAPSHOT.jar.md5;
|
|
echo ${snapshotVersion} | tee ${artifactId}-snapshot-version;
|
|
chgrp ${maven.repository.group} ${artifactId}-SNAPSHOT.jar*;
|
|
chmod g+w,a+r ${artifactId}-SNAPSHOT.jar*;
|
|
</repository:exec>
|
|
</goal>
|
|
|
|
<!--
|
|
! this uses any old file for copying
|
|
!-->
|
|
<goal name="repository:copy-jar"
|
|
description="copy a jar, specified by groupId and artifact, to the repository">
|
|
|
|
<maven:param-check value="${artifact}" fail="true" message="'artifact' must be specified"/>
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
|
|
|
|
<j:set var="type" value="jar" />
|
|
|
|
<attainGoal name="repository:copy-artifact" />
|
|
</goal>
|
|
|
|
<!--
|
|
! this uses any old file for copying
|
|
!-->
|
|
<goal name="repository:copy-artifact"
|
|
description="copy an artifact, specified by groupId, artifact and type, to the repository">
|
|
|
|
<maven:param-check value="${artifact}" fail="true" message="'artifact' must be specified"/>
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
|
|
<maven:param-check value="${type}" fail="true" message="'type' must be specified" />
|
|
|
|
<j:set var="directory" value="${maven.repo.central.directory}/${groupId}/${type}s/" />
|
|
<repository:exec command="mkdir -p ${directory}; chmod g+ws ${directory}; chgrp ${maven.repository.group} ${directory}"/>
|
|
<repository:copy from="${artifact}" toFileOrDir="${directory}" />
|
|
|
|
<u:file name="${artifact}" var="artifactFile"/>
|
|
<j:set var="artifactName">${artifactFile.canonicalFile.name}</j:set>
|
|
|
|
<repository:exec>
|
|
cd ${directory};
|
|
md5sum ${artifactName} | sed 's/ .*$//' | tee ${artifactName}.md5;
|
|
chgrp ${maven.repository.group} *;
|
|
chmod g+w,a+r *;
|
|
</repository:exec>
|
|
</goal>
|
|
|
|
</project>
|