source: plugins/base2/net.sf.basedb.illumina/trunk/build.xml @ 1542

Last change on this file since 1542 was 1542, checked in by Nicklas Nordborg, 10 years ago

Fixes #363: Add 'install' target to ant build script

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!-- $Id: build.xml 1542 2012-02-22 10:22:28Z nicklas $ -->
4
5<project 
6  name="IlluminaPlugins" 
7  default="dist" 
8  basedir=".">
9
10  <!--create this file if you need to override values from properties below -->
11  <property file="build.properties" />
12
13 
14  <!-- variables used -->
15  <property name="name" value="illumina-plugins" />
16  <property name="version" value="1.8-dev" />
17  <property name="src" location="src" description="Location of source files" />
18  <property name="build" location="build" description="Location of compiled files" />
19  <property name="dist" location="dist" description="Directory where distribution should be created" />
20  <property name="package" location="package" description="Directory where packaged distribution files are created"/>
21  <property name="jar.name" value="${name}.jar" description="Name of JAR file with the extensions." />
22  <property name="tar.prefix" value="${name}-${version}" description="Prefix of .tar.gz file for download." />
23  <property name="tar.name" value="${tar.prefix}.tar.gz" description="Full name of .tar.gz file for download." />
24  <property name="javac.arg" value="-Xlint:unchecked" />
25  <property name="javac.source" value="1.6" />
26  <property name="javac.target" value="1.6" />
27  <property name="javac.encoding" value="UTF-8" />
28  <property name="depend.base-version" 
29    value="3.0.0" 
30    description="The BASE version that this project depends on."
31  />
32  <property name="depend.jars" 
33    value="http://base2.thep.lu.se/base/jars/${depend.base-version}" 
34    description="The location of the BASE core JARs that this project depends on."
35  />
36
37  <!-- set up classpath for compiling -->
38  <path id="classpath">
39    <fileset dir="lib">
40      <include name="**/*.jar" />
41    </fileset>
42  </path>
43
44  <target name="init">
45    <mkdir dir="${build}" />
46    <mkdir dir="${dist}" />
47  </target>
48   
49  <target name="clean">
50    <delete failonerror="false" includeemptydirs="true">
51      <fileset dir="${build}" defaultexcludes="no" />
52      <fileset dir="${dist}" defaultexcludes="no" />
53      <fileset dir="${package}" defaultexcludes="no" />
54    </delete>
55  </target>
56 
57  <target 
58    name="dist" 
59    depends="clean,build"
60    >
61    <copy todir="${dist}">
62      <fileset dir="." includes="README*,LICENSE,INSTALL" />
63      <fileset dir="." includes="config/*" />
64      <fileset dir="." includes="contrib/*" />
65    </copy>
66  </target>
67 
68  <target
69    name="package"
70    depends="dist"
71    description="Create binary distribution package"
72    >
73    <mkdir dir="${package}" />
74    <tar
75      destfile="${package}/${tar.name}"
76      longfile="gnu"
77      compression="gzip"
78      >
79      <tarfileset
80        dir="${dist}"
81        mode="755"
82        prefix="${tar.prefix}"
83        preserveLeadingSlashes="true"
84        >
85        <include name="**/*.sh" />
86      </tarfileset>
87      <tarfileset
88        dir="${dist}"
89        prefix="${tar.prefix}"
90        preserveLeadingSlashes="true"
91        >
92        <exclude name="**/*.sh" />
93      </tarfileset>
94    </tar>
95  </target>
96 
97  <target 
98    name="build"
99    depends="init,checkjar"
100    description="Compiles the plugin and put in jar"
101    >
102    <property name="jar" value="${name}.jar" />
103    <mkdir dir="${build}" />
104    <javac 
105      encoding="${javac.encoding}" 
106      srcdir="${src}" 
107      destdir="${build}" 
108      debug="true" 
109      deprecation="true"
110      classpathref="classpath"
111      source="${javac.source}"
112      target="${javac.target}"
113      includeantruntime="false"
114      >
115      <compilerarg value="${javac.arg}" />
116    </javac>
117    <copy todir="${build}">
118      <fileset dir="." includes="META-INF/*"/>
119    </copy>   
120    <jar 
121      jarfile="${dist}/${jar.name}" 
122      basedir="${build}"
123      >
124    </jar>     
125  </target>
126 
127  <target 
128    name="install"
129    depends="build"
130    >
131    <fail unless="base.plugins" message="base.plugins is not set to the path of BASE plug-ins directory." />
132    <copy todir="${base.plugins}">
133      <fileset file="${dist}/${jar.name}" />
134    </copy>
135    <echo>Copied '${jar.name}' to '${base.plugins}'.</echo>
136  </target>
137 
138  <target name="update-version">
139    <echo>Setting version to: ${version}</echo>
140   
141    <echo>Illumina.java</echo>
142    <replaceregexp 
143      file="${src}/net/sf/basedb/illumina/Illumina.java"
144      match="public static final String VERSION = &#34;.*&#34;;"
145      replace="public static final String VERSION = &#34;${version}&#34;;"
146      encoding="UTF-8"
147    />
148   
149    <echo>extensions.xml</echo>
150    <replaceregexp 
151      file="META-INF/extensions.xml"
152      match="&lt;version&gt;.*&lt;/version&gt;"
153      replace="&lt;version&gt;${version}&lt;/version&gt;"
154      encoding="UTF-8"
155    />
156    <replaceregexp 
157      file="META-INF/extensions.xml"
158      match="&lt;min-base-version&gt;.*&lt;/min-base-version&gt;"
159      replace="&lt;min-base-version&gt;${depend.base-version}&lt;/min-base-version&gt;"
160      encoding="UTF-8"
161    />
162    <echo>Don't forget to commit the changes to the subversion repository!</echo>
163  </target>
164 
165  <target 
166    name="checkjar"
167    description="Checks that the base-core-${depend.base-version}.jar, base-webclient-${depend.base-version}.jar, base-coreplugins-${depend.base-version}.jar and base-wsclient-${depend.base-version}.jar exists."
168    >
169    <available classname="net.sf.basedb.core.Application" 
170      classpathref="classpath" property="base-core" />
171    <available classname="net.sf.basedb.plugins.ReporterFlatFileImporter" 
172      classpathref="classpath" property="base-coreplugins" />
173    <available classname="net.sf.basedb.ws.client.SessionClient"
174      classpathref="classpath" property="base-webservices-client" />
175    <available classname="net.sf.basedb.clients.web.extensions.menu.FixedMenuItemFactory" 
176      classpathref="classpath" property="base-webclient" />
177    <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." />
178    <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." />
179    <fail unless="base-webservices-client" message="Can't find base-webservices-client-${depend.base-version}.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
180    <fail unless="base-webclient" message="Can't find base-webclient-${depend.base-version}.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
181    <echo>
182Found base-core-${depend.base-version}.jar,
183      base-coreplugins-${depend.base-version}.jar,
184      base-webservices-client-${depend.base-version}.jar and
185      base-webclient-${depend.base-version}.jar.</echo>
186  </target>
187
188  <target 
189    name="download-lib"
190    description="Download BASE JAR files that are needed for compilation"
191    >
192    <echo>
193-------------------------------------------------------   
194NOTE! You may specify a different download location by
195creating the file './build.properties' and
196setting 'depend.jars' to the URL to download from.
197-------------------------------------------------------
198    </echo>
199    <download-lib file="base-core-${depend.base-version}.jar" />
200    <download-lib file="base-coreplugins-${depend.base-version}.jar" />
201    <download-lib file="base-webservices-client-${depend.base-version}.jar" />
202    <download-lib file="base-webclient-${depend.base-version}.jar" />
203  </target>
204 
205  <macrodef name="download-lib" description="Download BASE core JAR files">
206    <attribute name="file" />
207    <sequential>
208      <get 
209        dest="lib/compile/@{file}" 
210        src="${depend.jars}/@{file}" 
211        usetimestamp="true" 
212        verbose="true"
213        ignoreerrors="true"
214      />
215    </sequential>
216  </macrodef> 
217
218</project>
Note: See TracBrowser for help on using the repository browser.