Subversion Repositories DevTools

Rev

Rev 1960 | Blame | Last modification | View Log | RSS feed

<project name="using-macrodef">

        <!--    C O P Y R I G H T   N O T I C E
                        This material is confidential to ERG and may not be disclosed in whole
                        or in part to any third party nor used in any manner whatsoever other
                        than for the purposes expressly consented to by ERG in writing.

                        This material is also copyright and may not be reproduced, stored in a
                        retrieval system or transmitted in any form or by any means in whole or
                        in part without the express written consent of ERG.
        -->


        <!--                                            BUILD ENVIRONMENT NOTES

                GBE_DPKG_CACHE  =       Global Build Environment DPKG Cache
                                                        (This location holds the local set of artefacts acquired from DPKG,
                                                         for use within a build)

                GBE_DPKG                =       Global Build Environment DPKG source

        -->

        <property name="env" environment="env" value="not used"/>


        <macrodef name="using">

                <attribute name="name"/>
                <attribute name="version"/>
                <attribute name="includes" default="" />
                <attribute name="from"     default="${env.GBE_DPKG}"/>
                <attribute name="refid"    default="@{name}"/>
                <attribute name="copy"     default="true"/>

                <element name="using-fileset" optional="yes" implicit="yes" description="Anything you can put in a fileset."/>

                <sequential>

                        <property name="using.@{name}.version" value="@{version}"/>

                        <fail message="The 'using' for package @{name} has already been declared as version @{version}" status="2">
                                <condition>
                                        <and>
                                                <isset  property="using.@{name}.version"/>
                                                <not><equals    arg1="${using.@{name}.version}" arg2="@{version}"/></not>
                                        </and>
                                </condition>
                        </fail>

                        <if>
                                <isset property="using.@{refid}.basedir"/>
                                <then>
                                        <echo taskname="ant-using" level="verbose">@{name} has already been defined. Skipping import...</echo>
                                </then>
                                <else>
                                        <if>
                                                <not><isset property="manifest.prepared"/></not>
                                                <then>
                                                        <delete file="${basedir}/build/pkg/descpkg" quiet="true"/>
                                                        <property name="manifest.prepared" value="true"/>
                                                </then>
                                        </if>

                                        <if>
                                                <equals arg1="@{copy}" arg2="true"/>
                                                <then>
                                                        <property name="using.@{refid}.basedir" value="${build.repository}/@{name}/@{version}"/>
                                                </then>
                                                <else>
                                                        <property name="using.@{refid}.basedir" value="@{from}/@{name}/@{version}"/>
                                                </else>
                                        </if>

                                        <mkdir dir="${basedir}/build/pkg"/>
                                        <manifest file="${basedir}/build/pkg/descpkg" mode="update">
                                                <section name="Build Dependencies">
                                                        <attribute name="@{name}" value="@{version}"/>
                                                </section>
                                        </manifest>


                                        <echo taskname="ant-using">Using @{name} version @{version}</echo>
                                        <if>
                                                <equals arg1="@{copy}" arg2="true"/>
                                                <then>

                                                        <!-- Only copy from the package archive is the source and target locations are different -->
                                                        <if>
                                                                <not><equals arg1="@{from}/@{name}/@{version}" arg2="${using.@{refid}.basedir}"/></not>
                                                                <then>
                                                                        <mkdir dir="${using.@{refid}.basedir}"/>
                                                                        <copy todir="${using.@{refid}.basedir}" verbose="yes">
                                                                                <fileset dir="@{from}/@{name}/@{version}" includes="@{includes}">
                                                                                        <exclude name="descpkg"/>
                                                                                        <!--patternset refid="@{name}.patternset-libraries"/-->
                                                                                        <using-fileset/>
                                                                                </fileset>
                                                                        </copy>
                                                                </then>
                                                                <else>
                                                                        <echo taskname="ant-using">Skipping Copy from ${using.@{refid}.basedir} where Source = Target location</echo>
                                                                </else>
                                                        </if>

                                                </then>
                                        </if>

                                        <path id="using.@{refid}.path">
                                                <fileset dir="${using.@{refid}.basedir}" includes="@{includes}">
                                                        <using-fileset/>
                                                </fileset>
                                        </path>

                                        <path id="using.@{refid}.classpath">
                                                <fileset dir="${using.@{refid}.basedir}" includes="**/*.jar">
                                                        <using-fileset/>
                                                </fileset>
                                        </path>

                                        <!-- Look for an ant script in the dependency named [name].xml - if it exists, import it.
                                                 Otherwise, carry on and ignore the fact that it does not exist. -->
                                        <trycatch>
                                                <try>
                                                        <import file="${using.@{refid}.basedir}/@{name}.xml" optional="true"/>
                                                </try>
                                                <catch>
                                                        <echo taskname="ant-using" level="warning" message="Import ignored when called within target."/>
                                                </catch>
                                        </trycatch>


                                </else>
                        </if>

                </sequential>

        </macrodef>

</project>