-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
215 lines (195 loc) · 9.38 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2012 Institute of Meteorology and Water Management, IMGW
This file is part of the jrat software.
jrat is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jrat is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
long with the jrat. If not, see http://www.gnu.org/licenses.
-->
<project name="jrat" default="dist" basedir=".">
<description>Builds, tests, and runs the project jrat.</description>
<property name="app.name" value="jrat" />
<property name="version.src" value="src/pl/imgw/jrat/AplicationConstans.java" />
<property name="main.class" value="pl.imgw.jrat.Main" />
<property name="root.dir" value="${basedir}"/>
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="lib.native.dir" value="lib/native"/>
<property name="log.dir" value="log"/>
<property name="etc.dir" value="etc"/>
<property name="tmp.dir" value="tmp"/>
<property name="data.dir" value="data"/>
<property name="dist.dir" value="dist"/>
<property name="share.dir" value="share"/>
<property name="bin.dir" value="bin"/>
<property name="build.dir" value="build"/>
<property name="build.test.dir" value="${build.dir}/test"/>
<property name="build.coverage.dir" value="${build.dir}/coverage"/>
<property name="build.instrument.dir" value="${build.dir}/instrument"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="compile.debug" value="true"/>
<property name="compile.includeAntRuntime" value="no"/>
<property name="compile.optimize" value="true"/>
<property name="javadocs.dir" value="docs"/>
<property name="javadocs.src.dir" value="${src.dir}/pl/imgw/jrat"/>
<property name="test.dir" value="test"/>
<property name="build.test.dir" value="${build.dir}/test"/>
<property name="install.prefix" value="."/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<target name="install" depends="dist">
<mkdir dir="${install.prefix}/${app.name}"/>
<mkdir dir="${install.prefix}/${app.name}/${lib.dir}"/>
<mkdir dir="${install.prefix}/${app.name}/${bin.dir}"/>
<mkdir dir="${install.prefix}/${app.name}/${share.dir}"/>
<mkdir dir="${install.prefix}/${app.name}/${log.dir}"/>
<mkdir dir="${install.prefix}/${app.name}/${etc.dir}"/>
<mkdir dir="${install.prefix}/${app.name}/${tmp.dir}"/>
<mkdir dir="${install.prefix}/${app.name}/${data.dir}"/>
<copy todir="${install.prefix}/${app.name}/${share.dir}" flatten="true">
<fileset dir="${dist.dir}">
<include name="**/*.jar" />
</fileset>
</copy>
<copy todir="${install.prefix}/${app.name}/${lib.native.dir}" >
<fileset dir="${lib.native.dir}" includes="**"/>
</copy>
<echo file="${install.prefix}/${app.name}/${bin.dir}/jrat">#!/bin/sh
java -Dnative.libpath=${install.prefix}/${app.name}/${lib.native.dir} -Xmx256m -XX:MaxPermSize=256m -Duser.timezone=UTC \
-jar ${install.prefix}/${app.name}/${share.dir}/${app.name}.jar $@</echo>
<echo file="${install.prefix}/${app.name}/${bin.dir}/jrat.bat">java -Dnative.libpath=${install.prefix}/${app.name}/${lib.native.dir} -Xmx256m -XX:MaxPermSize=256m -Duser.timezone=UTC -jar ${install.prefix}/${app.name}/${share.dir}/${app.name}.jar %*</echo>
<chmod file="${install.prefix}/${app.name}/${bin.dir}/jrat" perm="755" />
<echo file="${install.prefix}/${app.name}/${share.dir}/before">#!/bin/sh
PATH=$PATH:${install.prefix}/${app.name}/${bin.dir}
export PATH</echo>
<chmod file="${install.prefix}/${app.name}/${share.dir}/before" perm="755" />
</target>
<target name="init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="compile" depends="clean, init">
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<copy file="src/pl/imgw/jrat/AplicationConstans" toFile="${version.src}" overwrite="true">
<filterset>
<filter token="DATE" value="${TODAY}"/>
<filter token="LOG" value="${install.prefix}/${app.name}/${log.dir}"/>
<filter token="ETC" value="${install.prefix}/${app.name}/${etc.dir}"/>
<filter token="TMP" value="${install.prefix}/${app.name}/${tmp.dir}"/>
<filter token="DATA" value="${install.prefix}/${app.name}/${data.dir}"/>
</filterset>
</copy>
<javac encoding="UTF-8" deprecation="on" srcdir="${src.dir}" destdir="${build.classes.dir}"
includeantruntime="false">
<include name="**/*.java"/>
<classpath refid="classpath"/>
</javac>
</target>
<target name="dist" depends="compile">
<jar destfile="${dist.dir}/${app.name}.jar" basedir="${build.classes.dir}" >
<zipgroupfileset dir="${lib.dir}" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
</target>
<!-- Compiles tests -->
<target name="compile.test" depends="compile">
<mkdir dir="${build.dir}/test"/>
<javac srcdir="${root.dir}/${test.dir}"
encoding="8859_1"
deprecation="on"
debug="${compile.debug}"
includeAntRuntime="${compile.includeAntRuntime}"
optimize="${compile.optimize}"
destdir="${build.test.dir}" classpathref="classpath">
<classpath location="${build.classes.dir}"/>
<classpath refid="classpath"/>
</javac>
</target>
<!-- Executes tests -->
<target name="execute.test">
<mkdir dir="${dist.dir}/junit-reports" />
<junit showoutput="true" forkmode="perBatch" printsummary="no" >
<jvmarg line="-Dnative.libpath=${lib.native.dir} -Xmx512m -XX:MaxPermSize=512m"/>
<formatter type="xml"/>
<formatter type="brief" usefile="false" />
<classpath location="${build.classes.dir}"/>
<classpath refid="classpath"/>
<classpath location="${build.test.dir}"/>
<batchtest fork="yes" todir="${dist.dir}/junit-reports">
<fileset dir="${build.test.dir}" includes="**/*Test.class"/>
</batchtest>
</junit>
</target>
<!-- Runs actual tests -->
<target name="test" depends="compile.test,execute.test"/>
<!-- CODE COVERAGE -->
<target name="instrument.coverage">
<delete dir="${build.instrument.dir}" />
<delete file="${build.coverage.dir}/coverage.ec" />
<delete file="${build.coverage.dir}/metadata.emma" />
<mkdir dir="${build.instrument.dir}" />
<mkdir dir="${build.coverage.dir}" />
<emma enabled="true">
<instr instrpath="${build.classes.dir}/"
destdir="${build.instrument.dir}/"
metadatafile="${build.coverage.dir}/metadata.emma"
merge="true"/>
</emma>
</target>
<target name="test.coverage" depends="instrument.coverage">
<mkdir dir="${dist.dir}/coverage-reports" />
<junit showoutput="true" forkmode="perBatch" printsummary="no" >
<jvmarg line="-Dnative.libpath=${lib.dir}/cisd-jhdf5/lib/native -Xmx512m -XX:MaxPermSize=512m"/>
<sysproperty key="emma.coverage.out.file" file="${build.coverage.dir}/coverage.ec" /> <!-- So I know where ec file is placed -->
<formatter type="xml"/>
<formatter type="brief" usefile="false" />
<classpath location="${build.instrument.dir}" /> <!-- For instrumentation -->
<classpath location="${build.classes.dir}"/>
<classpath refid="classpath"/>
<classpath location="${build.test.dir}"/>
<classpath refid="emma.classpath" />
<batchtest fork="yes" todir="${dist.dir}/junit-reports">
<fileset dir="${build.test.dir}" includes="**/*Test.class"/>
</batchtest>
</junit>
<emma enabled="true">
<report sourcepath="${source.dir}" >
<fileset dir="${build.coverage.dir}" >
<include name="*.emma" />
<include name="*.ec" />
</fileset>
<xml outfile="${dist.dir}/coverage-reports/coverage.xml" depth="method"/>
</report>
</emma>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${javadocs.dir}"/>
</target>
<!-- Generate source code documentation -->
<target name="javadocs">
<mkdir dir="${javadocs.dir}"/>
<javadoc sourcepath="${src.dir}" destdir="${javadocs.dir}"
classpath="${src.dir}" author="true" version="true"
use="true" windowtitle="${app.name} API"
doctitle="<h1>${app.name}</h1>">
<fileset dir="${javadocs.src.dir}">
<include name="**/*.java"/>
</fileset>
</javadoc>
</target>
</project>