-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
243 lines (178 loc) · 8.88 KB
/
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
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
<project name="phnmnl-Enrichment" default="usage" basedir=".">
<exec executable="git" outputproperty="git.commit.hash" resultproperty="git.return.status" failifexecutionfails="false">
<arg line="log -1 --pretty=format:%H" />
</exec>
<condition property="git.clone">
<and>
<not>
<contains string="${git.commit.hash}" substring="fatal" />
</not>
<isset property="git.return.status" />
</and>
</condition>
<tstamp>
<format property="YEAR" pattern="yyyy" />
</tstamp>
<property file="${basedir}/build.properties" />
<!-- =================================================================== -->
<!-- Initialization target -->
<!-- =================================================================== -->
<target description="Initialization target" name="init" unless="target.init.done" depends="git.build.number">
<property name="target.init.done" value="true" />
<property name="Name" value="${phnmnl.Name}" />
<property name="name" value="${phnmnl.name}" />
<property name="version" value="${phnmnl.version}" />
<property name="api.version" value="${phnmnl.api.version}" />
<property name="year" value="${YEAR}" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<echo message="----------- ${TODAY} ------------" />
<echo message="----------- ${DSTAMP} ${TSTAMP} ------------" />
<echo message="----------- git hash ${phnmnl.revision} ------------" />
<echo message="----------- git url ${phnmnl.url} ------------" />
<property environment="env" />
<property name="build.compiler" value="modern" />
<property name="build.sysclasspath" value="ignore" />
<property name="debug" value="on" />
<property name="optimize" value="on" />
<property name="deprecation" value="false" />
<property name="depend" value="true" />
<property name="verbose" value="false" />
<property name="build.time" value="${DSTAMP}-${TSTAMP}" />
<property name="build.name" value="${version} (build ${phnmnl.revision}-${build.time})" />
<property name="src.dir" value="${basedir}/src" />
<property name="test.src.dir" value="${basedir}/test" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.src" value="${basedir}/build/src" />
<property name="build.dest" value="${basedir}/build/classes" />
<property name="build.javadocs" value="${basedir}/build/apidocs" />
<property name="jars.dir" value="${basedir}/lib" />
<property name="dist.root" value="${basedir}/dist" />
<property name="dist.lib.dir" value="${dist.root}/lib" />
<property name="dist.dir" value="${dist.root}/${name}" />
<property name="resource.dir" value="${basedir}/resources" />
<property name="main-class" value="phnmnl.enrichment.EnrichMetaboliteIds" />
<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
<path id="classpath">
<fileset dir="${jars.dir}" includes="*.jar *.zip" />
<fileset dir="${build.dir}" includes="*.jar *.zip" />
</path>
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" description="Help on usage" depends="init">
<echo message=" ${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message=" available targets are:" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" src-jar --> generates the ${name}.jar file along with the source code" />
<!-- <echo message=" test runs the tests" />
<echo message=" javadoc generates the API documentation" />-->
<echo message=" See the comments inside the build.xml file for more details." />
<echo message=" -------------------------------------------------------------" />
</target>
<!-- =================================================================== -->
<!-- Creating the phnmnl revision and url -->
<!-- =================================================================== -->
<target name="git.build.number" description="Finds out the git build number" if="git.clone">
<exec executable="git" outputproperty="git.origin.url" failifexecutionfails="false">
<arg line="config --get remote.origin.url" />
</exec>
<property name="phnmnl.revision" value="${git.commit.hash}" />
<property name="phnmnl.url" value="${git.origin.url}" />
</target>
<!-- =================================================================== -->
<!-- Prepares the build directory -->
<!-- =================================================================== -->
<target name="prepare" description="Prepares the build directory" depends="init" unless="prepare.src.target.done">
<mkdir dir="${build.dir}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${build.src}" />
<echo message="Directories created" />
</target>
<!-- =================================================================== -->
<!-- Prepares the source code -->
<!-- =================================================================== -->
<target name="prepare-src" description="Prepares the source code" depends="prepare" unless="prepare.src.target.done">
<property name="prepare.src.target.done" value="true" />
<copy todir="${build.src}">
<fileset dir="${basedir}/src" includes="**/*" />
</copy>
</target>
<!-- =================================================================== -->
<!-- Compiles the src directory -->
<!-- =================================================================== -->
<target name="compile" description="Compiles the source" depends="prepare">
<javac srcdir="${src.dir}"
destdir="${build.dest}"
debug="${debug}"
optimize="${optimize}"
verbose="${verbose}"
source="${phnmnl.build.javac.source}"
target="${phnmnl.build.javac.target}"
classpathref="classpath">
</javac>
</target>
<!-- =================================================================== -->
<!-- Creates the class package and include all the dependencies jars -->
<!-- =================================================================== -->
<target name="copy-dependencies">
<mkdir dir="${dist.lib.dir}" />
<jar jarfile="${dist.lib.dir}/dependencies-all.jar">
<zipgroupfileset dir="${jars.dir}">
<include name="**/*.jar" />
</zipgroupfileset>
</jar>
</target>
<!-- =================================================================== -->
<!-- Creates the class package and include all the dependencies jars -->
<!-- =================================================================== -->
<target name="jar" description="Creates the class package and includes all the dependencies jars into a big jsbml jar file" depends="compile, copy-dependencies">
<jar jarfile="${dist.dir}/${name}.jar" basedir="${build.dest}" includes="**/*.class" index="true">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
<zipfileset src="${dist.lib.dir}/dependencies-all.jar" excludes="META-INF/*.SF" />
</jar>
<ant dir="${basedir}" >
<target name="clean-up" />
</ant>
</target>
<!-- =================================================================== -->
<!-- Creates the class package and include all the dependencies jars -->
<!-- =================================================================== -->
<target name="src-jar"
description="Creates the class package and includes all the dependencies jars into a big jsbml jar file"
depends="compile, copy-dependencies, prepare-src">
<jar jarfile="${dist.dir}/${name}-with-src.jar"
filesetmanifest="mergewithoutmain"
duplicate="preserve" basedir="${build.dest}"
index="true">
<!-- we use the ${build.src} to include the sources in the resulting jar -->
<fileset dir="${build.src}" />
<!-- all the dependencies jars -->
<zipfileset src="${dist.lib.dir}/dependencies-all.jar" excludes="META-INF/*.SF" />
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
</jar>
<ant dir="${basedir}">
<target name="clean-up" />
</ant>
</target>
<!-- =================================================================== -->
<!-- Cleans the directory after the jar creation -->
<!-- =================================================================== -->
<target name="clean-up" description="Cleans the build directory" >
<delete includeEmptyDirs="true" >
<fileset dir="${build.dest}" includes="**/*" />
<fileset dir="${build.src}" includes="**/*" />
</delete>
<delete dir="${dist.lib.dir}" includeEmptyDirs="true" >
</delete>
</target>
</project>