source: webservices/net.sf.basedb.examples/trunk/build.xml @ 1296

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

Fixes #290: Add 'download-lib' target to ant buildfile and remove checked in BASE jar file

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 4.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project 
3  name="ExampleWebServiceClient" 
4  default="build" 
5  basedir=".">
6 
7  <!-- settings for the BASE webservices server -->
8  <!-- modify the values as needed              -->
9  <property name="services.url" value="http://localhost:8080/base2/services" />
10  <property name="services.login" value="root" />
11  <property name="services.password" value="root" />
12  <!-- set this to a valid directory to enable download of raw data from raw bioassays -->
13  <property name="download.dir" value="" />
14
15  <!-- variables used -->
16  <property name="name" value="example-webservices" />
17  <property name="version" value="2.6" />
18  <property name="src" location="src" description="Location of source files" />
19  <property name="build" location="build" description="Location of compiled files" />
20  <property name="dist" location="dist" description="Directory where distribution should be created" />
21  <property name="jar.name" value="${name}.jar" description="Name of JAR file with the compiled code." />
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.jars" 
29    value="http://base2.thep.lu.se/base/jars/2.17.0" 
30    description="The location of the BASE core JARs that we depend on"
31  />
32
33  <!-- set up classpath for compiling -->
34  <path id="classpath">
35    <fileset dir="lib">
36      <include name="**/*.jar" />
37    </fileset>
38  </path>
39
40  <target name="init">
41    <mkdir dir="${build}" />
42    <mkdir dir="${dist}" />
43  </target>
44   
45  <target name="clean">
46    <delete failonerror="false" includeemptydirs="true">
47      <fileset dir="${build}" defaultexcludes="no" />
48      <fileset dir="${dist}" defaultexcludes="no" />
49      <fileset file="${jar.name}" />
50      <fileset file="${tar.name}" />
51    </delete>
52  </target>
53 
54  <target 
55    name="dist" 
56    depends="clean,build"
57    >
58    <copy todir="${dist}">
59      <fileset dir="." includes="README,LICENSE,RELEASE,build.xml" />
60      <fileset dir="." includes="src/**" />
61      <fileset dir="." includes="lib/**" />
62      <fileset file="${jar.name}" />
63    </copy>
64  </target>
65 
66  <target
67    name="package"
68    depends="dist"
69    description="Create binary distribution package"
70    >
71    <tar
72      destfile="${tar.name}"
73      longfile="gnu"
74      compression="gzip"
75      >
76      <tarfileset
77        dir="${dist}"
78        mode="755"
79        prefix="${tar.prefix}"
80        preserveLeadingSlashes="true"
81        >
82        <include name="**/*.sh" />
83      </tarfileset>
84      <tarfileset
85        dir="${dist}"
86        prefix="${tar.prefix}"
87        preserveLeadingSlashes="true"
88        >
89        <exclude name="**/*.sh" />
90      </tarfileset>
91    </tar>
92  </target>
93 
94  <target 
95    name="test" 
96    description="Test the client by logging in to BASE and listing projects and experiments" 
97    depends="build"
98    >
99    <java
100      classname="net.sf.basedb.ws.example.Main"
101      >
102      <arg value="${services.url}" />
103      <arg value="${services.login}" />
104      <arg value="${services.password}" />
105      <arg value="${download.dir}" />
106      <classpath>
107        <path refid="classpath" />
108        <path location="${build}" />
109      </classpath>
110    </java>
111  </target>
112 
113  <target 
114    name="build"
115    depends="init,checkjar"
116    description="Compiles the plugin and put in jar"
117    >
118    <mkdir dir="${build}" />
119    <javac 
120      encoding="${javac.encoding}" 
121      srcdir="${src}" 
122      destdir="${build}" 
123      debug="true" 
124      classpathref="classpath"
125      source="${javac.source}"
126      target="${javac.target}"
127      includeantruntime="false"
128      >
129      <compilerarg value="${javac.arg}" />
130    </javac>
131    <jar 
132      jarfile="${jar.name}" 
133      basedir="${build}" 
134      >
135    </jar>
136  </target>
137 
138  <target 
139    name="checkjar"
140    description="Checks that the BASE2WSClient.jar exists."
141    >
142    <available classname="net.sf.basedb.ws.client.SessionClient"
143      classpathref="classpath" property="base2wsclient" />
144    <fail unless="base2wsclient" message="Can't find BASE2WSClient.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
145    <echo>Found BASE2WSClient.jar.</echo>
146  </target>
147
148  <target 
149    name="download-lib"
150    description="Download BASE2WSClient.jar."
151    >
152    <echo>
153-------------------------------------------------------   
154NOTE! You may specifiy a different download location by
155creating the file './build.properties' and
156setting 'depend.jars' to the URL to download from.
157-------------------------------------------------------
158    </echo>
159    <download-lib file="BASE2WSClient.jar" />
160  </target>
161 
162  <macrodef name="download-lib" description="Download BASE core JAR files">
163    <attribute name="file" />
164    <sequential>
165      <get 
166        dest="lib/@{file}" 
167        src="${depend.jars}/@{file}" 
168        usetimestamp="true" 
169        verbose="true"
170        ignoreerrors="true"
171      />
172    </sequential>
173  </macrodef>
174</project>
Note: See TracBrowser for help on using the repository browser.