Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2359cf2a1038896b48e3a4734408a04b4f444a39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<?xml version="1.0" encoding="UTF-8"?>
<!--
 ******************************************************************************
 * Copyright (c) 2008, 2010 VMware Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   VMware Inc. - initial contribution
 ******************************************************************************
-->
<project name="common-common" xmlns:ivy="antlib:org.apache.ivy.ant">

	<tstamp>
		<format property="timestamp" pattern="yyyyMMddHHmmss" timezone="GMT"/>
	</tstamp>

<!-- Properties -->
	<dirname property="virgo.build.dir" file="${ant.file.common-common}/.."/>
	<property file="${virgo.build.dir}/common/common.properties"/>

<!-- Global tasks -->
	<condition property="adjusted.release.type" value="snapshot" else="${release.type}">
		<equals arg1="integration" arg2="${release.type}"/>
	</condition>

<!-- Main targets -->
	<target name="clean" description="Removes the target directory.">
		<delete quiet="false" failonerror="false" dir="${target.dir}"/>
	</target>

	<target name="clean-integration" description="Removes the integration repository directory.">
		<fail message="The 'integration.repo.dir' property must be set on this project.">
			<condition>
				<not>
					<isset property="integration.repo.dir"/>
				</not>
			</condition>
		</fail>
        <fail message="The 'project.organisation' property must be set on this project.">
			<condition>
				<not>
					<isset property="project.organisation"/>
				</not>
			</condition>
		</fail>
		<echo message="Project Integration Repo: ${integration.repo.dir}/${project.organisation}"/>
		<echo message="Project Ivy Cache: ${ivy.cache.dir}/repository/${project.organisation}"/>
		<delete quiet="false" failonerror="false" dir="${integration.repo.dir}/${project.organisation}"/>
		<delete quiet="false" failonerror="false" dir="${ivy.cache.dir}/repository/${project.organisation}"/>
	</target>

	<target name="clean-all-integration" description="Removes the integration repository directory.">
		<fail message="The 'integration.repo.dir' property must be set on this project.">
			<condition>
				<not>
					<isset property="integration.repo.dir"/>
				</not>
			</condition>
		</fail>
		<echo message="Integration Repo: ${integration.repo.dir}"/>
		<delete quiet="false" failonerror="false" dir="${integration.repo.dir}"/>
	</target>

	<target name="clean-ivy" description="Removes the ivy cache directory.">
		<fail message="The 'ivy.cache.dir' property must be set on this project.">
			<condition>
				<not>
					<isset property="ivy.cache.dir"/>
				</not>
			</condition>
		</fail>
		<echo message="Ivy Cache: ${ivy.cache.dir}"/>
		<delete quiet="false" failonerror="false" dir="${ivy.cache.dir}"/>
	</target>

	<target name="resolve" depends="resolve.init" description="Retrieves all external dependencies for this project.">
		<ivy:resolve id="all.classpath" log="download-only"/>
	</target>

<!-- Other targets -->
	<target name="ivy.init" unless="ivy.initialized">
		<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant">
			<classpath>
				<path location="${ivy.lib.dir}/ivy-2.3.0.jar"/>
				<path location="${ivy.lib.dir}/org.springframework.build.aws.ivy.jar"/>
				<path location="${ivy.lib.dir}/commons-codec.jar"/>
				<path location="${ivy.lib.dir}/commons-httpclient.jar"/>
				<path location="${ivy.lib.dir}/commons-logging.jar"/>
				<path location="${ivy.lib.dir}/jets3t.jar"/>
				<path location="${ivy.lib.dir}/com.jcraft.jsch_0.1.50.v201310081430.jar"/>
				<path location="${ivy.lib.dir}"/>
			</classpath>
		</taskdef>
		<ivy:settings file="${ivy.settings.file}"/>
		<property name="ivy.initialized" value="true"/>
	</target>

	<target name="resolve.init" depends="ivy.file.exists">
		<fail message="Dependency resolution requires an ${ivy.file} file to exist.">
			<condition>
				<not>
					<isset property="ivy.file.exists"/>
				</not>
			</condition>
		</fail>
	</target>

	<target name="ivy.file.exists" depends="ivy.init">
		 <condition property="ivy.file.exists">
			<available file="${ivy.file}"/>
		</condition>
	</target>

	<target name="resolve.compile" depends="resolve.init">
		<ivy:cachepath resolveId="compile.classpath" pathid="compile.classpath" conf="compile,optional,provided,server-provided" type="jar" log="download-only"/>
	</target>

	<target name="resolve.test" depends="resolve.init, resolve.compile">
		<ivy:cachepath resolveId="test.classpath" pathid="test.classpath" conf="test" type="jar" log="download-only"/>
		<ivy:cachepath resolveId="runtime.classpath" pathid="runtime.classpath" conf="runtime" type="jar" log="download-only"/>
	</target>

	<target name="resolve.aspects" depends="resolve.init">
		<ivy:cachepath resolveId="aspects.classpath" pathid="aspects.classpath" conf="aspects" type="jar" log="download-only"/>
	</target>

	<target name="resolve.external" depends="resolve.init">
		<ivy:cachepath resolveId="external.classpath" pathid="external.classpath" conf="external" type="jar" transitive="false" log="download-only"/>
		<ivy:cachepath resolveId="external.srcpath" pathid="external.srcpath" conf="external" type="src" transitive="false" log="download-only"/>
	</target>

	<target name="src.init">
		<condition property="src.exists">
			<resourcecount when="gt" count="0">
				<fileset dir="${main.java.dir}" erroronmissingdir="false">
					<include name="**/*.java"/>
					<include name="*.java"/>
				</fileset>
			</resourcecount>
		</condition>
	</target>

	<target name="test.init">
		<condition property="test.exists">
			<resourcecount when="gt" count="0">
				<fileset dir="${test.java.dir}" erroronmissingdir="false">
					<include name="**/*.java"/>
					<include name="*.java"/>
				</fileset>
			</resourcecount>
        </condition>
        
        <!-- init the property containing the ivy-cache and the integration repo location placeholders -->
        <delete file="${basedir}/../user-ivy.properties"/>
        <!-- replace the backslashes with slashes in the ivy.cache.dir -->
        <echo message="${ivy.cache.dir}" file="tmp.file" />
        <loadfile property="transformed.ivy.cache.dir" srcFile="tmp.file">
            <filterchain>
                <tokenfilter>
                    <replaceregex pattern="\\" replace="/" flags="g"/>
                </tokenfilter>
            </filterchain>
        </loadfile>
        <delete file="tmp.file"/>

        <echo file="${basedir}/../user-ivy.properties" message="ivy.cache=${transformed.ivy.cache.dir}&#xa;"/> 
	</target>

	<target name="diagnostics" description="diagnostics">
		<sequential>
			<echo>The diagnostics target was explicitly requested...</echo>
			<echo>----Ant diagnostics-------------------------------</echo>
        	<diagnostics/>
			<echo>----Properties--Ant-------------------------------</echo>
			<echoproperties>
				<propertyset>
					<propertyref builtin="all"/>
				</propertyset>
			</echoproperties>
			<echo>----Environment-----------------------------------</echo>
			<property environment="env"/>
			<echoproperties>
				<propertyset>
					<propertyref prefix="env."/>
				</propertyset>
			</echoproperties>
			<echo>--------------------------------------------------</echo>
			<fail message="Diagnostics output -- build aborted."/>
		</sequential>
    </target>

	<target name="exec-ant" description="execute an ant command">
		<sequential>
			<echo>exec-ant for target '${exec-ant-target}' executing in directory '${basedir}'</echo>
			<exec executable="ant" dir="${basedir}"
				failonerror="true" osfamily="unix"
				resultproperty="exec-ant-rc">
			    <arg value="${exec-ant-target}"/>
				<arg value="-Dci.build=${ci.build}"/>
				<arg value="-Dtimestamp=${timestamp}"/>
				<arg value="-Dbundle.version=${bundle.version}"/>
                <arg value="-Dvirgo.deps.location=${virgo.deps.location}"/>
				<arg value="${exec-args}"/>
			</exec>
			<exec executable="${virgo.build.dir}\common\runant.bat" dir="${basedir}"
				failonerror="true" osfamily="windows"
				resultproperty="exec-ant-rc">
			    <arg value="${exec-ant-target}"/>
				<arg value="-Dci.build=${ci.build}"/>
				<arg value="-Dtimestamp=${timestamp}"/>
				<arg value="-Dbundle.version=${bundle.version}"/>
                <arg value="-Dvirgo.deps.location=${virgo.deps.location}"/>
				<arg value="${exec-args}"/>
			</exec>
			<echo>exec-ant for target '${exec-ant-target}' gave return code ${exec-ant-rc}</echo>
		</sequential>
	</target>	

<!-- Macros -->
	<macrodef name="compile">
		<attribute name="classpath.id"/>
		<attribute name="input.dir"/>
		<attribute name="output.dir"/>
		<attribute name="resources.dir"/>
		<sequential>
			<delete quiet="true" dir="@{output.dir}"/>
			<mkdir dir="@{output.dir}"/>
			<pre-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}"
					resources.dir="@{resources.dir}"/>
			<do-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}"
					resources.dir="@{resources.dir}"/>
			<post-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}"
					resources.dir="@{resources.dir}"/>
		</sequential>
	</macrodef>

	<macrodef name="test-compile">
		<attribute name="classpath.id"/>
		<attribute name="input.dir"/>
		<attribute name="output.dir"/>
		<attribute name="resources.dir"/>
		<sequential>
			<delete quiet="true" dir="@{output.dir}"/>
			<mkdir dir="@{output.dir}"/>
			<test-pre-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}"
					resources.dir="@{resources.dir}"/>
			<do-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}"
					resources.dir="@{resources.dir}"/>
			<test-post-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}"
					resources.dir="@{resources.dir}"/>
		</sequential>
	</macrodef>

	<macrodef name="pre-compile">
		<attribute name="classpath.id"/>
		<attribute name="input.dir"/>
		<attribute name="output.dir"/>
		<attribute name="resources.dir"/>
		<sequential/>
	</macrodef>

	<macrodef name="post-compile">
		<attribute name="classpath.id"/>
		<attribute name="input.dir"/>
		<attribute name="output.dir"/>
		<attribute name="resources.dir"/>
		<sequential/>
	</macrodef>

	<macrodef name="test-pre-compile">
		<attribute name="classpath.id"/>
		<attribute name="input.dir"/>
		<attribute name="output.dir"/>
		<attribute name="resources.dir"/>
		<sequential/>
	</macrodef>

	<macrodef name="test-post-compile">
		<attribute name="classpath.id"/>
		<attribute name="input.dir"/>
		<attribute name="output.dir"/>
		<attribute name="resources.dir"/>
		<sequential/>
	</macrodef>

	<macrodef name="java-doc">
		<attribute name="input.dir"/>
		<attribute name="output.dir"/>
		<attribute name="classpath.id"/>
		<attribute name="access"/>
		<attribute name="exclude.package.names" default=""/>
		<sequential>
			<delete quiet="true" dir="@{output.dir}"/>
			<mkdir dir="@{output.dir}"/>
			<javadoc.links sourcepath="@{input.dir}" destdir="@{output.dir}" classpathref="@{classpath.id}"
					access="@{access}" excludepackagenames="@{exclude.package.names}" maxmemory="${javadoc.max.memory}"
					stylesheetfile="${javadoc.stylesheet.file}" splitindex="true" useexternalfile="true">
				<header><![CDATA[<!-- Begin Google Analytics code --> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-2728886-3"); pageTracker._setDomainName("none"); pageTracker._setAllowLinker(true); pageTracker._trackPageview(); </script> <!-- End Google Analytics code -->]]></header>
				<bottom><![CDATA[<!-- Begin LoopFuse code --> <script src="http://loopfuse.net/webrecorder/js/listen.js" type="text/javascript"> </script> <script type="text/javascript"> _lf_cid = "LF_48be82fa"; _lf_remora(); </script> <!-- End LoopFuse code -->]]></bottom>
			</javadoc.links>
			<copy toDir="@{output.dir}/resources">
				<fileset dir="${javadoc.resources.dir}" erroronmissingdir="false"/>
			</copy>
		</sequential>
	</macrodef>
	
	<presetdef name="javadoc.links">
		<javadoc/>
	</presetdef>

</project>

Back to the top