source: extensions/net.sf.basedb.relax/trunk/build.xml @ 6778

Last change on this file since 6778 was 6778, checked in by Nicklas Nordborg, 6 months ago

References #1800: Update to BASE 3.19

Changed in the build.xml file.

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