forked from molgenis/molgenis_apps-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_compute.xml
170 lines (140 loc) · 6.66 KB
/
build_compute.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
<project name="compute">
<!-- This name is used to name the war file -->
<property name="app_name" value="compute" />
<!-- This holds all the settings for the generator -->
<property name="app_properties" value="apps/${app_name}/org/molgenis/${app_name}/${app_name}.properties" />
<!-- This determines what handwritten modules should be loaded -->
<path id="app.class.path">
<pathelement location="apps/${app_name}" />
<pathelement location="modules/_deprecated" />
<pathelement location="modules/compute4" />
<pathelement location="test/modules/compute4" />
<pathelement location="modules/settings" />
<pathelement location="modules/file" />
<pathelement location="modules/datamodel" />
<pathelement location="modules/decorators/core" />
<pathelement location="modules/webserver" />
</path>
<!-- Import all tasks from build_common: clean, generate, compile, test, war, standalone-jar -->
<import file="build_common.xml" />
<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 outputDir="${testng.report.dir}" haltOnFailure="true">
<xmlfileset dir="${build.molgenis_apps.dir}" includes="org/molgenis/compute/commandline/testng-compute.xml" />
<classpath location="${cb.instrument.dir}" />
<classpath refid="combined.class.path"/>
<classfileset dir="${build.molgenis.dir}" includes="**/*Test*.class" />
<sysproperty key="net.sourceforge.cobertura.datafile" value="${cb.file}" />
<jvmarg value="-noverify" />
<jvmarg value="-ea" />
<jvmarg value="-Xmx2048m" />
</testng>
</target>
<target name="gitversion">
<!-- Get GIT revision info from the commandline GIT client-->
<exec executable="git" dir="${basedir}" outputproperty="git.apps.version">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" dir="${molgenis.dir}" outputproperty="git.molgenis.version">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<echo>Creating MOLGENIS/compute distro based on Git Revision: ${git.molgenis.version} (molgenis) and ${git.apps.version} (apps)</echo>
</target>
<!-- Make a distribution:
* Generate and compile this molgenis app
* Bundle it with all associated dependencies and resources like manuals, example files, etc.
* Create a *.zip archive -->
<target name="makedistro" depends="gitversion">
<!-- Create folder structure for distro -->
<property name="root_distro_dir" value="${basedir}/dist/"/>
<property name="app_distro_dir" value="${root_distro_dir}/molgenis_${app_name}/"/>
<mkdir dir="${app_distro_dir}"/>
<!-- Delete the old distro -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${app_distro_dir}" />
</delete>
<!-- Create folder substructure for distro -->
<property name="app-r_distro_dir" value="${app_distro_dir}/molgenis_${app_name}-${git.apps.version}/"/>
<property name="lib_dir" value="${app-r_distro_dir}/lib/"/>
<property name="templates_dir" value="${app-r_distro_dir}/templates/"/>
<property name="protocols_dir" value="${app-r_distro_dir}/protocols/"/>
<property name="workflows_dir" value="${app-r_distro_dir}/workflows/"/>
<property name="app_module_dir" value="${basedir}/modules/compute/" />
<!-- Copy documentation to the distro dir -->
<mkdir dir="${app-r_distro_dir}/docs/"/>
<copy todir="${app-r_distro_dir}/docs/">
<fileset dir="${basedir}/doc/${app_name}/">
<include name="*"/>
</fileset>
</copy>
<!-- Copy example script to analyze a test data set -->
<copy todir="${app_distro_dir}">
<fileset dir="${basedir}/apps/${app_name}/org/molgenis/${app_name}/">
<include name="test_molgenis_compute.sh"/>
</fileset>
</copy>
<!-- Copy all generic templates, protocols and workflows to the distro dir -->
<copy todir="${templates_dir}">
<fileset dir="${app_module_dir}/templates/"/> <!-- org/molgenis/${app_name}/ -->
</copy>
<copy todir="${protocols_dir}">
<fileset dir="${app_module_dir}/protocols/"/>
</copy>
<copy todir="${workflows_dir}">
<fileset dir="${app_module_dir}/workflows/"/>
</copy>
<!-- Copy all dependencies to the distro lib dir -->
<!-- This is a manually maintained list of libs for now, but we should collect this from include statements -->
<copy todir="${lib_dir}">
<fileset dir="${molgenis.dir}/lib/">
<include name="commons-io-2.4.jar"/>
<include name="freemarker.jar"/>
<include name="log4j-1.2.15.jar"/>
</fileset>
</copy>
<!-- Create molgenis.jar -->
<jar jarfile="${lib_dir}/molgenis-${git.molgenis.version}.jar" basedir="${build.molgenis.dir}" update="false"/>
<!-- Create molgenis_app.jar in folder dist/${app} -->
<jar jarfile="${lib_dir}/molgenis-${app_name}-${git.apps.version}.jar" basedir="${build.molgenis_apps.dir}" update="false"/>
<!-- Make shell script to start molgenis app from the commandline -->
<echo file="${app-r_distro_dir}/molgenis_${app_name}.sh">#!/bin/bash
#
# This script runs the MOLGENIS/compute commandline with only the jars needed added to the CLASSPATH.
# To get relative path to this script use $(dirname -- "$0").
#
# If -mcdir is not specified as argument then use the current path:
MCDIR=$( cd -P "$( dirname "$0" )" && pwd )
# If user has specified -mcdir, then use that one.
customMcdir=$(echo $* | grep -E "\-mcdir")
if [[ ! $customMcdir ]]; then mcDirArg="-mcdir=${MCDIR}"; else mcDirArg=""; fi;
java -cp \
$(dirname -- "$0")/lib/molgenis-${git.molgenis.version}.jar:\
$(dirname -- "$0")/lib/molgenis-compute-${git.apps.version}.jar:\
$(dirname -- "$0")/lib/commons-io-2.4.jar:\
$(dirname -- "$0")/lib/freemarker.jar:\
$(dirname -- "$0")/lib/log4j-1.2.15.jar \
org.molgenis.compute.commandline.ComputeCommandLine \
$* \
$mcDirArg
</echo>
<chmod file="${app-r_distro_dir}/molgenis_${app_name}.sh" perm="755"/>
<!-- Make package with 'lib','workflows','protocols' and shell script -->
<zip destfile="${root_distro_dir}/molgenis_${app_name}-${git.apps.version}.zip" basedir="${app_distro_dir}" update="false" />
<!-- Cleanup -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${app_distro_dir}" />
</delete>
</target>
<target name="clean-generate-compile-test-makedistro" depends="clean,generate,compile,test,makedistro"/>
<target name="clean-generate-compile-makedistro" depends="clean,generate,compile,makedistro"/>
</project>