source: extensions/net.sf.basedb.labenv/trunk/build.xml @ 5572

Last change on this file since 5572 was 5572, checked in by Nicklas Nordborg, 4 years ago

Preparing for future release LabEnv? 1.8

File size: 6.3 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project 
3  name="LabEnv" 
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="labenv" />
12  <property name="version" value="1.8-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.15.0" 
24    description="The BASE version that this project depends on."
25  />
26  <property name="depend.jars" 
27    value="http://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/compile" 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" />
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      <tarfileset
89        dir="."
90        prefix="${tar.prefix}"
91        preserveLeadingSlashes="true"
92        includes="labenv-config.xml"
93        >
94      </tarfileset>
95    </tar>
96  </target>
97 
98  <target 
99    name="install"
100    depends="build"
101    >
102    <fail unless="base.plugins" message="base.plugins is not set to the path of BASE plug-ins directory." />
103    <copy todir="${base.plugins}">
104      <fileset file="${jar.name}" />
105    </copy>
106    <echo>Copied '${jar.name}' to '${base.plugins}'.</echo>
107  </target>
108
109  <target 
110    name="build"
111    depends="init,checkjar"
112    description="Compiles the plugin and put in jar"
113    >
114    <mkdir dir="${build}" />
115    <javac 
116      encoding="${javac.encoding}" 
117      srcdir="${src}" 
118      destdir="${build}" 
119      debug="true" 
120      includeantruntime="false"
121      classpathref="classpath"
122      release="${javac.release}"
123      >
124      <compilerarg value="${javac.arg}" />
125    </javac>
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/compile. 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/compile. 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/compile/@{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>LabEnv.java</echo>
181    <replaceregexp 
182      file="${src}/net/sf/basedb/labenv/LabEnv.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>labenv.js</echo>
189    <replaceregexp 
190      file="resources/labenv.js"
191      match="labenv.VERSION = '.*';"
192      replace="labenv.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>Don't forget to commit the changes to the subversion repository!</echo>
211  </target>
212
213</project>
Note: See TracBrowser for help on using the repository browser.