forked from appirio-tech/direct-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-configuration.xml
145 lines (133 loc) · 4.66 KB
/
build-configuration.xml
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
<project name="TopCoder Configuration Scripts" basedir="." default="update_properties">
<property file="topcoder_global.properties"/>
<!-- Import the dependencies of this build file -->
<import file="${basedir}/build-dependencies.xml"/>
<!-- subversion tasks -->
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.lib" />
<!-- ant contrib tasks (if, then)-->
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<!-- base svn path to checkout *.properties files -->
<property name="base_url" value="https://coder.topcoder.com/internal/app_configs/direct" />
<!-- directory to checkout *.properties files -->
<property name="prop_dir" value="properties" />
<!-- supported environments -->
<property name="env_vm" value="vm" />
<property name="env_ci" value="ci" />
<property name="env_prod" value="prod" />
<property name="env_staging" value="staging" />
<target name="update_properties">
<if>
<not>
<isset property="env"/>
</not>
<then>
<fail>You must specify target environemt by adding -Denv=some_env. Supported environments:${env_vm}, ${env_ci}, ${env_prod}, ${env_prod}</fail>
</then>
<else>
<if>
<not>
<or>
<equals arg1="${env}" arg2="${env_vm}" />
<equals arg1="${env}" arg2="${env_ci}" />
<equals arg1="${env}" arg2="${env_prod}" />
<equals arg1="${env}" arg2="${env_staging}" />
</or>
</not>
<then>
<fail>Unsupported environment</fail>
</then>
<else>
<checkout_properties url="${base_url}/${env}" />
<antcall target="move_properties" />
</else>
</if>
</else>
</if>
</target>
<!-- this macro synchronizes properties directory with svn repository and copies *.properties to proper locations. -->
<macrodef name="checkout_properties" >
<attribute name="url" />
<sequential>
<if>
<available file="${prop_dir}"/>
<then>
<svnex>
<info target="${prop_dir}" />
</svnex>
<if>
<not>
<equals arg1="${svn.info.url}" arg2="@{url}"/>
</not>
<then>
<echo message="-------------------- Switching to url: @{url}"/>
<svnex>
<switch path="${prop_dir}" url="@{url}" />
</svnex>
</then>
<else>
<echo message="-------------------- Updating: @{url}"/>
<svnex>
<update dir="${prop_dir}" />
</svnex>
</else>
</if>
</then>
<!-- if not checkout the project -->
<else>
<echo message="-------------------- Checking out: ${prop_dir}"/>
<svnex>
<checkout destPath="${prop_dir}" url="@{url}" />
</svnex>
</else>
</if>
</sequential>
</macrodef>
<target name="move_properties" >
<copy todir="${basedir}" overwrite="true" >
<fileset dir="${prop_dir}">
<include name="**/*.properties" />
<include name="**/*.xml" />
<include name="**/*.sh" />
</fileset>
</copy>
<if>
<isset property="env"/>
<then>
<if>
<equals arg1="${env}" arg2="${env_ci}"/>
<then>
<chmod file="${basedir}/start-firefox-cockpit.sh" perm="755"/>
</then>
</if>
</then>
</if>
</target>
<!-- This tasks execute svn operations against cached credentials,
or prompt for password if svn.username property is set. -->
<macrodef name="svnex">
<!-- the operations to be performed via subversion -->
<element name="operation" implicit="true"/>
<sequential>
<if>
<isset property="svn.username"/>
<then>
<if>
<not>
<isset property="svn.password"/>
</not>
<then>
<input addproperty="svn.password" message="Please enter svn password: "/>
</then>
</if>
</then>
<else>
<input addproperty="svn.username" message="Please enter svn username: "/>
<input addproperty="svn.password" message="Please enter svn password: "/>
</else>
</if>
<svn javahl="false" username="${svn.username}" password="${svn.password}">
<operation />
</svn>
</sequential>
</macrodef>
</project>