Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1960 mtynas 1
<project name="using-macrodef">
2
 
3
	<!--	C O P Y R I G H T   N O T I C E
1962 mhunt 4
			This material is confidential to ERG and may not be disclosed in whole
1960 mtynas 5
			or in part to any third party nor used in any manner whatsoever other
6
			than for the purposes expressly consented to by ERG in writing.
7
 
8
			This material is also copyright and may not be reproduced, stored in a
9
			retrieval system or transmitted in any form or by any means in whole or
10
			in part without the express written consent of ERG.
11
	-->
12
 
13
 
14
	<!--						BUILD ENVIRONMENT NOTES
15
 
16
		GBE_DPKG_CACHE	=	Global Build Environment DPKG Cache
1962 mhunt 17
							(This location holds the local set of artefacts acquired from DPKG,
1960 mtynas 18
							 for use within a build)
19
 
20
		GBE_DPKG		=	Global Build Environment DPKG source
21
 
22
	-->
23
 
24
	<property name="env" environment="env" value="not used"/>
25
 
26
 
27
	<macrodef name="using">
28
 
29
		<attribute name="name"/>
30
		<attribute name="version"/>
31
		<attribute name="includes" default="" />
32
		<attribute name="from"     default="${env.GBE_DPKG}"/>
33
		<attribute name="refid"    default="@{name}"/>
34
		<attribute name="copy"     default="true"/>
35
 
36
		<element name="using-fileset" optional="yes" implicit="yes" description="Anything you can put in a fileset."/>
37
 
38
		<sequential>
39
 
40
			<property name="using.@{name}.version" value="@{version}"/>
41
 
42
			<fail message="The 'using' for package @{name} has already been declared as version @{version}" status="2">
43
				<condition>
44
					<and>
45
						<isset	property="using.@{name}.version"/>
46
						<not><equals	arg1="${using.@{name}.version}" arg2="@{version}"/></not>
47
					</and>
48
				</condition>
49
			</fail>
50
 
51
			<if>
52
				<isset property="using.@{refid}.basedir"/>
53
				<then>
54
					<echo taskname="ant-using" level="verbose">@{name} has already been defined. Skipping import...</echo>
55
				</then>
56
				<else>
57
					<if>
58
						<not><isset property="manifest.prepared"/></not>
59
						<then>
60
							<delete file="${basedir}/build/pkg/descpkg" quiet="true"/>
61
							<property name="manifest.prepared" value="true"/>
62
						</then>
63
					</if>
64
 
65
					<if>
66
						<equals arg1="@{copy}" arg2="true"/>
67
						<then>
68
							<property name="using.@{refid}.basedir" value="${build.repository}/@{name}/@{version}"/>
69
						</then>
70
						<else>
71
							<property name="using.@{refid}.basedir" value="@{from}/@{name}/@{version}"/>
72
						</else>
73
					</if>
74
 
75
					<mkdir dir="${basedir}/build/pkg"/>
76
					<manifest file="${basedir}/build/pkg/descpkg" mode="update">
77
						<section name="Build Dependencies">
78
							<attribute name="@{name}" value="@{version}"/>
79
						</section>
80
					</manifest>
81
 
82
 
83
					<echo taskname="ant-using">Using @{name} version @{version}</echo>
84
					<if>
85
						<equals arg1="@{copy}" arg2="true"/>
86
						<then>
87
 
88
							<!-- Only copy from the package archive is the source and target locations are different -->
89
							<if>
90
								<not><equals arg1="@{from}/@{name}/@{version}" arg2="${using.@{refid}.basedir}"/></not>
91
								<then>
92
									<mkdir dir="${using.@{refid}.basedir}"/>
93
									<copy todir="${using.@{refid}.basedir}" verbose="yes">
94
										<fileset dir="@{from}/@{name}/@{version}" includes="@{includes}">
95
											<exclude name="descpkg"/>
96
											<!--patternset refid="@{name}.patternset-libraries"/-->
97
											<using-fileset/>
98
										</fileset>
99
									</copy>
100
								</then>
101
								<else>
102
									<echo taskname="ant-using">Skipping Copy from ${using.@{refid}.basedir} where Source = Target location</echo>
103
								</else>
104
							</if>
105
 
106
						</then>
107
					</if>
108
 
109
					<path id="using.@{refid}.path">
110
						<fileset dir="${using.@{refid}.basedir}" includes="@{includes}">
111
							<using-fileset/>
112
						</fileset>
113
					</path>
114
 
1962 mhunt 115
					<path id="using.@{refid}.classpath">
116
						<fileset dir="${using.@{refid}.basedir}" includes="**/*.jar">
117
							<using-fileset/>
118
						</fileset>
119
					</path>
120
 
1960 mtynas 121
					<!-- Look for an ant script in the dependency named [name].xml - if it exists, import it.
122
						 Otherwise, carry on and ignore the fact that it does not exist. -->
123
					<trycatch>
124
						<try>
125
							<import file="${using.@{refid}.basedir}/@{name}.xml" optional="true"/>
126
						</try>
127
						<catch>
128
							<echo taskname="ant-using" level="warning" message="Import ignored when called within target."/>
129
						</catch>
130
					</trycatch>
131
 
132
 
133
				</else>
134
			</if>
135
 
136
		</sequential>
137
 
138
	</macrodef>
139
 
140
</project>