Skip to main content
summaryrefslogtreecommitdiffstats
blob: 089d745f1bd038f2a94e700fb5538091af17a497 (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
<project>

	<import file="download-dependencies.xml" />

	<taskdef resource="net/sf/antcontrib/antlib.xml">
		<classpath>
			<pathelement location="externals/libs/ant-contrib-1.0b3.jar" />
		</classpath>
	</taskdef>

	<property environment="env" />
	<condition property="path" value="${env.PATH}">
		<isset property="env.PATH" />
	</condition>
	<condition property="path" value="${env.Path}">
		<isset property="env.Path" />
	</condition>

	<macrodef name="check.executable">
		<attribute name="executable" />
		<sequential>
			<echo>Checking for @{executable} on path.</echo>
			<available file="@{executable}" filepath="${path}" property="@{executable}.executable.available" />
			<available file="@{executable}.exe" filepath="${path}" property="@{executable}.executable.available" />
			<fail unless="@{executable}.executable.available" message="@{executable} not available on path. Please ensure that @{executable} is on path." />
			<echo>Found @{executable} on path.</echo>
		</sequential>
	</macrodef>

	<condition property="isWin">
		<contains casesensitive="false" substring="win" string="${os.name}" />
	</condition>

	<target name="check-windows-preconditions" if="isWin">
		<check.executable executable="unzip" />
	</target>

	<target name="check-other-preconditions" unless="isWin">
		<check.executable executable="tar" />
	</target>

	<target name="guess-pde-build-version" unless="pde-build-version">
		<echo>Guessing plugin version of org.eclipse.pde.build.</echo>
		<for param="pde-build-file">
			<dirset dir="../eclipse/plugins/" includes="org.eclipse.pde.build_*" />
			<sequential>
				<propertyregex property="pde-build-version" input="@{pde-build-file}" regexp="org.eclipse.pde.build_(.*)" select="\1" />
			</sequential>
		</for>
		<fail unless="pde-build-version" message="Could not find org.eclipse.pde.build in target eclipse" />
		<echo>Plugin version of org.eclipse.pde.build is "${pde-build-version}"</echo>
	</target>

	<target name="create-build-properties-from-template">
		<copy file="build.properties.template" tofile="build.properties" overwrite="true">
			<filterset>
				<filter token="PDE_BUILD_PLUGIN_VERSION" value="${pde-build-version}" />
			</filterset>
		</copy>
		<property file="build.properties" />
	</target>

	<target name="check-conditions" depends="download-dependencies, check-windows-preconditions, check-other-preconditions">
		<check.executable executable="git" />
		<available file="build.developer.properties" property="build.developer.properties.available" />
		<available file="host-conf/build.${hostname}.properties" property="build.developer.properties.available" />
		<fail unless="build.developer.properties.available">Could not find the file "build.developer.properties", or host-conf/build.${hostname}.properties. Please create the file using "build.developer.properties.sample" as the starting point.</fail>
	</target>

	<target name="guess-junit-version">
		<echo>Guessing plugin version of org.junit4.</echo>
		<for param="junit-version-file">
			<dirset dir="../eclipse/plugins/" includes="org.junit4_*" />
			<sequential>
				<propertyregex property="junit4-build-version" input="@{junit-version-file}" regexp="org.junit4_(.*)" select="\1" />
			</sequential>
		</for>
		<condition property="isJunit4.8">
			<contains string="${junit4-build-version}" substring="4.8" />
		</condition>
		<condition property="isJunit4.5">
			<contains string="${junit4-build-version}" substring="4.5" />
		</condition>
		<condition property="isJunit4.3">
			<contains string="${junit4-build-version}" substring="4.3" />
		</condition>
		<fail unless="junit4-build-version" message="Could not find org.junit4 in target eclipse" />
		<echo>Plugin version of org.junit is "${junit4-build-version}"</echo>
		<echo>isJunit4.3: ${isJunit4.3}</echo>
		<echo>isJunit4.5: ${isJunit4.5}</echo>
		<echo>isJunit4.8: ${isJunit4.8}</echo>
	</target>

	<target name="initialize-environment" depends="guess-junit-version, guess-pde-build-version, create-build-properties-from-template" />

	<delete file=".git.properties" />
	<touch file=".git.properties" />

	<!-- guess git revision -->
	<exec executable="git" output=".git.properties" dir=".." failifexecutionfails="false" failonerror="false">
		<arg line="log --pretty=format:'git.version=%h' -1" />
	</exec>
  <tstamp prefix="now"><format timezone="utc" pattern="yyyyMMdd_hhmm" property="now"/></tstamp>

  <replace file=".git.properties" token="git.version=" value="git.version=${now.now}-"/>
	<loadproperties srcfile=".git.properties" />

	<fail unless="git.version" message="could not determine git version number" />

</project>

Back to the top