1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: building.xml,v 1.15 2005/05/26 23:22:06 fredt Exp $ -->
<appendix id="building-appendix">
<title id="building-title">Building HSQLDB</title>
<appendixinfo>
<authorgroup>
<author>
<firstname>Fred</firstname>
<surname>Toussi</surname>
<affiliation>
<orgname>HSQLDB Development Group</orgname>
</affiliation>
<email>ft@cluedup.com</email>
</author>
</authorgroup>
<edition>$Revision: 1.15 $</edition>
<pubdate>$Date: 2005/05/26 23:22:06 $</pubdate>
<keywordset>
<keyword>Hsqldb</keyword>
<keyword>Building</keyword>
<keyword>Ant</keyword>
</keywordset>
</appendixinfo>
<section>
<title>Purpose</title>
<para>From 1.8.0, the supplied <filename>hsqldb.jar</filename> file is
built with Java 1.5. If you want to run the engine under JDK1.3 or
earlier, you should rebuild the jar with Ant.</para>
</section>
<section>
<title>Building with Ant, from the Apache Jakarta Project</title>
<titleabbrev>Building with Ant</titleabbrev>
<para>Ant (Another Neat Tool) is used for building hsqldb. The version
currently used to test the build script is 1.6.1 but versions since 1.5.1
should also be compatible.</para>
<section>
<title>Obtaining Ant</title>
<para>Ant is a part of the Jakarta/Apache Project.</para>
<itemizedlist>
<listitem>
<para>
<ulink url="http://ant.apache.org">Home of the Apache Ant
project</ulink>
</para>
</listitem>
<listitem>
<para>The <ulink
url="http://ant.apache.org/manual/install.html#installing">
Installing Ant</ulink> page of the <ulink
url="http://ant.apache.org/manual">Ant Manual </ulink>. Follow the
directions for your platform.</para>
</listitem>
</itemizedlist>
</section>
<section>
<title>Building Hsqldb with Ant</title>
<para>Once you have unpacked the zip package for hsqldb, under the
<filename>/hsqldb</filename> folder, in <filename>/build</filename>
there is a <filename>build.xml</filename> file that builds the
<filename>hsqldb.jar</filename> with Ant (Ant must be already
installed). To use it, change to <filename>/build</filename> then
type:</para>
<informalexample>
<screen> ant -projecthelp</screen>
</informalexample>
<para>This displays the available ant targets, which you can supply as
command line arguments to ant. These include</para>
<variablelist>
<varlistentry>
<term>hsqldb</term>
<listitem>
<para>to make the <filename>hsqldb.jar</filename></para>
</listitem>
</varlistentry>
<varlistentry>
<term>explainjars</term>
<listitem>
<para>Lists all targets which build jar files, with an explanation
of the purposes of the different jars.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>clean</term>
<listitem>
<para>to clean up the /classes directory that is created</para>
</listitem>
</varlistentry>
<varlistentry>
<term>cleanall</term>
<listitem>
<para>to remove the old jar as well</para>
</listitem>
</varlistentry>
<varlistentry>
<term>javadoc</term>
<listitem>
<para>to build javadoc</para>
</listitem>
</varlistentry>
<varlistentry>
<term>hsqldbmain</term>
<listitem>
<para>to build a smaller jar for HSQLDB that does not contain
utilities</para>
</listitem>
</varlistentry>
<varlistentry>
<term>hsqljdbc</term>
<listitem>
<para>to build an extremely small jar containing only the
client-side JDBC driver (does not support direct connection to
HSQLDB URLs of the form jdbc:hsldb:mem:*, jdbc:hsqldb:file:*, nor
jdbc:hsqldb:res:*).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>hsqldbmin</term>
<listitem>
<para>to build a small jar that supports HSQLDB URLs of the form
jdbc:hsqldb:mem:*, jdbc:hsqld:file*, jdbc:hsqldb:res:*; but not
network URLs like jdbc:hsql* or jdbc:http*.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>hsqldbtest</term>
<listitem>
<para>to build a larger jar for hsqldb that contains tests</para>
</listitem>
</varlistentry>
<varlistentry>
<term>...</term>
<listitem>
<para>Many more targets are available. Run <literal>ant
-projecthelp</literal> and <literal>ant
explainjars</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
<para>HSQLDB can be built in any combination of three JRE (Java Runtime
Environment) versions and many jar file sizes. The smallest jar
size(<filename>hsqljdbc.jar</filename>) contains only the HSQLDB JDBC
Driver client. The default size (<filename>hsqldb.jar</filename>) also
contains server mode support and the utilities. The largest size
(<filename>hsqldbtest.jar</filename>)includes some test classes as well.
Before building the <filename>hsqldbtest.jar</filename> package, you
should download the junit jar from <ulink url="http://www.junit.org" />
and put it in the <filename>/lib</filename> directory, alongside
<filename>servlet.jar</filename>, which is included in the .zip
package.</para>
<para>Just run <literal>ant explainjars</literal> for a concise list of
all available jar files.</para>
<para>If you want your code built for debugging, as opposed to high
performance, make a file named <filename>build.properties</filename> in
your build directory with the contents <informalexample>
<screen>build.debug: true</screen>
</informalexample>The resulting Java binaries will be larger and
slower, but exception stack traces will contain source code line
numbers, which can be extremely useful for debugging.</para>
<para>The preferred method of rebuilding the jar is with Ant. After
installing Ant on your system use the following command from the
<filename>/build</filename> directory:</para>
<informalexample>
<screen>ant explainjars</screen>
</informalexample>
<para>The command displays a list of different options for building
different sizes of the HSQLDB Jar. The default is built using:</para>
<example>
<title>Buiding the standard Hsqldb jar file with Ant</title>
<screen>ant hsqldb</screen>
</example>
<para>The Ant method always builds a jar with the JDK that is used by
Ant and specified in its JAVA_HOME environment variable. Building with
JDK 1.4.x or 1.5.x will result in a jar that is not backward compatible.
</para>
<para>From version 1.7.2, use of JDK 1.1.x is not recommended for
building the JAR, even for running under JDK 1.1.x -- use JDK 1.3.1 for
compatibility with 1.1.x. This is done in the following way. JDK 1.3.1
should be used as the JAVA_HOME for ant. You then issue the following
commands. The first command will make the sources compatible with JDK
1.3, the second command modifies the sources further so that the
compiled result can run under jdk 1.1 as well. The third command builds
the jar.<informalexample>
<screen>ant switchtojdk12
ant switchtojava1target
ant hsqldb
</screen>
</informalexample></para>
</section>
</section>
<section>
<title>Building with DOS Batch Files</title>
<para>UNIX users must use Ant to build hsqldb.</para>
<para>For DOS/Windows users, a set of MSDOS batch files is provided as an
example. These files produce only the default jar size. The path and
classpath variables for the JDK should of course be set before running any
of the batch files. These files are not currently maintained and will
probably need some additions and changes to work correctly. Please see the
build.xml file for up-to-date file</para>
<para>If you are compiling for JDK's other than 1.4.x, you should use the
appropriate <filename>switchToJDK11.bat</filename> or
<filename>switchToJDK12.bat</filename> to adapt the source files to the
target JDK before running the appropriate
<filename>buildJDK11.bat</filename> or <filename>buildJDK12.bat</filename>
JDK and JRE versions.</para>
</section>
<section>
<title>Hsqldb CodeSwitcher</title>
<para>CodeSwitcher is a tool to manage different version of Java source
code. It allows to compile HSQLDB for different JDKs. It is something like
a precompiler in C but it works directly on the source code and does not
create intermediate output or extra files.</para>
<para>CodeSwitcher is used internally in HSQLDB build scripts. You do not
have to use it separately to compile HSQLDB.</para>
<para>CodeSwitcher reads the source code of a file, removes comments where
appropriate and comments out the blocks that are not used for a particular
version of the file. This operation is done for all files of a defined
directory, and all subdirectories.</para>
<example>
<title>Example source code before CodeSwitcher is run</title>
<programlisting>
...
//#ifdef JAVA2
properties.store(out,"hsqldb database");
//#else
/*
properties.save(out,"hsqldb database");
*/
//#endif
...</programlisting>
</example>
<para>The next step is to run CodeSwitcher.</para>
<example>
<title>CodeSwitcher command line invocation</title>
<screen>
java org.hsqldb.util.CodeSwitcher . -JAVA2</screen>
</example>
<para>The '.' means the program works on the current directory (all
subdirectories are processed recursively). <literal>-JAVA2</literal> means
the code labelled with JAVA2 must be switched off.</para>
<example>
<title>Source code after CodeSwitcher processing</title>
<programlisting>
...
//#ifdef JAVA2
/*
pProperties.store(out,"hsqldb database");
*/
//#else
pProperties.save(out,"hsqldb database");
//#endif
...</programlisting>
</example>
<para>For detailed information on the command line options run
<classname>java org.hsqldb.util.CodeSwitcher</classname>. Usage examples
can be found in the switchtojdk1*.bat files in the
<filename>/build</filename> directory.</para>
</section>
<section>
<title>Building documentation</title>
<para>To build the User Guide in HTML format, you must have the Docbook
stylesheets installed locally. The Docbook stylesheets are available on
the Internet. On Linux, just install the
<literal>docbook-xsl-stylesheets</literal> rpm. Then add an entry to
<filename>build.properties</filename> in your build directory with
contents like <informalexample>
<screen>docbook.xsl.home: /usr/share/sgml/docbook/docbook-xsl-stylesheets</screen>
</informalexample> Where you specify your local path to the base
directory of your Docbook stylesheet installation. Build like <example>
<title>Building HTML User Guides</title>
<screen>ant docbooks-html
ant docbooks-chunk</screen>
</example></para>
<para>To build the User Guide in PDF format, you must also have the Java
FOP system installed locally. FOP is available for free download on the
Internet. Add an entry to <filename>build.properties</filename> in your
build directory with contents like <informalexample>
<screen>fop.home /usr/local/fop-0.20.5</screen>
</informalexample> Where you specify your local path to the base
directory of your FOP installation. <example>
<title>Building User Guides in all formats</title>
<screen>ant docbook</screen>
</example> Don't pay too much attention to error messages by FOP,
because they are really warnings, but do check the output. If there are
problems with the PDF output, try using a newer version of FOP.</para>
<important>
<para>By default, your docs will fail to build if you do not have
Internet connectivity. This is because our primary Docbook source file
references the Docbook DTDs via Internet URL. You can build without
Internet connectivity by installing the Docbook DTDs and editing our
primary Docbook source file. Docbook is available on the Internet. On
Linux, just install the <literal>docbook-dtds</literal> or
<literal>docbook</literal> rpm. Then make one edit to the file
<filename>docsrc/guide/guide.xml</filename> in your HSQLDB distribution.
Change the line containing <screen>"http://www.oasis-open.org/docbook/xml/4.2CR1/docbookx.dtd" [</screen>
to <screen>"file:///usr/share/xml/docbook/schema/dtd/4.2/docbookx.dtd" [</screen>
where the second filepath is the path to the
<filename>docbookx.dtd</filename> file within your Docbook
installation.</para>
</important>
</section>
</appendix>
|