forked from molgenis/molgenis_apps-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_common.xml
341 lines (286 loc) · 13.8 KB
/
build_common.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!-- this is a 'superclass' ant script with all stuff in common.
It should be used via 'import' plus passing of properties
'app_properties' (reference properties file) and
'app_src' (listing of the src folders to be included) -->
<project>
<!-- requires app_name, app_properties properties and app_src path -->
<fail unless="app_properties">app_properties is not set. Did you use the right build_xyz.xml?</fail>
<available file="${app_properties}" property="isFileAvail" />
<fail unless="isFileAvail" message="app_properties file not found: ${app_properties}" />
<fail unless="app_name">app_name is not set. Did you use the right build_xyz.xml?</fail>
<echo>Running Ant for MOLGENIS App "${app_name}" using basedir ${basedir}</echo>
<!-- static properties shared between all apps-->
<property file="${app_properties}" />
<property name="molgenis.dir" value="../molgenis" />
<property name="build.molgenis.dir" value="../molgenis/bin" />
<property name="build.molgenis_apps.dir" value="build/classes" />
<property name="testng.report.dir" value="dist/test-output" />
<property name="war.dir" value="dist/war" />
<property name="war.name" value="${app_name}.war" />
<property name="webxml.dir" value="WebContent/WEB-INF/web.xml" />
<!-- path to MOLGENIS toolkit -->
<path id="molgenis.classpath">
<pathelement location="${build.molgenis.dir}" />
<pathelement location="${build.molgenis_apps.dir}" />
<fileset dir="../molgenis/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="WebContent/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>
</path>
<!-- path to app src -->
<taskdef resource="testngtasks" classpathref="molgenis.classpath" />
<taskdef name="xmltask" classpathref="molgenis.classpath" classname="com.oopsconsultancy.xmltask.ant.XmlTask" />
<!-- clean out generated and build folders -->
<target name="clean">
<!-- remove and create generated folder -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${build.molgenis.dir}" />
<fileset dir="${build.molgenis_apps.dir}" />
<fileset dir="${testng.report.dir}" />
<fileset dir="${war.dir}" />
</delete>
<mkdir dir="${build.molgenis.dir}"/>
<mkdir dir="${build.molgenis_apps.dir}" />
<mkdir dir="${output_src}" />
<mkdir dir="${output_sql}" />
<mkdir dir="${testng.report.dir}" />
<mkdir dir="${war.dir}" />
</target>
<!-- generate based on properties file for this app_properties-->
<target name="generate" depends="update-eclipse">
<!-- clean generated folders -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${output_src}" excludes=".gitignore"/>
<fileset dir="${output_sql}" excludes=".gitignore"/>
<fileset dir="${output_ccp}" excludes=".gitignore"/>
</delete>
<mkdir dir="${output_src}" />
<mkdir dir="${output_sql}" />
<!-- check if the molgenis project is where it is to be expected, in ../molgenis/ -->
<condition property="dir.exists">
<available file="${molgenis.dir}" type="dir" />
</condition>
<!-- check if molgenis is compiled into ${build.dir}, otherwise compile now -->
<javac srcdir="${molgenis.dir}/src" destdir="${build.molgenis.dir}" nowarn="on" debug="true">
<classpath refid="molgenis.classpath" />
</javac>
<!-- copy resources to build dir -->
<copy todir="${build.molgenis.dir}">
<fileset dir="${molgenis.dir}/src" includes="**/*.xml,**/*.properties,**/*.txt,**/*.ico,**/*.js,**/*.css,**/*.jpg,**/*.png,**/*.gif,**/*.ftl" />
</copy>
<!-- call the generator -->
<java classname="org.molgenis.Molgenis" fork="yes" failonerror="true">
<classpath refid="molgenis.classpath" />
<classpath refid="app.class.path" />
<arg value="${app_properties}" />
</java>
<!-- copy all ftl files from module folders-->
<!-- concat all elements of app_path together separated by /**/*, -->
<pathconvert property="app_path" refid="app.class.path" pathsep="/**/*," dirsep="/">
<map from="${basedir}/" to="" />
</pathconvert>
<echo message="copying ftl files from ${app_path} to ${build.dir}" />
<fail unless="app_path">app.class.path is not set</fail>
<copy todir="${build.molgenis_apps.dir}">
<!-- watch the trailing /**/*.ftl"-->
<fileset dir="." includes="${app_path}/**/*" excludes="**/*.java" />
<!-- cut the two leading directories from path -->
<mapper type="regexp" from="^[-_a-zA-Z0-9]*[/\\][-_a-zA-Z0-9]*[/\\](.*)" to="\1" />
<!--cutdirsmapper dirs="2"/-->
</copy>
<!-- copy sql and other resources from generate sql -->
<copy todir="${build.molgenis_apps.dir}" verbose="true">
<fileset dir="${output_sql}" includes="**/*.sql" erroronmissingdir="false"/>
<fileset dir="${output_src}" includes="**/*.xml,**/*.properties,**/*.txt,**/*.ico" />
</copy>
<!-- Copy persistence.xml to rigth location if it's specified in *.properties as persistence_xml_location-->
<antcall target="copy-persistence.xml" />
</target>
<target name="check_persistence_xml_locaton">
<echo>${persistence_xml_location}</echo>
<condition property="condition">
<isset property="persistence_xml_location" />
</condition>
</target>
<target name="updatedb">
<java classname="org.molgenis.Molgenis" fork="yes" failonerror="true">
<classpath refid="molgenis.classpath" />
<classpath refid="app.class.path" />
<arg value="${app_properties}" />
<arg value="--updatedb" />
</java>
</target>
<target name="updatedbfillmeta">
<java classname="org.molgenis.Molgenis" fork="yes" failonerror="true">
<classpath refid="molgenis.classpath" />
<classpath refid="app.class.path" />
<arg value="${app_properties}" />
<arg value="--updatedbfillmeta" />
</java>
</target>
<target name="copy-persistence.xml" depends="check_persistence_xml_locaton" if="condition">
<copy file="${persistence_xml_location}" todir="${build.molgenis_apps.dir}/META-INF/" overwrite="true" />
<echo>persistence.xml copied from ${persistence_xml_location} to ${build.molgenis_apps.dir}/META-INF/</echo>
</target>
<target name="compile">
<pathconvert property="app_src" refid="app.class.path" pathsep=":">
<map from="${basedir}/" to="" />
</pathconvert>
<fail unless="app_src">app.class.path is not set. Did you use the right build_xyz.xml?</fail>
<echo message="compile :${output_src}:${app_src}" />
<!-- compile the generated results, use fork to run it with its own memory settings -->
<!-- NB: under Windows, forking works only if the javac path is in your PATH variable -->
<javac fork="true" srcdir="${output_src}:${app_src}" destdir="${build.molgenis_apps.dir}" nowarn="on" memoryinitialsize="256m" memorymaximumsize="512m" debug="true">
<classpath refid="molgenis.classpath" />
</javac>
</target>
<target name="test">
<!-- combine classpaths -->
<path id="combined.class.path">
<path refid="molgenis.classpath" />
<path refid="app.class.path" />
<path location="${output_src}" />
</path>
<!-- run the tests -->
<testng classpathref="combined.class.path" outputDir="${testng.report.dir}" haltOnFailure="true">
<xmlfileset dir="${build.molgenis_apps.dir}" includes="**/*testng.xml" />
<jvmarg value="-ea" />
<jvmarg value="-Xmx1512m" />
</testng>
<!--junitreport todir="${testng.report.dir}">
<fileset dir="${testng.report.dir}">
<include name="**/*.xml" />
</fileset>
<report format="noframes" todir="${testng.report.dir}" />
</junitreport-->
</target>
<!--
<target name="javadoc">
<javadoc access="public" destdir="${dir.javadoc}" author="true" version="true" noindex="false" use="true" classpathref="classpath">
<fileset dir="handwritten/java" defaultexcludes="yes">
<include name="**/*.java" />
<exclude name="org/test/**/*.java" />
</fileset>
<fileset dir="generated/java" defaultexcludes="yes">
<include name="**/*.java" />
<exclude name="org/test/**/*.java" />
</fileset>
</javadoc>
</target>
<target name="makeWar" depends="compile">
the ant war task. with all resources in place, create the war file
<war destfile="${war.dir}/${war.name}" webxml="${webxml.dir}">
<classes dir="${build.dir}">
<include name="**/*" />
</classes>
<lib dir="../molgenis/lib">
<include name="**/*.jar" />
</lib>
<lib dir="WebContent/WEB-INF/lib">
<include name="**/*.jar" />
</lib>
<metainf dir="WebContent/META-INF">
</metainf>
</war>
</target>
-->
<target name="update-eclipse">
<echo>Restoring .classpath from template file ${basedir}/.classpath.template.xml</echo>
<copy file="${basedir}/.classpath.template.xml" tofile="${basedir}/.classpath" overwrite="true" />
<echo>Customizing .classpath for ${app_name} ...</echo>
<pathconvert property="app_xml" refid="app.class.path" pathsep=""/><classpathentry kind="src" path="">
<!--<map from="${user.dir}/" to="" />-->
<map from="${basedir}/" to="" />
</pathconvert>
<!-- add generated src as well -->
<property name="app_xml2" value="<classpathentry kind="src" path="${app_xml}"/>" />
<property name="app_xml3" value="${app_xml2}<classpathentry kind="src" path="${output_sql}"/><classpathentry kind="src" path="${output_src}"/>" />
<echo message="eclipse .classpath xml: ${app_xml3}" />
<xmltask source=".classpath" dest=".classpath" outputter="simple">
<remove path="classpath/classpathentry[@kind='src' and not(@exported)]" />
<insert path="classpath" position="under" xml="${app_xml3}" />
</xmltask>
<echo>Restoring .setting/sorg.eclipse.wst.common.component from template file ${basedir}/.settings/template.org.eclipse.wst.common.component</echo>
<copy file="${basedir}/.settings/template.org.eclipse.wst.common.component" tofile="${basedir}/.settings/org.eclipse.wst.common.component" overwrite="true" />
<copy file="${basedir}/.settings/template.jsdtscope" tofile="${basedir}/.settings/jsdtscope" overwrite="yes" />
<copy file="${basedir}/.settings/template.org.eclipse.jdt.core.prefs" tofile="${basedir}/.settings/org.eclipse.jdt.core.prefs" overwrite="yes" />
<copy file="${basedir}/.settings/template.org.eclipse.wst.common.project.facet.core.xml" tofile="${basedir}/.settings/org.eclipse.wst.common.project.facet.core.xml" overwrite="yes" />
<copy file="${basedir}/.project.template" tofile="${basedir}/.project" overwrite="yes" />
<!-- <wb-resource deploy-path="/WEB-INF/classes" source-path="/generated/src"/> -->
<pathconvert property="app_xml4" refid="app.class.path" pathsep=""/><wb-resource deploy-path="/WEB-INF/classes" source-path="">
<!--<map from="${user.dir}/" to="" />-->
<map from="${basedir}/" to="" />
</pathconvert>
<!-- add generated src as well -->
<property name="app_xml5" value="<wb-resource deploy-path="/WEB-INF/classes" source-path="${app_xml4}"/>" />
<property name="app_xml6" value="<wb-resource deploy-path="/WEB-INF/classes" source-path="${output_src}"/>${app_xml5}" />
<property name="app_xml7" value="<wb-resource deploy-path="/WEB-INF/classes" source-path="${output_sql}"/>${app_xml6}" />
<echo message="eclipse .classpath xml: ${app_xml5}" />
<xmltask source=".settings/template.org.eclipse.wst.common.component" dest=".settings/org.eclipse.wst.common.component" outputter="simple">
<insert path="project-modules/wb-module" position="under" xml="${app_xml7}" />
</xmltask>
</target>
<target name="generate-compile" depends="generate,compile" />
<target name="clean-generate-compile" depends="clean,generate,compile" />
<target name="clean-generate-compile-run" depends="clean,generate,compile,run" />
<target name="clean-generate-compile-test" depends="clean,generate,compile,test" />
<target name="testcopy">
<pathconvert property="app_path" refid="app.class.path" pathsep="/**/*," dirsep="/">
<map from="${basedir}/" to="" />
</pathconvert>
<copy todir="${build.molgenis_apps.dir}">
<!-- watch the trailing /**/*.ftl"-->
<fileset dir="." includes="${app_path}/**/*" excludes="**/*.java" />
<fileset dir="${app_path}/handwritten/java/META-INF" />
<!-- cut the two leading directories from path -->
<mapper type="regexp" from="^[-_a-zA-Z0-9]*/[-_a-zA-Z0-9]*/(.*)" to="\1" />
<!--cutdirsmapper dirs="2"/-->
</copy>
<!-- copy sql and other resources from generate sql -->
<copy todir="${build.dir}" verbose="true">
<fileset dir="${output_sql}" includes="**/*.sql" />
<fileset dir="${output_src}" includes="**/*.xml,**/*.properties,**/*.txt,**/*.ico" />
</copy>
</target>
<target name="run" description="Start the application">
<java maxmemory="512m" classname="boot.RunStandalone" fork="yes" failonerror="true">
<classpath>
<path refid="molgenis.classpath" />
<path location="${build.molgenis.dir}" />
<path location="${build.molgenis_apps.dir}" />
</classpath>
</java>
</target>
<target name="makeWar">
<war destfile="${war.dir}/${war.name}" webxml="${webxml.dir}">
<classes dir="${build.molgenis.dir}">
<include name="**/*" />
</classes>
<classes dir="${build.molgenis_apps.dir}">
<include name="**/*" />
</classes>
<fileset dir="WebContent">
<exclude name="WebContent/META-INF/*" />
<exclude name="WebContent/WEB-INF/*" />
<include name="**/*.*" />
</fileset>
<lib dir="../molgenis/lib">
<include name="**/*.jar" />
</lib>
<lib dir="WebContent/WEB-INF/lib">
<include name="**/*.jar" />
</lib>
<metainf dir="WebContent/META-INF">
</metainf>
</war>
</target>
<target name="webtest" description="Start the Selenium test">
<testng classpathref="${molgenis.classpath}" haltOnFailure="true">
<classfileset dir="${app_build_dir}" includes="**/${selenium_test_class}.class"/>
</testng>
</target>
<target name="clean-generate-compile-war" depends="clean,generate,compile,makeWar" />
<target name="clean-generate-compile-updatedbfillmeta-run" depends="clean,generate,compile,updatedbfillmeta,run" />
</project>