-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
261 lines (222 loc) · 10 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!--
~ Copyright (c) 2007-2012 The Broad Institute, Inc.
~ SOFTWARE COPYRIGHT NOTICE
~ This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved.
~
~ This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality.
~
~ This software is licensed under the terms of the GNU Lesser General Public License (LGPL),
~ Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php.
-->
<project name="IGV" default="all" basedir=".">
<import file="build_macros.xml"/>
<property name="jar.name" value="igv.jar"/>
<property name="main-class" value="org.broad.igv.ui.Main"/>
<!-- Source and lib directories -->
<property name="src.dir" value="${basedir}/src/"/>
<property name="lib.dir" value="${basedir}/lib/"/>
<property name="testsrc.dir" value="${basedir}/test/src"/>
<property name="testlib.dir" value="${basedir}/test/lib"/>
<!-- Temp directory. Sources are compiled here prior to archiving -->
<property name="tmp.dir" value="${basedir}/tmp/"/>
<property name="testtmp.dir" value="${basedir}/testtmp/"/>
<property name="resource.dir" value="${tmp.dir}resources/"/>
<!-- Distribution directory. Binary distribution is placed here -->
<property name="dist.dir" value="${basedir}/"/>
<property name="jar.path" value="${dist.dir}${jar.name}"/>
<property name="dist.lib.dir" value="${dist.dir}lib/"/>
<property name="scripts.dir" value="${basedir}/scripts"/>
<property name="docs.dir" value="${basedir}/docs"/>
<!-- Create class path for manifest -->
<path id="@jars">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- Clean all generated artifacts -->
<target name="clean">
<delete dir="${tmp.dir}"/>
<delete dir="${testtmp.dir}"/>
</target>
<!-- Would like to be able to set bcel to true or false
This is easy in ant 1.8, but not earlier versions-->
<condition property="act.include.libs">
<and>
<available classname="org.apache.tools.ant.util.depend.bcel.FullAnalyzer"/>
<istrue value="${include.libs}"/>
</and>
</condition>
<!-- Unzip jars to the tmp directory -->
<target name="prepare" if="act.include.libs">
<unzip dest="${tmp.dir}">
<patternset>
<include name="**/*"/>
<exclude name="META-INF/**"/>
</patternset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<exclude name="**/batik-codec.jar"/>
<exclude name="**/goby-io-igv.jar"/>
<exclude name="**/*AppleJavaExtensions.jar"/>
</fileset>
</unzip>
</target>
<target name="init" depends="clean">
<mkdir dir="${tmp.dir}"/>
<mkdir dir="${testtmp.dir}"/>
<mkdir dir="${dist.dir}"/>
<!-- Copy resource files to the tmp directory -->
<copy todir="${tmp.dir}" overwrite="true">
<fileset dir="${src.dir}">
<exclude name="**/*.form"/>
<exclude name="**/*.java"/>
<exclude name="**/*.svn"/>
<exclude name="**/manifest.mf"/>
</fileset>
</copy>
<antcall target="prepare"/>
<write_version targetFile="${resource.dir}about.properties"/>
<condition property="compile.tests">
<and>
<not>
<isset property="notests"/>
</not>
<available file="${testsrc.dir}" type="dir"/>
</and>
</condition>
</target>
<!-- We compile IGV and the tests separately, because we only want
to include the main classes in the JAR and so it's easier to run
tests later. -->
<target name="compile" depends="init" description="Compile main source files to temp directory">
<javac srcdir="${src.dir}" debug="on" destdir="${tmp.dir}">
<classpath refid="@jars"/>
</javac>
</target>
<target name="compileTests" if="compile.tests" description="Compile test files to testtmp directory">
<javac srcdir="${testsrc.dir}" debug="on" destdir="${testtmp.dir}" includeantruntime="true">
<classpath refid="test.classpath"/>
</javac>
</target>
<macrodef name="build">
<attribute name="includedFileset"/>
<sequential>
<jar destfile="${jar.path}" basedir="${tmp.dir}" compress="true" duplicate="preserve">
<fileset refid="@{includedFileset}"/>
<manifest>
<!-- Here just to be a good citizen. Apparently reading from the correct manifest
is tricky. We rely on a separate properties file-->
<attribute name="Class-Path" value="${class-path}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="${main-class}"/>
<section name="org/broad/igv">
<attribute name="Specification-Title" value="${ant.project.name}"/>
<attribute name="Specification-Version" value="${version}"/>
<attribute name="Specification-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${version} ${build-number}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
</section>
</manifest>
</jar>
<copy file="${lib.dir}batik-codec.jar" tofile="${dist.dir}batik-codec.jar" overwrite="true"/>
<copy file="${lib.dir}goby-io-igv.jar" tofile="${dist.dir}goby-io-igv.jar" overwrite="true"/>
</sequential>
</macrodef>
<target name="build-small" depends="compile" unless="act.include.libs" description="Build the IGV JAR, without including libraries">
<fileset dir="${tmp.dir}" id="files"/>
<pathconvert property="class-path" pathsep=" " dirsep="/" refid="@jars">
<map from="${lib.dir}" to="lib/"/>
</pathconvert>
<build includedFileset="files"/>
</target>
<target name="build-all" depends="compile" if="act.include.libs"
description="Build the IGV JAR, including libraries, using BCEL to take only required classes">
<classfileset dir="${tmp.dir}" id="files">
<root classname="${main-class}"/>
</classfileset>
<property name="class-path" value="batic-codec.jar goby-io-igv.jar"/>
<build includedFileset="files"/>
</target>
<target name="build" depends="build-small,build-all"/>
<target name="all" depends="build, clean"/>
<!-- Run all tests with ant -->
<path id="test.classpath">
<path refid="@jars"/>
<fileset dir="${testlib.dir}">
<include name="fest*.jar"/>
<include name="jcip*.jar"/>
</fileset>
<pathelement location="${testtmp.dir}"/>
<pathelement location="${tmp.dir}"/>
</path>
<property name="test.reports" value="${basedir}/reports"/>
<property name="LARGE_DATA_DIR" value="${basedir}/test/largedata/"/>
<fileset dir="${testtmp.dir}" id="allfileset">
<include name="**/*.class"/>
<exclude name="**/*$*.class"/>
</fileset>
<fileset dir="${testtmp.dir}" id="uifileset">
<include name="**/IGVTest.class"/>
<include name="**/TrackLoaderTest.class"/>
<exclude name="**/*$*.class"/>
</fileset>
<!-- This looks a bit complicated but there is logic to it. We define this target
to be run by any other test runners, after they define an appropriate fileset.
We define files of tests to be run above (allfileset and uifileset), one
can also define their own by setting the filesetpattern property.
e.g.
>ant tests
runs all tests
>ant -Dfilesetpattern *BED* tests
would run any test with BED in the file name.
>ant -Dfilesetpattern IGVToolsTest tests
would simply run IGVToolsTest.
-->
<target name="actruntests" depends="compile, compileTests">
<delete dir="${test.reports}"/>
<mkdir dir="${test.reports}"/>
<junit haltonfailure="no" showoutput="no" printsummary="on" failureproperty="tests.failed" maxmemory="1500m">
<jvmarg value="-javaagent:${testlib.dir}/RuntimeUtils.jar"/>
<sysproperty key="LARGE_DATA_DIR" value="${LARGE_DATA_DIR}"/>
<classpath refid="test.classpath"/>
<formatter type="xml" usefile="true"/>
<batchtest fork="yes" todir="${test.reports}" if="filesetpattern">
<fileset dir="${testtmp.dir}">
<include name="**/${filesetpattern}.class"/>
<exclude name="**/*$*.class"/>
</fileset>
</batchtest>
<batchtest fork="yes" todir="${test.reports}" unless="filesetpattern">
<fileset refid="${filesetid}"/>
</batchtest>
</junit>
</target>
<target name="makereports" depends="actruntests">
<junitreport todir="${test.reports}">
<fileset dir="${test.reports}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${test.reports}"/>
</junitreport>
<fail message="Test failure detected, check test results." if="tests.failed"/>
</target>
<target name="tests">
<antcall target="makereports">
<param name="filesetid" value="allfileset"/>
</antcall>
</target>
<target name="uitests">
<antcall target="makereports">
<param name="filesetid" value="uifileset"/>
</antcall>
</target>
<!-- Deploy the application -->
<target name="deploy">
<copy todir="${deploy.dir}" overwrite="true">
<fileset dir="${dist.dir}">
<include name="lib/**"/>
</fileset>
<fileset file="${dist.dir}${jar.name}"/>
</copy>
</target>
</project>