This repository has been archived by the owner on Aug 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild_compute.xml
219 lines (185 loc) · 8.61 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
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
<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" />
<!-- Set relative path to molgenis-pipeline repo. -->
<!-- We need it to bundle some demo and production pipelines with a compute distro. -->
<property name="pipelines_repo_dir" value="${basedir}/../molgenis-pipelines/" />
<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>
<!-- Get version and timestamp info from the commandline. -->
<target name="currentversion">
<!-- Get commit hashes from the commandline GIT client. -->
<exec executable="git" outputproperty="git.version">
<arg value="--version"/>
</exec>
<echo>Using ${git.version}</echo>
<exec executable="git" dir="${basedir}" outputproperty="git.apps.hash-short">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" dir="${basedir}" outputproperty="git.apps.hash-long">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" dir="${molgenis.dir}" outputproperty="git.molgenis.hash-short">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" dir="${molgenis.dir}" outputproperty="git.molgenis.hash-long">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" dir="${pipelines_repo_dir}" outputproperty="git.pipelines.hash-short">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" dir="${pipelines_repo_dir}" outputproperty="git.pipelines.hash-long">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<!-- Get timestamp for current build -->
<exec executable="date" dir="${pipelines_repo_dir}" outputproperty="timestamp">
<arg value="+%Y-%m-%dT%H:%M:%S%z"/>
</exec>
<echo>Creating MOLGENIS/compute distro based on Git commits: ${git.apps.hash-short} (molgenis_apps-legacy) depending on ${git.molgenis.hash-short} (molgenis-legacy) and bundled with ${git.pipelines.hash-short} (molgenis-pipelines).</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="currentversion">
<!-- 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 label for this release which includes the short git hashes for all repos:
MA = molgenis_apps-legacy
M = molgenis-legacy
MP = molgenis-pipelines -->
<property name="app-r_label" value="molgenis_${app_name}-MA_${git.apps.hash-short}-M_${git.molgenis.hash-short}-MP_${git.pipelines.hash-short}"/>
<!-- Create folder substructure for distro -->
<property name="app-r_distro_dir" value="${app_distro_dir}/${app-r_label}/"/>
<property name="lib_dir" value="${app-r_distro_dir}/lib/"/>
<!-- Create RELEASE document with version numbers. -->
<echo file="${app-r_distro_dir}/RELEASE.txt">
==========================================================================
MOLGENIS/compute distro release details
==========================================================================
Git commit hash tags for the code in this release:
* molgenis_apps-legacy: ${git.apps.hash-long}
* molgenis-legacy: ${git.molgenis.hash-long}
* molgenis-pipelines: ${git.pipelines.hash-long}
Release compiled on: ${timestamp}
==========================================================================
</echo>
<!-- 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 demo pipelines from molgenis_apps-legacy repo. -->
<copy todir="${app-r_distro_dir}/pipelines/demo/">
<fileset dir="${basedir}/modules/${app_name}/demo/" />
</copy>
<!-- Copy example script to analyze a test data set from a demo workflow from the molgenis_apps-legacy repo. -->
<copy todir="${app-r_distro_dir}">
<fileset dir="${basedir}/apps/${app_name}/org/molgenis/${app_name}/">
<include name="test_molgenis_compute.sh"/>
</fileset>
</copy>
<!-- Copy all generic templates from the molgenis_apps-legacy repo. -->
<copy todir="${app-r_distro_dir}/templates/">
<fileset dir="${basedir}/modules/${app_name}/templates/"/>
</copy>
<!-- Copy all generic templates, protocols and workflows from the molgenis-pipelines repo. -->
<copy todir="${app-r_distro_dir}/pipelines/production/">
<fileset dir="${pipelines_repo_dir}/compute4/"/>
</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.hash-short}.jar" basedir="${build.molgenis.dir}" update="false"/>
<!-- Create molgenis_app.jar in folder dist/${app} -->
<jar jarfile="${lib_dir}/molgenis-${app_name}-${git.apps.hash-short}.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 (absolute) 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 \
${MCDIR}/lib/molgenis-${git.molgenis.hash-short}.jar:\
${MCDIR}/lib/molgenis-compute-${git.apps.hash-short}.jar:\
${MCDIR}/lib/commons-io-2.4.jar:\
${MCDIR}/lib/freemarker.jar:\
${MCDIR}/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}/${app-r_label}.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>