forked from mohrwurm/appserver-io-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
executable file
·186 lines (168 loc) · 9.88 KB
/
build.xml
File metadata and controls
executable file
·186 lines (168 loc) · 9.88 KB
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
<?xml version="1.0"?>
<project name="appserver-io-apps/appserver-io-cli" default="composer-init" basedir=".">
<!-- initialize ENV variable -->
<property environment="env" />
<!-- ==================================================================== -->
<!-- Generate a time stamp for further use in build targets -->
<!-- ==================================================================== -->
<tstamp>
<format property="time.stamp" pattern="yyyy-MM-dd_HHmmss"/>
</tstamp>
<!-- initialize file based properties -->
<property file="${basedir}/build.properties"/>
<property file="${basedir}/build.default.properties"/>
<property file="${basedir}/build.${os.family}.properties"/>
<!-- initialize the library specific properties -->
<property name="codepool" value="vendor"/>
<!-- initialize the directory where we can find the real build files -->
<property name="vendor.dir" value ="${basedir}/${codepool}" />
<property name="build.dir" value="${vendor.dir}/appserver-io/build" />
<property name="php-target.dir" value="${basedir}/target"/>
<property name="appserver.webapps.dir" value="/opt/appserver/webapps"/>
<!-- ==================================================================== -->
<!-- Import the common build configuration file -->
<!-- ==================================================================== -->
<import file="${build.dir}/common.xml" optional="true"/>
<!-- ==================================================================== -->
<!-- Checks if composer has installed it's dependencies -->
<!-- ==================================================================== -->
<target name="is-composer-installed">
<condition property="composer.present">
<available file="${build.dir}" type="dir"/>
</condition>
</target>
<!-- ==================================================================== -->
<!-- Installs all dependencies defined in composer.json -->
<!-- ==================================================================== -->
<target name="composer-install" depends="is-composer-installed" unless="composer.present" description="Installs all dependencies defined in composer.json">
<exec dir="${basedir}" executable="composer">
<arg line="--no-interaction --dev install"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Updates composer dependencies defined in composer.json -->
<!-- ==================================================================== -->
<target name="composer-update" depends="is-composer-installed" if="composer.present" description="Updates composer dependencies defined in composer.json">
<exec dir="${basedir}" executable="composer">
<arg line="--no-interaction --dev update"/>
</exec>
</target>
<!-- ===================================================================== -->
<!-- Checks if the build- and deployment stub has already been initialized -->
<!-- ===================================================================== -->
<target name="composer-init">
<antcall target="composer-install"/>
<antcall target="composer-update"/>
</target>
<!-- ==================================================================== -->
<!-- Deletes the directory with the generated artefacts -->
<!-- ==================================================================== -->
<target name="clean" description="Deletes the directory with the generated artefacts.">
<delete dir="${php-target.dir}" includeemptydirs="true" quiet="false" verbose="true" failonerror="true"/>
</target>
<!-- ==================================================================== -->
<!-- Prepares the directory to temporarily store generated artefacts -->
<!-- ==================================================================== -->
<target name="prepare" description="Prepares the directory to temporarily store generated artefacts.">
<!-- clean the build environment -->
<antcall target="clean" />
<!-- create the default build environment folders -->
<mkdir dir="${php-target.dir}" />
<mkdir dir="${php-target.dir}/reports" />
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the target directory -->
<!-- ==================================================================== -->
<target name="copy" description="Copies the sources to the target directory.">
<!-- prepare the directory structure -->
<antcall target="prepare"/>
<!-- copy sources and resources to the target directory -->
<copy todir="${php-target.dir}/${appserver.webapp.name}" preservelastmodified="true" overwrite="true">
<fileset dir="${php-src.dir}">
<include name="**/*" />
<exclude name="vendor/**" />
</fileset>
</copy>
<!-- install the composer library -->
<exec dir="${basedir}" executable="composer">
<env key="COMPOSER_VENDOR_DIR" value="${php-target.dir}/${appserver.webapp.name}/vendor" />
<arg line="--no-dev --optimize-autoloader install" />
</exec>
<!-- remove all .git directories -->
<delete includeemptydirs="true">
<fileset dir="${php-target.dir}/${appserver.webapp.name}" includes="**/.git/" defaultexcludes="false"/>
</delete>
</target>
<!-- ==================================================================== -->
<!-- Creates a basic appserver project -->
<!-- ==================================================================== -->
<target name="create-project" description="Create a basic appserver.io project">
<input addProperty="appName" defaultvalue="example" message="What's the application name?" />
<input addProperty="namespace" defaultvalue="Example" message="And the application namespace?" />
<exec dir="${basedir}" executable="php">
<arg line="bin/appserver appconfig ${appName} ${namespace} ${php-target.dir}/${appName}"/>
</exec>
<exec dir="${basedir}" executable="php">
<arg line="bin/appserver action index ${namespace} /index ${php-target.dir}/${appName}"/>
</exec>
<exec dir="${basedir}" executable="php">
<arg line="bin/appserver processor ${namespace} ${php-target.dir}/${appName}"/>
</exec>
<exec dir="${php-target.dir}/${appName}" executable="composer">
<arg line="install"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the specified directory -->
<!-- ==================================================================== -->
<target name="copy-project" description="Copies project to specified directory">
<input addProperty="appName" defaultvalue="example" message="What's the project name?" />
<input addProperty="copyDir" defaultvalue="/opt/appserver/webapps/example" message="Where do you want to copy the project?" />
<copy todir="${copyDir}">
<fileset dir="${php-target.dir}/${appName}" defaultexcludes="false" />
</copy>
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the deploy directory -->
<!-- ==================================================================== -->
<target name="local-deploy" description="Copies the sources to the deploy directory.">
<!-- copy the sources to the deploy directory -->
<echo message="Copy sources to ${deploy.dir} ..."/>
<copy todir="${appserver.webapps.dir}" preservelastmodified="true" overwrite="true">
<fileset dir="${php-target.dir}">
<include name="**/*"/>
</fileset>
</copy>
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the deploy directory -->
<!-- ==================================================================== -->
<target name="docker-deploy" description="Copies the sources to the deploy directory.">
<input addProperty="appName" defaultvalue="example" message="What's the application name?" />
<!-- copy the sources to the deploy directory -->
<exec dir="${basedir}" executable="docker-compose">
<arg line="up -d"/>
</exec>
<exec dir="${basedir}" executable="docker">
<arg line="exec appserveriocli_appserver_1 mkdir -p /opt/appserver/webapps/${appName}" />
</exec>
<exec dir="${basedir}" executable="docker">
<arg line="cp target/${appName} appserveriocli_appserver_1:/opt/appserver/webapps/" />
</exec>
<exec dir="${basedir}" executable="docker">
<arg line="restart appserveriocli_appserver_1" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Copies the sources to the deploy directory -->
<!-- ==================================================================== -->
<target name="docker-delete-container" description="Copies the sources to the deploy directory.">
<!-- copy the sources to the deploy directory -->
<exec dir="${basedir}" executable="docker">
<arg line="stop appserveriocli_appserver_1"/>
</exec>
<exec dir="${basedir}" executable="docker">
<arg line="rm appserveriocli_appserver_1"/>
</exec>
</target>
</project>