1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <!-- |
---|
3 | Copyright (C) 2011 Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of the Example Code Package for BASE. |
---|
6 | Available at http://baseplugins.thep.lu.se/ |
---|
7 | BASE main site: http://base.thep.lu.se/ |
---|
8 | |
---|
9 | This is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | The software is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | --> |
---|
22 | <project |
---|
23 | name="ExampleCode" |
---|
24 | default="build" |
---|
25 | basedir="."> |
---|
26 | |
---|
27 | <!--create this file if you need to override values from properties below --> |
---|
28 | <property file="build.properties" /> |
---|
29 | |
---|
30 | <!-- variables used --> |
---|
31 | <property name="name" value="base-examples" /> |
---|
32 | <property name="version" value="1.9-dev" /> |
---|
33 | <property name="src" location="src" description="Location of source files" /> |
---|
34 | <property name="build" location="build" description="Location of compiled files" /> |
---|
35 | <property name="dist" location="dist" description="Directory where distribution should be created" /> |
---|
36 | <property name="jar.name" value="${name}.jar" description="Name of JAR file with the extensions." /> |
---|
37 | <property name="tar.prefix" value="${name}-${version}" description="Prefix of .tar.gz file for download." /> |
---|
38 | <property name="tar.name" value="${tar.prefix}.tar.gz" description="Full name of .tar.gz file for download." /> |
---|
39 | <property name="javac.arg" value="-Xlint:unchecked" /> |
---|
40 | <property name="javac.source" value="1.8" /> |
---|
41 | <property name="javac.target" value="1.8" /> |
---|
42 | <property name="javac.encoding" value="UTF-8" /> |
---|
43 | <property name="depend.base-version" |
---|
44 | value="3.10.0" |
---|
45 | description="The BASE version that this project depends on." |
---|
46 | /> |
---|
47 | <property name="depend.jars" |
---|
48 | value="https://base.thep.lu.se/chrome/site/files/base/jars/${depend.base-version}" |
---|
49 | description="The location of the BASE core JARs that this project depends on." |
---|
50 | /> |
---|
51 | |
---|
52 | <!-- set up classpath for compiling --> |
---|
53 | <path id="classpath"> |
---|
54 | <fileset dir="lib"> |
---|
55 | <include name="**/*.jar" /> |
---|
56 | </fileset> |
---|
57 | </path> |
---|
58 | |
---|
59 | <target name="init"> |
---|
60 | <mkdir dir="${build}" /> |
---|
61 | <mkdir dir="${dist}" /> |
---|
62 | </target> |
---|
63 | |
---|
64 | <target name="clean"> |
---|
65 | <delete failonerror="false" includeemptydirs="true"> |
---|
66 | <fileset dir="${build}" defaultexcludes="no" /> |
---|
67 | <fileset dir="${dist}" defaultexcludes="no" /> |
---|
68 | <fileset file="${jar.name}" /> |
---|
69 | <fileset file="${tar.name}" /> |
---|
70 | </delete> |
---|
71 | </target> |
---|
72 | |
---|
73 | <target |
---|
74 | name="dist" |
---|
75 | depends="clean,build" |
---|
76 | > |
---|
77 | <copy todir="${dist}"> |
---|
78 | <fileset dir="." includes="README,LICENSE,RELEASE,build.xml" /> |
---|
79 | <fileset dir="." includes="src/**,resources/**,META-INF/**" /> |
---|
80 | <fileset dir="." includes="lib/compile/*" /> |
---|
81 | <fileset file="${jar.name}" /> |
---|
82 | </copy> |
---|
83 | </target> |
---|
84 | |
---|
85 | <target |
---|
86 | name="package" |
---|
87 | depends="dist" |
---|
88 | description="Create binary distribution package" |
---|
89 | > |
---|
90 | <tar |
---|
91 | destfile="${tar.name}" |
---|
92 | longfile="gnu" |
---|
93 | compression="gzip" |
---|
94 | > |
---|
95 | <tarfileset |
---|
96 | dir="${dist}" |
---|
97 | mode="755" |
---|
98 | prefix="${tar.prefix}" |
---|
99 | preserveLeadingSlashes="true" |
---|
100 | > |
---|
101 | <include name="**/*.sh" /> |
---|
102 | </tarfileset> |
---|
103 | <tarfileset |
---|
104 | dir="${dist}" |
---|
105 | prefix="${tar.prefix}" |
---|
106 | preserveLeadingSlashes="true" |
---|
107 | > |
---|
108 | <exclude name="**/*.sh" /> |
---|
109 | </tarfileset> |
---|
110 | </tar> |
---|
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 | includeantruntime="false" |
---|
125 | classpathref="classpath" |
---|
126 | source="${javac.source}" |
---|
127 | target="${javac.target}" |
---|
128 | > |
---|
129 | <compilerarg value="${javac.arg}" /> |
---|
130 | </javac> |
---|
131 | <copy todir="${build}"> |
---|
132 | <fileset dir="." includes="META-INF/*" /> |
---|
133 | <fileset dir="." includes="resources/**" /> |
---|
134 | </copy> |
---|
135 | <jar |
---|
136 | jarfile="${jar.name}" |
---|
137 | basedir="${build}" |
---|
138 | > |
---|
139 | </jar> |
---|
140 | </target> |
---|
141 | |
---|
142 | <target |
---|
143 | name="checkjar" |
---|
144 | description="Checks that the base-core-${depend.base-version}.jar and base-webclient-${depend.base-version}.jar exists." |
---|
145 | > |
---|
146 | <available classname="net.sf.basedb.core.Application" |
---|
147 | classpathref="classpath" property="baseCore" /> |
---|
148 | <available classname="net.sf.basedb.clients.web.Base" |
---|
149 | classpathref="classpath" property="baseWeb" /> |
---|
150 | <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." /> |
---|
151 | <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." /> |
---|
152 | <echo>Found all requried BASE core JAR files.</echo> |
---|
153 | </target> |
---|
154 | |
---|
155 | <target |
---|
156 | name="install" |
---|
157 | depends="build" |
---|
158 | > |
---|
159 | <fail unless="base.plugins" message="base.plugins is not set to the path of BASE plug-ins directory." /> |
---|
160 | <copy todir="${base.plugins}"> |
---|
161 | <fileset file="${jar.name}" /> |
---|
162 | </copy> |
---|
163 | <echo>Copied '${jar.name}' to '${base.plugins}'.</echo> |
---|
164 | </target> |
---|
165 | |
---|
166 | <target name="update-version"> |
---|
167 | <echo>Setting version to: ${version}</echo> |
---|
168 | |
---|
169 | <echo>extensions.xml</echo> |
---|
170 | <replaceregexp |
---|
171 | file="META-INF/extensions.xml" |
---|
172 | match="<version>.*</version>" |
---|
173 | replace="<version>${version}</version>" |
---|
174 | encoding="UTF-8" |
---|
175 | /> |
---|
176 | <replaceregexp |
---|
177 | file="META-INF/extensions.xml" |
---|
178 | match="<min-base-version>.*</min-base-version>" |
---|
179 | replace="<min-base-version>${depend.base-version}</min-base-version>" |
---|
180 | encoding="UTF-8" |
---|
181 | /> |
---|
182 | <echo>Don't forget to commit the changes to the subversion repository!</echo> |
---|
183 | </target> |
---|
184 | |
---|
185 | |
---|
186 | <target |
---|
187 | name="download-lib" |
---|
188 | description="Download base-core-${depend.base-version}.jar and base-webclient-${depend.base-version}.jar." |
---|
189 | > |
---|
190 | <echo> |
---|
191 | ------------------------------------------------------- |
---|
192 | NOTE! You may specifiy a different download location by |
---|
193 | creating the file './build.properties' and |
---|
194 | setting 'depend.jars' to the URL to download from. |
---|
195 | ------------------------------------------------------- |
---|
196 | </echo> |
---|
197 | <download-lib file="base-core-${depend.base-version}.jar" /> |
---|
198 | <download-lib file="base-webclient-${depend.base-version}.jar" /> |
---|
199 | </target> |
---|
200 | |
---|
201 | <macrodef name="download-lib" description="Download BASE core JAR files"> |
---|
202 | <attribute name="file" /> |
---|
203 | <sequential> |
---|
204 | <get |
---|
205 | dest="lib/compile/@{file}" |
---|
206 | src="${depend.jars}/@{file}" |
---|
207 | usetimestamp="true" |
---|
208 | verbose="true" |
---|
209 | ignoreerrors="true" |
---|
210 | /> |
---|
211 | </sequential> |
---|
212 | </macrodef> |
---|
213 | </project> |
---|