source: extensions/net.sf.basedb.examples/trunk/build.xml @ 1352

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

References #309: Merge example plug-ins and extensions into one package

Automatically set min-base-version in 'ant update-version'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.8 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project 
3  name="ExtensionExamples" 
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="base-examples" />
12  <property name="version" value="1.3-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.source" value="1.6" />
21  <property name="javac.target" value="1.6" />
22  <property name="javac.encoding" value="UTF-8" />
23  <property name="depend.base-version" 
24    value="3.0.0" 
25    description="The BASE version that this project depends on."
26  />
27  <property name="depend.jars" 
28    value="http://base2.thep.lu.se/base/jars/${depend.base-version}" 
29    description="The location of the BASE core JARs that this project depends on."
30  />
31
32  <!-- set up classpath for compiling -->
33  <path id="classpath">
34    <fileset dir="lib">
35      <include name="**/*.jar" />
36    </fileset>
37  </path>
38
39  <target name="init">
40    <mkdir dir="${build}" />
41    <mkdir dir="${dist}" />
42  </target>
43   
44  <target name="clean">
45    <delete failonerror="false" includeemptydirs="true">
46      <fileset dir="${build}" defaultexcludes="no" />
47      <fileset dir="${dist}" defaultexcludes="no" />
48      <fileset file="${jar.name}" />
49      <fileset file="${tar.name}" />
50    </delete>
51  </target>
52 
53  <target 
54    name="dist" 
55    depends="clean,build"
56    >
57    <copy todir="${dist}">
58      <fileset dir="." includes="README,LICENSE,RELEASE,build.xml" />
59      <fileset dir="." includes="src/**,resources/**,META-INF/**" />
60      <fileset dir="." includes="lib/compile/*" />
61      <fileset file="${jar.name}" />
62    </copy>
63  </target>
64 
65  <target
66    name="package"
67    depends="dist"
68    description="Create binary distribution package"
69    >
70    <tar
71      destfile="${tar.name}"
72      longfile="gnu"
73      compression="gzip"
74      >
75      <tarfileset
76        dir="${dist}"
77        mode="755"
78        prefix="${tar.prefix}"
79        preserveLeadingSlashes="true"
80        >
81        <include name="**/*.sh" />
82      </tarfileset>
83      <tarfileset
84        dir="${dist}"
85        prefix="${tar.prefix}"
86        preserveLeadingSlashes="true"
87        >
88        <exclude name="**/*.sh" />
89      </tarfileset>
90    </tar>
91  </target>
92 
93  <target 
94    name="build"
95    depends="init,checkjar"
96    description="Compiles the plugin and put in jar"
97    >
98    <mkdir dir="${build}" />
99    <javac 
100      encoding="${javac.encoding}" 
101      srcdir="${src}" 
102      destdir="${build}" 
103      debug="true" 
104      includeantruntime="false"
105      classpathref="classpath"
106      source="${javac.source}"
107      target="${javac.target}"
108      >
109      <compilerarg value="${javac.arg}" />
110    </javac>
111    <copy todir="${build}">
112      <fileset dir="." includes="META-INF/*" />
113      <fileset dir="." includes="resources/**" />
114    </copy>
115    <jar 
116      jarfile="${jar.name}" 
117      basedir="${build}" 
118      >
119    </jar>
120  </target>
121 
122  <target 
123    name="checkjar"
124    description="Checks that the base-core-${depend.base-version}.jar and base-webclient-${depend.base-version}.jar exists."
125    >
126    <available classname="net.sf.basedb.core.Application" 
127      classpathref="classpath" property="baseCore" />
128    <available classname="net.sf.basedb.clients.web.Base" 
129      classpathref="classpath" property="baseWeb" />
130    <fail unless="baseCore" message="Can't find base-core-${depend.base-version}.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
131    <fail unless="baseWeb" message="Can't find base-webclient-${depend.base-version}.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
132    <echo>Found all requried BASE core JAR files.</echo>
133  </target>
134 
135  <target 
136    name="install"
137    depends="build"
138    >
139    <fail unless="base.plugins" message="base.plugins is not set to the path of BASE plug-ins directory." />
140    <copy todir="${base.plugins}">
141      <fileset file="${jar.name}" />
142    </copy>
143    <echo>Copied '${jar.name}' to '${base.plugins}'.</echo>
144  </target>
145 
146  <target name="update-version">
147    <echo>Setting version to: ${version}</echo>
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 
166  <target 
167    name="download-lib"
168    description="Download base-core-${depend.base-version}.jar and base-webclient-${depend.base-version}.jar."
169    >
170    <echo>
171-------------------------------------------------------   
172NOTE! You may specifiy a different download location by
173creating the file './build.properties' and
174setting 'depend.jars' to the URL to download from.
175-------------------------------------------------------
176    </echo>
177    <download-lib file="base-core-${depend.base-version}.jar" />
178    <download-lib file="base-webclient-${depend.base-version}.jar" />
179  </target>
180 
181  <macrodef name="download-lib" description="Download BASE core JAR files">
182    <attribute name="file" />
183    <sequential>
184      <get 
185        dest="lib/compile/@{file}" 
186        src="${depend.jars}/@{file}" 
187        usetimestamp="true" 
188        verbose="true"
189        ignoreerrors="true"
190      />
191    </sequential>
192  </macrodef> 
193</project>
Note: See TracBrowser for help on using the repository browser.