utils.xml (80 lines of code) (raw):

<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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:artifact="antlib:org.apache.maven.artifact.ant"> <!-- xml namespace which is used to deploy the artifacts with maven --> <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpath="lib/maven-ant-tasks-2.1.3.jar"/> <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="lib/ant-contrib-0.6.jar"/> <!-- defined maven snapshots and staging repository id and url --> <property name="maven-staging-repository-id" value="apache.releases.https" /> <property name="maven-staging-repository-url" value="https://repository.apache.org/service/local/staging/deploy/maven2" /> <property name="maven-pgp-passphrase" value=""/> <property name="maven-pgp-keyname" value=""/> <macrodef name="apache-deploy"> <attribute name="binaryFile"/> <attribute name="sourcesFile" default=""/> <attribute name="docFile" default=""/> <attribute name="todir"/> <attribute name="pomTemplate"/> <attribute name="artifact"/> <attribute name="type"/> <attribute name="name"/> <attribute name="version"/> <attribute name="description"/> <sequential> <!-- Create POM from template --> <copy file="@{pomTemplate}" tofile="@{todir}/@{artifact}-@{version}.pom"/> <replace file="@{todir}/@{artifact}-@{version}.pom"> <replacefilter token="@ARTIFACT@" value="@{artifact}"/> <replacefilter token="@TYPE@" value="@{type}"/> <replacefilter token="@NAME@" value="@{name}"/> <replacefilter token="@VERSION@" value="@{version}"/> <replacefilter token="@DESCRIPTION@" value="@{description}"/> </replace> <copy file="@{binaryFile}" tofile="@{todir}/@{artifact}-@{version}.@{type}" /> <if> <equals arg1="@{type}" arg2="jar" /> <then> <copy file="@{sourcesFile}" tofile="@{todir}/@{artifact}-@{version}-sources.@{type}" /> <copy file="@{docFile}" tofile="@{todir}/@{artifact}-@{version}-javadoc.@{type}" /> </then> </if> <!-- sign and deploy the main artifact --> <artifact:mvn> <artifact:arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file"/> <artifact:arg value="-Durl=${maven-staging-repository-url}"/> <artifact:arg value="-DrepositoryId=${maven-staging-repository-id}"/> <artifact:arg value="-DpomFile=@{todir}/@{artifact}-@{version}.pom"/> <artifact:arg value="-Dfile=@{todir}/@{artifact}-@{version}.@{type}"/> <artifact:arg value="-Dgpg.passphrase=${maven-pgp-passphrase}"/> <artifact:arg value="-Dgpg.keyname=${maven-pgp-keyname}"/> <artifact:arg value="-Pgpg"/> </artifact:mvn> <if> <equals arg1="@{type}" arg2="jar" /> <then> <!-- sign and deploy the sources artifact --> <artifact:mvn> <artifact:arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file"/> <artifact:arg value="-Durl=${maven-staging-repository-url}"/> <artifact:arg value="-DrepositoryId=${maven-staging-repository-id}"/> <artifact:arg value="-DpomFile=@{todir}/@{artifact}-@{version}.pom"/> <artifact:arg value="-Dfile=@{todir}/@{artifact}-@{version}-sources.@{type}"/> <artifact:arg value="-Dclassifier=sources"/> <artifact:arg value="-Dgpg.passphrase=${maven-pgp-passphrase}"/> <artifact:arg value="-Dgpg.keyname=${maven-pgp-keyname}"/> <artifact:arg value="-Pgpg"/> </artifact:mvn> <!-- sign and deploy the javadoc artifact --> <artifact:mvn> <artifact:arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file"/> <artifact:arg value="-Durl=${maven-staging-repository-url}"/> <artifact:arg value="-DrepositoryId=${maven-staging-repository-id}"/> <artifact:arg value="-DpomFile=@{todir}/@{artifact}-@{version}.pom"/> <artifact:arg value="-Dfile=@{todir}/@{artifact}-@{version}-javadoc.@{type}"/> <artifact:arg value="-Dclassifier=javadoc"/> <artifact:arg value="-Dgpg.passphrase=${maven-pgp-passphrase}"/> <artifact:arg value="-Dgpg.keyname=${maven-pgp-keyname}"/> <artifact:arg value="-Pgpg"/> </artifact:mvn> </then> </if> </sequential> </macrodef> </project>