source: extensions/net.sf.basedb.torrent/trunk/build.xml @ 1636

Last change on this file since 1636 was 1636, checked in by Nicklas Nordborg, 11 years ago

Changes required for BASE 3.1 compatibility.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.7 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3  $Id $
4
5  Copyright (C) 2010 Nicklas Nordborg
6
7  This file is part of Bittorent download service for BASE.
8  Available at http://baseplugins.thep.lu.se/
9
10  BASE is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14
15  BASE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330,
23  Boston, MA  02111-1307, USA.
24-->
25<project 
26  name="BittorentService" 
27  default="jar" 
28  basedir=".">
29
30  <!--create this file if you need to override values from properties below -->
31  <property file="build.properties" />
32 
33  <!-- variables used -->
34  <property name="name" value="base-torrent" />
35  <property name="version" value="0.2-dev" />
36  <property name="src" location="src" description="Location of source files" />
37  <property name="build" location="build" description="Location of compiled files" />
38  <property name="jar.name" value="${name}.jar" 
39    description="Name of JAR file with the extensions." />
40  <property name="tar.prefix" value="${name}-${version}" 
41    description="Prefix of .tar.gz file for download." />
42  <property name="tar.name" value="${tar.prefix}.tar.gz" 
43    description="Full name of .tar.gz file for download." />
44  <property name="javac.arg" value="-Xlint:unchecked" />
45  <property name="javac.source" value="1.6" />
46  <property name="javac.target" value="1.6" />
47  <property name="javac.encoding" value="UTF-8" />
48  <property name="depend.base-version" 
49    value="3.1.0" 
50    description="The BASE version that this project depends on."
51  />
52  <property name="depend.jars" 
53    value="http://base2.thep.lu.se/base/jars/${depend.base-version}" 
54    description="The location of the BASE core JARs that this project depends on."
55  />
56
57  <!-- set up classpath for compiling -->
58  <path id="external.classpath">
59    <fileset dir="lib">
60      <include name="**/*.jar" />
61    </fileset>
62  </path>
63
64  <path id="classpath">
65    <path refid="external.classpath" />
66    <pathelement location="${build}/external/hpbtc" />
67  </path>
68
69  <target name="init">
70    <mkdir dir="${build}" />
71  </target>
72   
73  <target name="clean">
74    <delete failonerror="false" includeemptydirs="true">
75      <fileset dir="${build}" defaultexcludes="no" />
76      <fileset file="${jar.name}" />
77      <fileset file="lib/torrent/hpbtc.jar" />
78      <fileset file="${tar.name}" />
79    </delete>
80  </target>
81 
82  <target
83    name="package"
84    depends="clean,jar"
85    description="Clean and create binary distribution package"
86    >
87    <tar
88      destfile="${tar.name}"
89      longfile="gnu"
90      compression="gzip"
91      >
92      <tarfileset
93        dir="."
94        prefix="${tar.prefix}"
95        preserveLeadingSlashes="true"
96        includes="${jar.name},README,LICENSE*,torrent.properties,lib/torrent/*"
97      />
98    </tar>
99  </target>
100 
101  <target 
102    name="install"
103    depends="jar"
104    >
105    <fail unless="base.plugins" message="base.plugins is not set to the path of BASE plug-ins directory." />
106    <copy todir="${base.plugins}">
107      <fileset file="${jar.name}" />
108    </copy>
109    <echo>Copied '${jar.name}' to '${base.plugins}'.</echo>
110  </target>
111
112 
113  <target 
114    name="jar"
115    depends="build"
116    description="Creates the extension JAR file"
117    >
118    <jar 
119      jarfile="${jar.name}"
120      manifest="META-INF/MANIFEST.MF"
121      >
122      <fileset dir="${build}/main" />
123      <fileset dir="${build}//external/hpbtc" />
124      <fileset dir="." includes="META-INF/**" />
125      <fileset dir="." includes="resources/**" />
126    </jar>
127  </target>
128 
129  <target 
130    name="build"
131    depends="init,checkjar,build.external"
132    description="Compiles the plugin"
133    >
134    <mkdir dir="${build}/main" />
135    <javac 
136      srcdir="${src}/main" 
137      destdir="${build}/main" 
138      debug="true" 
139      classpathref="classpath"
140      encoding="${javac.encoding}" 
141      source="${javac.source}"
142      target="${javac.target}"
143      includeantruntime="false"
144      >
145      <compilerarg value="${javac.arg}" />
146    </javac>
147  </target>
148 
149  <target
150    name="build.external"
151    >
152    <mkdir dir="${build}/external/hpbtc" />
153    <javac 
154      srcdir="${src}/external/hpbtc" 
155      destdir="${build}/external/hpbtc" 
156      debug="true" 
157      classpathref="external.classpath"
158      encoding="${javac.encoding}" 
159      source="${javac.source}"
160      target="${javac.target}"
161      includeantruntime="false"
162      >
163      <!--compilerarg value="${javac.arg}" / -->
164    </javac>
165  </target>
166 
167  <target 
168    name="checkjar"
169    description="Checks that the BASE2Core.jar and BASE2Webclient.jar exists."
170    >
171    <available classname="net.sf.basedb.core.Application" 
172      classpathref="classpath" property="base-core" />
173    <available classname="net.sf.basedb.clients.web.extensions.menu.FixedMenuItemFactory" 
174      classpathref="classpath" property="base-web" />
175    <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." />
176    <fail unless="base-web" message="Can't find base-webservices-client-${depend.base-version}.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
177    <echo>Found all requried BASE core JAR files.</echo>
178  </target>
179 
180  <target 
181    name="download-lib"
182    description="Download required BASE core jar files"
183    >
184    <echo>
185-------------------------------------------------------   
186NOTE! You may specifiy a different download location by
187creating the file './build.properties' and
188setting 'depend.jars' to the URL to download from.
189-------------------------------------------------------
190    </echo>
191    <download-lib file="base-core-${depend.base-version}.jar" />
192    <download-lib file="base-webclient-${depend.base-version}.jar" />
193  </target>
194 
195  <macrodef name="download-lib" description="Download BASE core JAR files">
196    <attribute name="file" />
197    <sequential>
198      <get 
199        dest="lib/compile/@{file}" 
200        src="${depend.jars}/@{file}" 
201        usetimestamp="true" 
202        verbose="true"
203        ignoreerrors="true"
204      />
205    </sequential>
206  </macrodef>
207 
208  <target name="update-version">
209    <echo>Setting version to: ${version}</echo>
210   
211    <echo>extensions.xml</echo>
212    <replaceregexp 
213      file="META-INF/extensions.xml"
214      match="&lt;version&gt;.*&lt;/version&gt;"
215      replace="&lt;version&gt;${version}&lt;/version&gt;"
216      encoding="UTF-8"
217    />
218    <replaceregexp 
219      file="META-INF/extensions.xml"
220      match="&lt;min-base-version&gt;.*&lt;/min-base-version&gt;"
221      replace="&lt;min-base-version&gt;${depend.base-version}&lt;/min-base-version&gt;"
222      encoding="UTF-8"
223    />
224
225    <echo>Don't forget to commit the changes to the subversion repository!</echo>
226  </target>
227
228 
229</project>
Note: See TracBrowser for help on using the repository browser.