-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
executable file
·213 lines (177 loc) · 7.37 KB
/
build.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
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
<!--
Sample build script. This script will not necessarily deploy
any specific project successfully, but is intended to serve as
a representation of the baseline targets and tasks that will
be executed for most projects.
Although this script may not work as is, it should be able to
act as a baseline for most projects and should be fully functional
with a little modification.
@author Rob Wilkerson
@date 8/23/2007
NOTE:
THIS BUILD DEPENDS ON THE PARENT BUILD SAVING OFF A COPY OF THE
polyclip/webroot/assets DIRECTORY. IT WILL BE COPIED BACK AFTER
THE BUILD TO PRESERVE CLIENT ASSETS.
-->
<project name="build-polyclip" default="all" basedir=".">
<description>
Builds and deploys the CakePHP FormatMask Plugin.
</description>
<!-- get build properties from file -->
<property file="build.properties" />
<!-- make the antelope tasks available -->
<taskdef resource="ise/antelope/tasks/antlib.xml"
classpath="AntelopeTasks.jar"
/>
<target name="all" depends="init,export,backup,delete,deploy,finalize,clean" />
<!-- the default target calls other targets in the proper sequence -->
<target name="init">
<description>Initialize the build.</description>
<!--
Ensure that the revision being retrieved is an integer value (i.e. not "HEAD")
-->
<grep in="${build.commit}" regex="^[a-f0-9]{7,}$" property="valid.commit" />
<fail unless="valid.commit" message="Unable to validate '${build.commit}'. Please include at least 7 characters from the commit hash." />
<echo> </echo>
<echo>IMPORTANT BUILD DETAILS:</echo>
<echo> - You are executing a build of the project named "${project.name}"</echo>
<echo> - This project will be deployed to __${remote.hostname}:${remote.projectroot}__</echo>
<switch name="project.baseuri">
<case value="http://dev.loudouncountyfair.com">
<property name="env.display" value="development" />
<property name="env.full" value="dev" />
<property name="env.abbrev" value="dev" />
<break/>
</case>
<case value="http://stage.loudouncountyfair.com">
<property name="env.display" value="staging" />
<property name="env.full" value="stage" />
<property name="env.abbrev" value="stg" />
<break/>
</case>
<case value="http://loudouncountyfair.com">
<property name="env.display" value="production" />
<property name="env.full" value="prod" />
<property name="env.abbrev" value="prd" />
<break/>
</case>
<default>
<fail message="Unknown project base URI (${project.baseuri}). Could not determine environment" />
<break/>
</default>
</switch>
<echo> - This build will be deployed to the __${env.display}__ environment.</echo>
<!--
Set the build type for install or upgrade. This may be used by some
tasks (e.g. the task that executes SQL scripts). An "upgrade" build
assumes an upgrade from the PREVIOUS VERSION, not from a previous
build of the same version
-->
<if name="build.upgrade" value="false">
<property name="build.executionpath" value="install" />
<else>
<property name="build.executionpath" value="upgrade" />
</else>
</if>
<stringutil string="${build.executionpath}" property="display.executionpath">
<uppercase />
</stringutil>
<echo> - This is an __${display.executionpath}__ build.</echo>
<!--
Creates a file system-safe name from the project.name property in the build.properties
file by lowercasing the name and replacing any spaces with a single hyphen.
-->
<stringutil string="${project.name}" property="project.fsname">
<lowercase />
<replace regex="\s+"
replacement="-"
/>
</stringutil>
<echo> - The file system project name used for directories, tags, etc. will be "${project.fsname}".</echo>
<exec executable="bash" outputproperty="project.fstimestamp">
<arg value="-c" />
<arg value="echo `date '+%Y%m%d%H%M%S'`" />
</exec>
<echo> </echo>
<echo>Please verify the output above. The build will continue in 30 seconds.</echo>
<sleep seconds="30"/>
<echo>Continuing...</echo>
<echo> </echo>
<echo>Delete local build files if any remain from a previous build (${local.buildroot}/${project.fsname}).</echo>
<delete dir="${local.buildroot}/${project.fsname}"
failonerror="false"
/>
<echo> > Complete</echo>
</target>
<target name="export">
<description>Export the project code base from source control.</description>
<echo>Export project files from the source control repository from the ${build.commit} commit.</echo>
<echo>bash -c "git archive ${build.commit} --prefix=${project.fsname}/ | tar -x -C ${local.buildroot}"</echo>
<exec executable="bash">
<arg value="-c" />
<arg value="git archive ${build.commit} --prefix=${project.fsname}/ | tar -x -C ${local.buildroot}" />
</exec>
<echo> > Complete</echo>
<echo> </echo>
</target>
<target name="backup">
<description>Creates backup of the project as it exists on the remote server (${remote.hostname})</description>
<echo>This is a plugin. The parent project build will take care of backups.</echo>
<echo> > Complete</echo>
</target>
<target name="delete">
<description>
Delete the existing code base in preparation for the new version.
</description>
<echo>Delete the existing classes directory and htaccess file.</echo>
<echo> > This is a plugin. The parent project build will take care of this.</echo>
<echo> > Complete</echo>
</target>
<target name="deploy">
<description>Copies the code base from the build root to the remote machine.</description>
<echo>Ensure that the plugin directory (${remote.projectroot}) exists.</echo>
<echo>Executing "mkdir -p ${remote.projectroot}"</echo>
<sshexec host="${remote.hostname}"
trust="true"
username="${remote.user}"
password="${remote.password}"
command="mkdir -p ${remote.projectroot}"
/>
<echo> > Complete</echo>
<echo>Copy project files to ${remote.hostname}:${remote.projectroot}.</echo>
<scp todir="${remote.user}:${remote.password}@${remote.hostname}:${remote.projectroot}"
trust="true"
verbose="false"
>
<fileset dir="${local.buildroot}/${project.fsname}/"
excludes="build.*, .gitignore, README*"
/>
<!-- <fileset dir="${local.buildroot}/${project.fsname}" /> -->
</scp>
<echo> > Complete</echo>
<!-- There should be no database requirement for this plugin
<echo> </echo>
<echo>Install or update the project database on ${mysql.host}.</echo>
<echo>Executing "mysql -h${mysql.host} -u${mysql.user} -p${mysql.password} < ${remote.projectroot}/config/install/${build.executionpath}.sql"</echo>
<sshexec host="${remote.hostname}"
trust="true"
username="${remote.user}"
password="${remote.password}"
command="mysql -h${mysql.host} -u${mysql.user} -p${mysql.password} < ${remote.projectroot}/config/install/${build.executionpath}.sql"
/>
<echo> > Complete</echo>
-->
</target>
<target name="finalize">
<description>Performs the final build actions</description>
<echo>Eventually we may do some tagging in the _finalize_ target, but nothing is being done now.</echo>
</target>
<target name="clean">
<description>Cleans up build resources on the remote and local machines</description>
<echo>Delete local build files</echo>
<delete dir="${local.buildroot}/${project.fsname}"
failonerror="false"
/>
<echo> > Complete</echo>
</target>
</project>