-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication-build.xml
207 lines (180 loc) · 8.25 KB
/
application-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
<?xml version="1.0" encoding="UTF-8"?>
<!--
General ant build file for play applications.
-->
<project>
<property name="test.start.delay" value="5"/>
<property name="application.path" value="${basedir}"/>
<property name="play.id" value=""/>
<property name="precompiled" value="false"/>
<echo message="Using play at ${play.path}"/>
<!-- classpath including play classes and dependencies -->
<path id="play.classpath">
<fileset dir="${play.path}/framework/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${play.path}/framework">
<include name="*.jar"/>
</fileset>
</path>
<!-- classpath including application dependencies -->
<path id="application.classpath">
<fileset dir="${basedir}/lib" erroronmissingdir="false">
<include name="*.jar"/>
</fileset>
</path>
<!-- additional classpath for running play in test mode -->
<path id="test.classpath">
<path refid="play.classpath"/>
<fileset dir="${play.path}/modules/testrunner/lib">
<include name="*.jar"/>
</fileset>
</path>
<!-- classpath for firephoque test runner -->
<path id="testrunner.classpath">
<fileset dir="${play.path}/modules/testrunner/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${play.path}/modules/testrunner/firephoque">
<include name="*.jar"/>
</fileset>
</path>
<!-- macro for the play python script in case you need it
usage example:
<target name="help">
<play-python command="help"/>
</target>
-->
<macrodef name="play-python">
<attribute name="command"/>
<attribute name="options"/>
<sequential>
<exec executable="cmd.exe" osfamily="winnt">
<arg line="/c ${play.path}/play.bat @{command} @{options}"/>
</exec>
<exec executable="python" osfamily="unix">
<arg line="${play.path}/play @{command} @{options}"/>
</exec>
</sequential>
</macrodef>
<taskdef classname="play.ant.PlayConfigurationLoadTask" name="playconfload">
<classpath>
<pathelement location="${play.antify.path}/lib/antify.jar"/>
</classpath>
</taskdef>
<target name="clean" description="Cleans build and test directories">
<delete dir="${basedir}/tmp"/>
<delete dir="${basedir}/test-result"/>
</target>
<target name="run" description="Runs the application">
<playconfload applicationDir="${basedir}" playId="${play.id}"/>
<java classname="play.server.Server" fork="yes" failonerror="yes">
<classpath>
<path refid="play.classpath"/>
<path refid="modules.classpath"/>
<path refid="application.classpath"/>
</classpath>
<jvmarg line="-javaagent:${play.path}/framework/play.jar -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"/>
<sysproperty key="play.id" value="${play.id}"/>
<sysproperty key="play.debug" value="true"/>
<sysproperty key="precompiled" value="${precompiled}"/>
<sysproperty key="application.path" value="${basedir}"/>
</java>
</target>
<target name="test" description="Run the application in test mode">
<playconfload applicationDir="${basedir}" playId="test"/>
<java classname="play.server.Server" fork="yes" failonerror="yes">
<classpath>
<path refid="test.classpath"/>
<path refid="modules.classpath"/>
<path refid="application.classpath"/>
</classpath>
<jvmarg line="-javaagent:${play.path}/framework/play.jar -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"/>
<sysproperty key="play.id" value="test"/>
<sysproperty key="play.debug" value="true"/>
<sysproperty key="application.path" value="${basedir}"/>
</java>
</target>
<target name="precompile" description="Compile all java sources and templates">
<playconfload applicationDir="${basedir}" playId="${play.id}"/>
<java classname="play.server.Server" fork="yes" failonerror="yes">
<classpath>
<path refid="play.classpath"/>
<path refid="modules.classpath"/>
<path refid="application.classpath"/>
</classpath>
<jvmarg line="-javaagent:${play.path}/framework/play.jar"/>
<sysproperty key="application.path" value="${basedir}"/>
<sysproperty key="play.id" value=""/>
<sysproperty key="precompile" value="true"/>
</java>
</target>
<target name="auto-test" description="Automatically run all application tests">
<playconfload applicationDir="${basedir}" playId="test"/>
<property name="application.conf.http.port" value="9000"/>
<property name="application.url" value="http://localhost:${application.conf.http.port}"/>
<get verbose="false" ignoreerrors="true" src="${application.url}/@kill" dest="${basedir}/test-result/[email protected]"/>
<delete dir="${basedir}/tmp"/>
<delete dir="${basedir}/test-result"/>
<property name="server.log" value="${basedir}/logs/auto-test.out"/>
<mkdir dir="${basedir}/logs"/>
<echo message="Starting server and redirecting output to ${server.log}"/>
<parallel>
<java classname="play.server.Server" fork="yes" failonerror="true">
<classpath>
<path refid="test.classpath"/>
<path refid="modules.classpath"/>
<path refid="application.classpath"/>
</classpath>
<jvmarg line="-javaagent:${play.path}/framework/play.jar"/>
<sysproperty key="play.id" value="test"/>
<sysproperty key="application.path" value="${basedir}"/>
</java>
<sequential>
<echo message="Waiting for the server to start up at ${application.url}/@tests"/>
<sleep seconds="${test.start.delay}"/>
<get verbose="false" ignoreerrors="false" src="${application.url}/@tests"
dest="${basedir}/test-result/[email protected]"/>
<echo message="Testing server at: ${application.url}"/>
<java classname="play.modules.testrunner.FirePhoque" fork="yes" failonerror="yes">
<classpath refid="testrunner.classpath"/>
<sysproperty key="application.url" value="${application.url}"/>
</java>
<echo message="Shutting down server"/>
<get verbose="false" ignoreerrors="true" src="${application.url}/@kill"
dest="${basedir}/test-result/[email protected]"/>
</sequential>
</parallel>
<fail message="There were test failures.">
<condition>
<not>
<resourcecount count="1">
<fileset dir="${basedir}/test-result" includes="result.passed"/>
</resourcecount>
</not>
</condition>
</fail>
</target>
<target name="package" depends="clean,precompile" description="Packages your application into a zip file package">
<mkdir dir="dist"/>
<zip file="dist/${ant.project.name}.zip">
<fileset dir="${basedir}">
<include name="precompiled/**"/>
<include name="conf/**"/>
<include name="public/**"/>
<include name="lib/**"/>
<include name="app/**"/>
<include name="*.xml"/>
</fileset>
</zip>
</target>
<target name="start" description="Start the application in the background">
<play-python command="start" options="--%${play.id}"/>
</target>
<target name="restart" description="Restart the running application">
<play-python command="restart" options="--%${play.id}"/>
</target>
<target name="stop" description="Stop the running application">
<play-python command="stop" options="--%${play.id}"/>
</target>
</project>