1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <!-- |
---|
3 | $Id: build.xml 2759 2014-10-08 07:34:45Z nicklas $ |
---|
4 | |
---|
5 | Copyright (C) 2008 Martin Svensson |
---|
6 | Copyright (C) 2009 Jari Häkkinen, Martin Svensson |
---|
7 | Copyright (C) 2010 Jari Häkkinen |
---|
8 | |
---|
9 | This file is part of the Normalizers plug-in package for BASE |
---|
10 | (net.sf.based.normalizers). The package is available at |
---|
11 | http://baseplugins.thep.lu.se/ BASE main site is |
---|
12 | http://base.thep.lu.se/ |
---|
13 | |
---|
14 | This is free software; you can redistribute it and/or modify it |
---|
15 | under the terms of the GNU General Public License as published by |
---|
16 | the Free Software Foundation; either version 3 of the License, or |
---|
17 | (at your option) any later version. |
---|
18 | |
---|
19 | The software is distributed in the hope that it will be useful, |
---|
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
22 | General Public License for more details. |
---|
23 | |
---|
24 | You should have received a copy of the GNU General Public License |
---|
25 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
26 | --> |
---|
27 | |
---|
28 | <project |
---|
29 | name="NormalizationPlugins" |
---|
30 | default="dist" |
---|
31 | basedir="." |
---|
32 | > |
---|
33 | <description> |
---|
34 | Build file for the Normalizers plug-in package for BASE. The main |
---|
35 | targets are ('dist' is default): |
---|
36 | |
---|
37 | Clean up: |
---|
38 | clean Remove generated files |
---|
39 | distclean Remove all generated and downloaded files |
---|
40 | |
---|
41 | Compiling: |
---|
42 | build Build all Java code |
---|
43 | c++ Build all C++ code in directory src/c++ |
---|
44 | dist Build all Java code for distribution (put in 'dist' |
---|
45 | subdirectory) |
---|
46 | download-lib Download required external dependecy files |
---|
47 | |
---|
48 | Packaging: |
---|
49 | package: Create *.tar.gz file containing required jars and |
---|
50 | source tar.gz files for non-Java source files. |
---|
51 | </description> |
---|
52 | |
---|
53 | <!--create this file if you need to override values from properties below --> |
---|
54 | <property file="build.properties" /> |
---|
55 | |
---|
56 | <!-- variables used --> |
---|
57 | <property name="name" value="normalization-plugins" /> |
---|
58 | <property name="version" value="1.1-beta2" description="Version number of the package" /> |
---|
59 | <property name="src" value="src" /> |
---|
60 | <property name="build" value="build" description="Location of build class files"/> |
---|
61 | <property name="dist" value="dist" description="Location where jar-file are created"/> |
---|
62 | <property name="jar" value="${name}.jar" description="Name of the jar file"/> |
---|
63 | <property name="package" location="package" description="Directory where packaged distribution files are created"/> |
---|
64 | <property name="javac.arg" value="-Xlint:unchecked" /> |
---|
65 | <property name="javac.source" value="1.7" /> |
---|
66 | <property name="javac.target" value="1.7" /> |
---|
67 | <property name="javac.encoding" value="UTF-8" /> |
---|
68 | <property name="depend.base-version" |
---|
69 | value="3.3.0" |
---|
70 | description="The BASE version that this project depends on." |
---|
71 | /> |
---|
72 | <property name="depend.jars" |
---|
73 | value="http://base.thep.lu.se/chrome/site/files/base/jars/${depend.base-version}" |
---|
74 | description="The location of the BASE core JARs that this project depends on." |
---|
75 | /> |
---|
76 | |
---|
77 | <property name="depend.PluginUtilityLocation" |
---|
78 | value="http://baseplugins.thep.lu.se/attachment/wiki/net.sf.basedb.pluginutilties" |
---|
79 | description="The location of the PluginUtility JAR that we depend on" |
---|
80 | /> |
---|
81 | <property name="PluginUtilityVersion" value="0.2" |
---|
82 | description="The version of PluginUtility that we depend on" |
---|
83 | /> |
---|
84 | <property name="PluginUtilitiesBase" |
---|
85 | value="PluginUtilities-${PluginUtilityVersion}" /> |
---|
86 | |
---|
87 | |
---|
88 | <!-- set up classpath for compiling --> |
---|
89 | <path id="classpath"> |
---|
90 | <fileset dir="lib"> |
---|
91 | <include name="**/*.jar"/> |
---|
92 | </fileset> |
---|
93 | <fileset dir="META-INF/lib"> |
---|
94 | <include name="**/*.jar"/> |
---|
95 | </fileset> |
---|
96 | </path> |
---|
97 | |
---|
98 | <target name="init"> |
---|
99 | <mkdir dir="${build}" /> |
---|
100 | <mkdir dir="${dist}" /> |
---|
101 | </target> |
---|
102 | |
---|
103 | <target name="clean"> |
---|
104 | <delete failonerror="false" includeemptydirs="true"> |
---|
105 | <fileset dir="${build}" defaultexcludes="no" /> |
---|
106 | <fileset dir="${dist}" defaultexcludes="no" /> |
---|
107 | <fileset dir="${package}" defaultexcludes="no" /> |
---|
108 | </delete> |
---|
109 | </target> |
---|
110 | |
---|
111 | <target |
---|
112 | name="distclean" |
---|
113 | depends="clean"> |
---|
114 | <delete failonerror="false" includeemptydirs="true"> |
---|
115 | <fileset file="META-INF/lib/${PluginUtilitiesBase}.jar" /> |
---|
116 | <fileset file="lib/${PluginUtilitiesBase}.tgz" /> |
---|
117 | <fileset dir="lib/compile" defaultexcludes="no"> |
---|
118 | <include name="*.jar" /> |
---|
119 | </fileset> |
---|
120 | </delete> |
---|
121 | </target> |
---|
122 | |
---|
123 | <!-- main target --> |
---|
124 | <target |
---|
125 | name="dist" |
---|
126 | depends="clean,build,manifest" |
---|
127 | > |
---|
128 | <jar |
---|
129 | jarfile="${dist}/${jar}" |
---|
130 | basedir="${build}" |
---|
131 | manifest="${build}/META-INF/MANIFEST.MF" |
---|
132 | /> |
---|
133 | <copy todir="${dist}"> |
---|
134 | <fileset dir="." includes="README*,license.txt,INSTALL" /> |
---|
135 | </copy> |
---|
136 | </target> |
---|
137 | |
---|
138 | <target |
---|
139 | name="manifest" |
---|
140 | description="Create MANIFEST.MF needed to set class path" |
---|
141 | > |
---|
142 | <manifest file="${build}/META-INF/MANIFEST.MF"> |
---|
143 | <attribute name="Built-By" value="${user.name}"/> |
---|
144 | <attribute name="Class-Path" value="lib/${PluginUtilitiesBase}.jar"/> |
---|
145 | </manifest> |
---|
146 | </target> |
---|
147 | |
---|
148 | <target |
---|
149 | name="package" |
---|
150 | depends="dist, package-qQuantileSource" |
---|
151 | description="Create binary distribution package" |
---|
152 | > |
---|
153 | <property name="tar.prefix" value="${name}-${version}" /> |
---|
154 | <mkdir dir="${package}" /> |
---|
155 | <tar |
---|
156 | destfile="${package}/${tar.prefix}.tar.gz" |
---|
157 | longfile="gnu" |
---|
158 | compression="gzip" |
---|
159 | > |
---|
160 | <tarfileset |
---|
161 | dir="${dist}" |
---|
162 | mode="755" |
---|
163 | prefix="${tar.prefix}" |
---|
164 | preserveLeadingSlashes="true" |
---|
165 | > |
---|
166 | <include name="**/*.sh" /> |
---|
167 | </tarfileset> |
---|
168 | <tarfileset |
---|
169 | dir="${dist}" |
---|
170 | prefix="${tar.prefix}" |
---|
171 | preserveLeadingSlashes="true" |
---|
172 | > |
---|
173 | <exclude name="**/*.sh" /> |
---|
174 | </tarfileset> |
---|
175 | </tar> |
---|
176 | <checksum file="${package}/${tar.prefix}.tar.gz" /> |
---|
177 | </target> |
---|
178 | |
---|
179 | <target |
---|
180 | name="package-qQuantileSource" |
---|
181 | description="Add qQuantileNormalization C++ package to 'dist'" |
---|
182 | > |
---|
183 | <exec dir="${src}/c++/" executable="./bootstrap" /> |
---|
184 | <replace file="${src}/c++/configure"> |
---|
185 | <replacefilter |
---|
186 | token="@PKGVERSION@" |
---|
187 | value="${version}" |
---|
188 | /> |
---|
189 | </replace> |
---|
190 | <chmod file="${src}/c++/configure" perm="a+x" /> |
---|
191 | <exec dir="${src}/c++/" executable="./configure"> |
---|
192 | <arg line="--disable-libcheck" /> |
---|
193 | </exec> |
---|
194 | <exec dir="${src}/c++/" executable="make"> |
---|
195 | <arg line="dist" /> |
---|
196 | </exec> |
---|
197 | <move file="${src}/c++/qqn-${version}.tar.gz" todir="dist" /> |
---|
198 | </target> |
---|
199 | |
---|
200 | <target |
---|
201 | name="build" |
---|
202 | depends="init, checkjar" |
---|
203 | description="Compiles the plugin and put in jar" |
---|
204 | > |
---|
205 | <mkdir dir="${build}" /> |
---|
206 | <javac |
---|
207 | encoding="${javac.encoding}" |
---|
208 | srcdir="${src}" |
---|
209 | destdir="${build}" |
---|
210 | debug="true" |
---|
211 | classpathref="classpath" |
---|
212 | source="${javac.source}" |
---|
213 | target="${javac.target}" |
---|
214 | includeantruntime="false" |
---|
215 | > |
---|
216 | <compilerarg value="${javac.arg}" /> |
---|
217 | </javac> |
---|
218 | <copy todir="${build}"> |
---|
219 | <fileset dir="." includes="META-INF/**" /> |
---|
220 | </copy> |
---|
221 | |
---|
222 | </target> |
---|
223 | |
---|
224 | <target |
---|
225 | name="install" |
---|
226 | depends="dist" |
---|
227 | > |
---|
228 | <fail unless="base.plugins" message="base.plugins is not set to the path of BASE plug-ins directory." /> |
---|
229 | <copy todir="${base.plugins}"> |
---|
230 | <fileset file="${dist}/${jar}" /> |
---|
231 | </copy> |
---|
232 | <echo>Copied '${jar}' to '${base.plugins}'.</echo> |
---|
233 | </target> |
---|
234 | |
---|
235 | <target name="update-version"> |
---|
236 | <echo>Setting version to: ${version}</echo> |
---|
237 | |
---|
238 | <echo>Normalizations.java</echo> |
---|
239 | <replaceregexp |
---|
240 | file="${src}/net/sf/basedb/normalizers/Normalizations.java" |
---|
241 | match="public static final String VERSION = ".*";" |
---|
242 | replace="public static final String VERSION = "${version}";" |
---|
243 | encoding="UTF-8" |
---|
244 | /> |
---|
245 | |
---|
246 | <echo>extensions.xml</echo> |
---|
247 | <replaceregexp |
---|
248 | file="META-INF/extensions.xml" |
---|
249 | match="<version>.*</version>" |
---|
250 | replace="<version>${version}</version>" |
---|
251 | encoding="UTF-8" |
---|
252 | /> |
---|
253 | <replaceregexp |
---|
254 | file="META-INF/extensions.xml" |
---|
255 | match="<min-base-version>.*</min-base-version>" |
---|
256 | replace="<min-base-version>${depend.base-version}</min-base-version>" |
---|
257 | encoding="UTF-8" |
---|
258 | /> |
---|
259 | <echo>Don't forget to commit the changes to the subversion repository!</echo> |
---|
260 | </target> |
---|
261 | |
---|
262 | <target |
---|
263 | name="checkjar" |
---|
264 | description="Checks that the BASE JAR files, |
---|
265 | and appropriate PluginUtilities jar file exists." |
---|
266 | > |
---|
267 | <available classname="net.sf.basedb.core.Application" |
---|
268 | classpathref="classpath" property="base-core" /> |
---|
269 | <available classname="net.sf.basedb.plugins.ReporterFlatFileImporter" |
---|
270 | classpathref="classpath" property="base-coreplugins" /> |
---|
271 | <available classname="net.sf.basedb.plugins.AbstractRunBinaryPlugin" |
---|
272 | classpathref="classpath" |
---|
273 | classpath="META-INF/lib/${PluginUtilitiesBase}/${PluginUtilitiesBase}.jar" |
---|
274 | property="pluginutilities" /> |
---|
275 | <fail unless="base-core" message="Can't find base-core-${depend.base-version}.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." /> |
---|
276 | <fail unless="base-coreplugins" message="Can't find base-coreplugins-${depend.base-version}.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." /> |
---|
277 | <fail unless="pluginutilities" message="Can't find PluginUtilities jar file in ./META-INF/lib. Try 'ant download-lib' to download the missing file." /> |
---|
278 | <echo>Found all required jar files</echo> |
---|
279 | </target> |
---|
280 | |
---|
281 | <target name="c++"> |
---|
282 | <exec dir="${src}/c++/" executable="./bootstrap" /> |
---|
283 | <replace file="${src}/c++/configure"> |
---|
284 | <replacefilter |
---|
285 | token="@PKGVERSION@" |
---|
286 | value="${version}" |
---|
287 | /> |
---|
288 | </replace> |
---|
289 | <chmod file="${src}/c++/configure" perm="a+x" /> |
---|
290 | <exec dir="${src}/c++/" executable="./configure"> |
---|
291 | </exec> |
---|
292 | <exec dir="${src}/c++/" executable="make"> |
---|
293 | </exec> |
---|
294 | </target> |
---|
295 | |
---|
296 | <target |
---|
297 | name="download-lib" |
---|
298 | depends="download-message, download-pluginutilities" |
---|
299 | description="Download BASE JAR files" |
---|
300 | > |
---|
301 | <download |
---|
302 | location="${depend.jars}" |
---|
303 | file="base-core-${depend.base-version}.jar" |
---|
304 | destdir="lib/compile" |
---|
305 | tofile="base-core-${depend.base-version}.jar" |
---|
306 | /> |
---|
307 | <download |
---|
308 | location="${depend.jars}" |
---|
309 | file="base-coreplugins-${depend.base-version}.jar" |
---|
310 | destdir="lib/compile" |
---|
311 | tofile="base-coreplugins-${depend.base-version}.jar" |
---|
312 | /> |
---|
313 | </target> |
---|
314 | |
---|
315 | <target name="download-message"> |
---|
316 | <echo> |
---|
317 | ------------------------------------------------------- |
---|
318 | NOTE! You may specify a different download locations by |
---|
319 | creating the file './build.properties' and set one or |
---|
320 | more of the below variables |
---|
321 | |
---|
322 | 'depend.jars': the URL to download BASE core jar |
---|
323 | files from. |
---|
324 | |
---|
325 | 'depend.PluginUtilityLocation': the URL to download |
---|
326 | PluginUtility jar from. |
---|
327 | 'PluginUtilityVersion': the version of PluginUtility to |
---|
328 | download. |
---|
329 | ------------------------------------------------------- |
---|
330 | </echo> |
---|
331 | </target> |
---|
332 | |
---|
333 | <target |
---|
334 | name="download-pluginutilities" |
---|
335 | description="Download PluginUtilities.jar." |
---|
336 | > |
---|
337 | <download |
---|
338 | location="${depend.PluginUtilityLocation}" |
---|
339 | file="${PluginUtilitiesBase}.tgz?format=raw" |
---|
340 | destdir="lib" |
---|
341 | tofile="${PluginUtilitiesBase}.tgz" |
---|
342 | /> |
---|
343 | <!-- Extract the PluginUtilities.jar file to the META-INF/lib directory --> |
---|
344 | <untar src="lib/${PluginUtilitiesBase}.tgz" dest="META-INF/lib" compression="gzip" > |
---|
345 | <patternset> |
---|
346 | <include name="${PluginUtilitiesBase}/*.jar" /> |
---|
347 | </patternset> |
---|
348 | <flattenmapper/> |
---|
349 | </untar> |
---|
350 | </target> |
---|
351 | |
---|
352 | <macrodef name="download" description="Download requested files"> |
---|
353 | <attribute name="destdir" /> |
---|
354 | <attribute name="location" /> |
---|
355 | <attribute name="file" /> |
---|
356 | <attribute name="tofile" /> |
---|
357 | <sequential> |
---|
358 | <get |
---|
359 | dest="@{destdir}/@{tofile}" |
---|
360 | src="@{location}/@{file}" |
---|
361 | usetimestamp="true" |
---|
362 | verbose="true" |
---|
363 | ignoreerrors="false" |
---|
364 | /> |
---|
365 | </sequential> |
---|
366 | </macrodef> |
---|
367 | |
---|
368 | </project> |
---|