<?xml version="1.0" encoding="UTF-8"?>
<!--
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.

This work is copyright by the author(s) and is part of a greater work collectively copyright by the
Groovy community. See the NOTICE.txt file distributed with this work for additional information.

Author : Paul King
$Revision: 11954 $ ($LastChangedBy: paulk $)
$Date: 2008-04-22 05:04:01 -0500 (Tue, 22 Apr 2008) $
-->
<project name="maven" xmlns:artifact="urn:maven-artifact-ant">

    <macrodef name="maven.dependencies">
        <attribute name="useScope"/>
        <attribute name="filesetId"/>
        <attribute name="pomRefId"/>
        <sequential>
            <artifact:dependencies useScope="@{useScope}" filesetId="@{filesetId}">
                <remoteRepository refid="ibiblio.remote.repository"/>
                <remoteRepository refid="repo1.remote.repository"/>
                <pom refid="@{pomRefId}"/>
            </artifact:dependencies>
        </sequential>
    </macrodef>

    <macrodef name="maven.pom">
        <attribute name="dir"/>
        <attribute name="id"/>
        <attribute name="file" default="@{dir}/@{id}"/>
        <sequential>
            <artifact:pom file="@{file}" id="@{id}"/>
        </sequential>
    </macrodef>

    <macrodef name="maven.remote.repository">
        <attribute name="id"/>
        <attribute name="url"/>
        <sequential>
            <artifact:remoteRepository id="@{id}" url="@{url}"/>
        </sequential>
    </macrodef>

    <target name="-mavenInit" depends="-mavenTaskdef,-mavenPomDefinitions,-mavenRepositoryDefinitions"/>

    <!-- Bring the Maven Ant tasks into the build -->
    <target name="-mavenTaskdef">
        <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
            <classpath>
                <fileset dir="${basedir}/ant/lib" includes="maven-ant-tasks-*.jar"/>
            </classpath>
        </typedef>
    </target>

    <target name="-mavenRepositoryDefinitions">
        <maven.remote.repository id="repo1.remote.repository" url="http://repo1.maven.org/maven2"/>
        <maven.remote.repository id="ibiblio.remote.repository" url="http://ibiblio.org/maven2"/>
        <maven.remote.repository id="codehaus.remote.repository" url="http://repository.codehaus.org"/>
        <maven.remote.repository id="snapshots.codehaus.remote.repository" url="http://snapshots.repository.codehaus.org"/>
    </target>

    <target name="-mavenDeployInit" depends="-mavenInit">
        <artifact:install-provider artifactId="wagon-webdav" version="1.0-beta-2"/>
    </target>

    <macrodef name="mavenDeploy">
        <attribute name="version"/>
        <attribute name="prefix"/>
        <sequential>
            <artifact:deploy file="${targetDistDirectory}/@{prefix}-@{version}.jar">
                <pom refid="@{prefix}.pom"/>
                <!--
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-sources.jar" classifier="sources"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-javadoc.jar" classifier="javadoc"/>
                -->
            </artifact:deploy>
        </sequential>
    </macrodef>

    <macrodef name="mavenInstallRepo">
        <attribute name="version"/>
        <attribute name="prefix"/>
        <sequential>
            <checksum file="${pom.target.dir}/@{prefix}.pom" algorithm="sha1" todir="${targetDistDirectory}"/>
            <artifact:install file="${targetDistDirectory}/@{prefix}-@{version}.jar">
                <pom refid="@{prefix}.pom"/>
                <attach file="${targetDistDirectory}/@{prefix}.pom.sha1" type="pom.sha1"/>
                  <!--
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-sources.jar" classifier="sources"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-javadoc.jar" classifier="javadoc"/>
                -->
            </artifact:install>
        </sequential>
    </macrodef>

    <macrodef name="mavenInstallRepoJar">
        <attribute name="version"/>
        <attribute name="prefix"/>
        <sequential>
            <checksum file="${pom.target.dir}/@{prefix}.pom" algorithm="sha1" todir="${targetDistDirectory}"/>
            <checksum file="${targetDistDirectory}/@{prefix}-@{version}.jar" algorithm="sha1"/>
            <artifact:install file="${targetDistDirectory}/@{prefix}-@{version}.jar">
                <pom refid="@{prefix}.pom"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}.jar.sha1" type="jar.sha1"/>
                <attach file="${targetDistDirectory}/@{prefix}.pom.sha1" type="pom.sha1"/>
                <!--
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-sources.jar" classifier="sources"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-javadoc.jar" classifier="javadoc"/>
                -->
            </artifact:install>
        </sequential>
    </macrodef>
</project>
