-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
113 lines (103 loc) · 3.93 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="WP-SDL" default="dist">
<!-- Properties -->
<property name="phpunitpath" value="/usr/bin/phpunit" />
<property name="wpclipath" value="/usr/local/bin/wp" />
<property name="source.dir" location="${basedir}/src" />
<property name="build.dir" location="${basedir}/build" />
<property name="build.dist" location="${build.dir}/dist" />
<property name="build.env" location="${build.dir}/env" />
<!-- Target: prepare -->
<target name="prepare">
<echo message="Preparing build dir..." />
<mkdir dir="${build.dir}" />
</target>
<!-- Target: test-prepare-init -->
<target name="test-prepare-init" depends="prepare">
<!-- default WordPress properties -->
<property name="wp.version" value="4.0" />
<property name="wp.dbname" value="wp_sdl_unit_tests" />
<property name="wp.dbuser" value="wordpress" />
<property name="wp.dbpass" value="wordpress" />
<property name="wp.dbhost" value="127.0.0.1" />
<property name="wp.url" value="http://localhost/" />
<property name="wp.title" value="WP-SDL Unit Testing" />
<property name="wp.admin_user" value="admin" />
<property name="wp.admin_password" value="admin" />
<property name="wp.admin_email" value="[email protected]" />
<!-- check if WordPress testing env exists -->
<echo message="Checking if WordPress environment is installed..." />
<available file="${build.env}" type="dir" property="wp_is_installed" value="true" />
</target>
<!-- Target: test-prepare-install -->
<target name="test-prepare-install" unless="wp_is_installed">
<echo message="Downloading WordPress test env to: ${build.env}" />
<exec executable="${wpclipath}" failonerror="true">
<arg value="core" />
<arg value="download" />
<arg value="--path=${build.env}" />
<arg value="--version=${wp.version}" />
</exec>
<echo message="Creating WordPress database..." />
<exec executable="${wpclipath}">
<arg value="db" />
<arg value="create" />
<arg value="--path=${build.env}" />
</exec>
<echo message="Creating WordPress config..." />
<exec executable="${wpclipath}" failonerror="true">
<arg value="core" />
<arg value="config" />
<arg value="--path=${build.env}" />
<arg value="--dbname=${wp.dbname}" />
<arg value="--dbuser=${wp.dbuser}" />
<arg value="--dbpass=${wp.dbpass}" />
<arg value="--dbhost=${wp.dbhost}" />
</exec>
</target>
<!-- Target: test-prepare -->
<target name="test-prepare" depends="test-prepare-init, test-prepare-install">
<echo message="Resetting WordPress tables..." />
<exec executable="${wpclipath}" failonerror="true">
<arg value="db" />
<arg value="reset" />
<arg value="--path=${build.env}" />
<arg value="--yes" />
</exec>
<echo message="Installing WordPress tables..." />
<exec executable="${wpclipath}" failonerror="true">
<arg value="core" />
<arg value="install" />
<arg value="--path=${build.env}" />
<arg value="--url=${wp.url}" />
<arg value="--title=${wp.title}" />
<arg value="--admin_user=${wp.admin_user}" />
<arg value="--admin_password=${wp.admin_password}" />
<arg value="--admin_email=${wp.admin_email}" />
</exec>
</target>
<!-- Target: test -->
<target name="test" depends="test-prepare">
<exec executable="${phpunitpath}" failonerror="true">
<arg line="--configuration ${basedir}/phpunit.xml" />
</exec>
</target>
<!-- Target: dist-clean -->
<target name="dist-clean">
<echo message="Removing old dist artifacts..." />
<delete dir="${build.dist}" quiet="true" />
</target>
<!-- Target: dist-prepare -->
<target name="dist-prepare" depends="prepare">
<echo message="Preparing dist dir..." />
<mkdir dir="${build.dist}" />
</target>
<!-- Target: dist (default) -->
<target name="dist" depends="dist-prepare">
<echo message="Creating zip archive..." />
<zip destfile="${build.dist}/wp-sdl.zip">
<zipfileset dir="${source.dir}" prefix="wp-sdl" />
</zip>
<echo message="Files copied and compressed!" />
</target>
</project>