build.html 14.3 KB
Newer Older
1 2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
3
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
4 5 6 7
and under the Eclipse Public License, Version 1.0
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
8 9
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
Thomas Mueller's avatar
Thomas Mueller committed
10
<meta name="viewport" content="width=device-width, initial-scale=1" />
11
<title>
12
Build
13 14
</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
15 16 17 18 19 20
<!-- [search] { -->
<script type="text/javascript" src="navigation.js"></script>
</head><body onload="frameMe();">
<table class="content"><tr class="content"><td class="content"><div class="contentDiv">
<!-- } -->

21
<h1 id="build_index">Build</h1>
22 23 24 25 26 27 28 29 30 31
<a href="#portability">
    Portability</a><br />
<a href="#environment">
    Environment</a><br />
<a href="#building">
    Building the Software</a><br />
<a href="#build_targets">
    Build Targets</a><br />
<a href="#maven2">
    Using Maven 2</a><br />
Thomas Mueller's avatar
Thomas Mueller committed
32 33
<a href="#using_eclipse">
    Using Eclipse</a><br />
34 35 36
<a href="#translating">
    Translating</a><br />
<a href="#providing_patches">
37
    Submitting Source Code Changes</a><br />
38 39
<a href="#support">
    Reporting Problems or Requests</a><br />
40 41
<a href="#automated">
    Automated Build</a><br />
42 43
<a href="#railroad">
    Generating Railroad Diagrams</a><br />
44

Thomas Mueller's avatar
Thomas Mueller committed
45
<h2 id="portability">Portability</h2>
46 47 48 49
<p>
This database is written in Java and therefore works on many platforms.
</p>

Thomas Mueller's avatar
Thomas Mueller committed
50
<h2 id="environment">Environment</h2>
51
<p>
52
To run this database, a Java Runtime Environment (JRE) version 1.7 or higher is required.
53 54
</p>
<p>
Thomas Mueller's avatar
Thomas Mueller committed
55 56
To create the database executables, the following software stack was used.
To use this database, it is not required to install this software however.
57
</p>
58
<ul><li>Mac OS X and Windows
59
</li><li><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Oracle JDK Version 1.7</a>
60
</li><li><a href="http://www.eclipse.org">Eclipse</a>
61
</li><li>Eclipse Plugins:
Thomas Mueller's avatar
Thomas Mueller committed
62
    <a href="http://subclipse.tigris.org">Subclipse</a>,
63
    <a href="https://checkstyle.github.io/eclipse-cs/">Eclipse Checkstyle Plug-in</a>,
64
    <a href="http://www.eclemma.org">EclEmma Java Code Coverage</a>
65
</li><li><a href="https://www.mozilla.com/firefox">Mozilla Firefox</a>
Thomas Mueller's avatar
Thomas Mueller committed
66
</li><li><a href="http://www.openoffice.org">OpenOffice</a>
67
</li><li><a href="http://nsis.sourceforge.net">NSIS</a> (Nullsoft Scriptable Install System)
Thomas Mueller's avatar
Thomas Mueller committed
68
</li><li><a href="http://maven.apache.org">Maven</a>
69 70
</li></ul>

Thomas Mueller's avatar
Thomas Mueller committed
71
<h2 id="building">Building the Software</h2>
72
<p>
73
You need to install a JDK, for example the Oracle JDK version 1.7 or 1.8.
74 75 76
Ensure that Java binary directory is included in the <code>PATH</code> environment variable, and that
the environment variable <code>JAVA_HOME</code> points to your Java installation.
On the command line, go to the directory <code>h2</code> and execute the following command:
77
</p>
78
<pre>
79 80 81
build -?
</pre>
<p>
82
For Linux and OS X, use <code>./build.sh</code> instead of <code>build</code>.
83 84
</p>
<p>
85
You will get a list of targets. If you want to build the <code>jar</code> file, execute (Windows):
86
</p>
87
<pre>
88 89
build jar
</pre>
90
<p>
91
To run the build tool in shell mode, use the command line option <code>-</code>:
92
</p>
93 94 95
<pre>
./build.sh -
</pre>
96 97 98

<h3>Switching the Source Code</h3>
<p>
99
The source code uses Java 1.7 features.
100
To switch the source code to the installed version of Java, run:
101
</p>
102
<pre>
103 104 105
build switchSource
</pre>

Thomas Mueller's avatar
Thomas Mueller committed
106
<h2 id="build_targets">Build Targets</h2>
107 108 109
<p>
The build system can generate smaller jar files as well. The following targets are currently supported:
</p>
110 111 112 113
<ul><li><code>jarClient</code>
    creates the file <code>h2client.jar</code>. This only contains the JDBC client.
</li><li><code>jarSmall</code>
    creates the file <code>h2small.jar</code>.
114
    This only contains the embedded database. Debug information is disabled.
115 116
</li><li><code>jarJaqu</code>
    creates the file <code>h2jaqu.jar</code>.
117
    This only contains the JaQu (Java Query) implementation. All other jar files do not include JaQu.
118
</li><li><code>javadocImpl</code> creates the Javadocs of the implementation.
119 120
</li></ul>
<p>
121
To create the file <code>h2client.jar</code>, go to the directory <code>h2</code> and execute the following command:
122
</p>
123
<pre>
124 125 126
build jarClient
</pre>

127
<h3>Using Apache Lucene</h3>
Thomas Mueller's avatar
Thomas Mueller committed
128
<p>
129
Apache Lucene 3.6.2 is used for testing.
130
Newer versions may work, however they are not tested.
Thomas Mueller's avatar
Thomas Mueller committed
131 132
</p>

Thomas Mueller's avatar
Thomas Mueller committed
133
<h2 id="maven2">Using Maven 2</h2>
134 135 136 137 138
<h3>Using a Central Repository</h3>
<p>
You can include the database in your Maven 2 project as a dependency.
Example:
</p>
139
<pre>
140 141 142 143 144 145 146 147
&lt;dependency&gt;
    &lt;groupId&gt;com.h2database&lt;/groupId&gt;
    &lt;artifactId&gt;h2&lt;/artifactId&gt;
    &lt;version&gt;${version}&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>
New versions of this database are first uploaded to http://hsql.sourceforge.net/m2-repo/ and then automatically
148 149
synchronized with the main <a href="http://repo2.maven.org/maven2/com/h2database/h2/">Maven repository</a>;
however after a new release it may take a few hours before they are available there.
150
</p>
Thomas Mueller's avatar
Thomas Mueller committed
151 152 153
<h3>Maven Plugin to Start and Stop the TCP Server</h3>
<p>
A Maven plugin to start and stop the H2 TCP server is available from
154
<a href="https://github.com/ljnelson/h2-maven-plugin">Laird Nelson at GitHub</a>.
Thomas Mueller's avatar
Thomas Mueller committed
155 156 157 158 159 160 161 162 163 164 165
To start the H2 server, use:
</p>
<pre>
mvn com.edugility.h2-maven-plugin:1.0-SNAPSHOT:spawn
</pre>
<p>
To stop the H2 server, use:
</p>
<pre>
mvn com.edugility.h2-maven-plugin:1.0-SNAPSHOT:stop
</pre>
166 167 168

<h3>Using Snapshot Version</h3>
<p>
169
To build a <code>h2-*-SNAPSHOT.jar</code> file and upload it the to the local Maven 2 repository, execute the following command:
170
</p>
171
<pre>
172 173 174 175 176
build mavenInstallLocal
</pre>
<p>
Afterwards, you can include the database in your Maven 2 project as a dependency:
</p>
177
<pre>
178 179 180 181 182 183 184
&lt;dependency&gt;
    &lt;groupId&gt;com.h2database&lt;/groupId&gt;
    &lt;artifactId&gt;h2&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt;
</pre>

Thomas Mueller's avatar
Thomas Mueller committed
185 186 187 188
<h2 id="using_eclipse">Using Eclipse</h2>
<p>
To create an Eclipse project for H2, use the following steps:
</p>
189
<ul><li>Install Git and <a href="http://www.eclipse.org">Eclipse</a>.
190 191 192 193 194
</li><li>Get the H2 source code from Github:<br />
    <code>git clone https://github.com/h2database/h2database</code>
</li><li>Download all dependencies:<br />
    <code>build.bat download</code>(Windows)<br />
    <code>./build.sh download</code>(otherwise)<br />
Thomas Mueller's avatar
Thomas Mueller committed
195 196
</li><li>In Eclipse, create a new Java project from existing source code:
    <code>File, New, Project, Java Project, Create project from existing source</code>.
Thomas Mueller's avatar
Thomas Mueller committed
197
</li><li>Select the <code>h2</code> folder, click <code>Next</code> and <code>Finish</code>.
Thomas Mueller's avatar
Thomas Mueller committed
198
</li><li>To resolve <code>com.sun.javadoc</code> import statements,
Thomas Mueller's avatar
Thomas Mueller committed
199 200 201
    you may need to manually add the file <code>&lt;java.home&gt;/../lib/tools.jar</code> to the build path.
</li></ul>

Thomas Mueller's avatar
Thomas Mueller committed
202
<h2 id="translating">Translating</h2>
203 204 205 206
<p>
The translation of this software is split into the following parts:
</p>
<ul>
Thomas Mueller's avatar
Thomas Mueller committed
207 208
<li>H2 Console: <code>src/main/org/h2/server/web/res/_text_*.prop</code>
</li><li>Error messages: <code>src/main/org/h2/res/_messages_*.prop</code>
209 210
</li></ul>
<p>
211
To translate the H2 Console, start it and select Preferences / Translate.
Thomas Mueller's avatar
Thomas Mueller committed
212 213
After you are done, send the translated <code>*.prop</code> file to the Google Group.
The web site is currently translated using Google.
214 215
</p>

216
<h2 id="providing_patches">Submitting Source Code Changes</h2>
217
<p>
218
If you'd like to contribute bug fixes or new features, please consider the following guidelines to simplify merging them:
219
</p>
220
<ul><li>Only use Java 7 features (do not use Java 8/9/etc) (see <a href="#environment">Environment</a>).
221 222
</li><li>Follow the coding style used in the project, and use Checkstyle (see above) to verify.
    For example, do not use tabs (use spaces instead).
223
    The checkstyle configuration is in <code>src/installer/checkstyle.xml</code>.
Thomas Mueller's avatar
Thomas Mueller committed
224 225 226
</li><li>A template of the Eclipse settings are in
    <code>src/installer/eclipse.settings/*</code>. If you want to use them,
    you need to copy them to the <code>.settings</code> directory.
Thomas Mueller's avatar
Thomas Mueller committed
227
    The formatting options (<code>eclipseCodeStyle</code>) are also included.
228
</li><li>Please provide test cases and integrate them into the test suite.
229 230 231
    For Java level tests, see <code>src/test/org/h2/test/TestAll.java</code>.
    For SQL level tests, see <code>src/test/org/h2/test/test.in.txt</code> or
    <code>testSimple.in.txt</code>.
232 233
</li><li>The test cases should cover at least 90% of the changed and new code;
    use a code coverage tool to verify that (see above).
234
    or use the build target <code>coverage</code>.
235
</li><li>Verify that you did not break other features: run the test cases by executing
236 237
    <code>build test</code>.
</li><li>Provide end user documentation if required (<code>src/docsrc/html/*</code>).
238
</li><li>Document grammar changes in <code>src/docsrc/help/help.csv</code>
239 240 241
</li><li>Provide a change log entry (<code>src/docsrc/html/changelog.html</code>).
</li><li>Verify the spelling using <code>build spellcheck</code>. If required
    add the new words to <code>src/tools/org/h2/build/doc/dictionary.txt</code>.
242
</li><li>Run <code>src/installer/buildRelease</code> to find and fix formatting errors.
243 244
</li><li>Verify the formatting using <code>build docs</code> and
    <code>build javadoc</code>.
245 246 247
</li><li>Submit changes using GitHub's "pull requests". You'll require a free <a href="https://github.com/">GitHub</a>
    account. If you are not familiar with pull requests, please read GitHub's
    <a href="https://help.github.com/articles/using-pull-requests/">Using pull requests</a> page.
248
</li></ul>
249
<p>
250 251
For legal reasons, patches need to be public in the form of an
    <a href="https://github.com/h2database/h2database/issues">issue report or attachment</a> or in the form of an email
252
    to the <a href="https://groups.google.com/group/h2-database">group</a>.
253 254
Significant contributions need to include the following statement:
</p>
255
<p>
256
"I wrote the code, it's mine, and I'm contributing it to H2 for distribution
257 258
multiple-licensed under the MPL 2.0, and the EPL 1.0
(http://h2database.com/html/license.html)."
259
</p>
260

261 262
<h2 id="support">Reporting Problems or Requests</h2>
<p>
263
Please consider the following checklist if you have a question, want to report a problem,
264 265
or if  you have a feature request:
</p>
Thomas Mueller's avatar
Thomas Mueller committed
266
<ul><li>For bug reports, please provide a
Thomas Mueller's avatar
Thomas Mueller committed
267 268
    <a href="http://sscce.org/">short, self contained, correct (compilable), example</a> of the problem.
</li><li>Feature requests are always welcome, even if the feature is already on the
269
    <a href="http://www.h2database.com/html/roadmap.html">roadmap</a>. Your mail will help prioritize feature requests.
270
    If you urgently need a feature, consider <a href="#providing_patches">providing a patch</a>.
271
</li><li>Before posting problems, check the
272
    <a href="faq.html">FAQ</a> and do a <a href="http://google.com">Google search</a>.
273
</li><li>When got an unexpected exception, please try the
274
    <a href="http://www.h2database.com/html/sourceError.html">Error Analyzer tool</a>. If this doesn't help,
275
    please report the problem, including the complete error message and stack trace,
276 277
    and the root cause stack trace(s).
</li><li>When sending source code, please use a public web clipboard such as
278
    <a href="https://pastebin.com/">Pastebin</a> or
279 280 281 282
    <a href="http://www.mysticpaste.com/new">Mystic Paste</a>
    to avoid formatting problems.
    Please keep test cases as simple and short as possible,
    but so that the problem can still be reproduced.
283
    As a template, use:
284
    <a href="https://github.com/h2database/h2database/tree/master/h2/src/test/org/h2/samples/HelloWorld.java">HelloWorld.java</a>.
285 286 287 288 289
    Method that simply call other methods should be avoided,
    as well as unnecessary exception handling.
    Please use the JDBC API and no external tools or libraries.
    The test should include all required initialization code, and
    should be started with the main method.
290 291
</li><li>For large attachments, use a public storage such as
    <a href="https://www.google.com/drive/">Google Drive</a>.
292
</li><li>Google Group versus issue tracking:
293
    Use the
294 295
    <a href="http://groups.google.com/group/h2-database">Google Group</a>
    for questions or if you are not sure it's a bug.
296
    If you are sure it's a bug, you can create an
297
    <a href="https://github.com/h2database/h2database/issues">issue</a>,
298 299
    but you don't need to (sending an email to the group is enough).
    Please note that only few people monitor the issue tracking system.
Thomas Mueller's avatar
Thomas Mueller committed
300
</li><li>For out-of-memory problems, please analyze the problem yourself first,
Thomas Mueller's avatar
Thomas Mueller committed
301
    for example using the command line option
Thomas Mueller's avatar
Thomas Mueller committed
302
    <code>-XX:+HeapDumpOnOutOfMemoryError</code>
Thomas Mueller's avatar
Thomas Mueller committed
303
    (to create a heap dump file on out of memory)
Thomas Mueller's avatar
Thomas Mueller committed
304
    and a memory analysis tool such as the
Thomas Mueller's avatar
Thomas Mueller committed
305
    <a href="http://www.eclipse.org/mat">Eclipse Memory Analyzer (MAT)</a>.
306 307 308
</li><li>It may take a few days to get an answers. Please do not double post.
</li></ul>

Thomas Mueller's avatar
Thomas Mueller committed
309
<h2 id="automated">Automated Build</h2>
310
<p>
311
This build process is automated and runs regularly.
312
The build process includes running the tests and code coverage, using the command line
313
<code>./build.sh clean jar coverage -Dh2.ftpPassword=... uploadBuild</code>.
314
The last results are available here:
315
</p>
316 317 318
<ul><li><a href="http://h2database.com/html/testOutput.html">Test Output</a>
</li><li><a href="http://h2database.com/coverage/overview.html">Code Coverage Summary</a>
</li><li><a href="http://h2database.com/coverage/coverage.zip">Code Coverage Details (download, 1.3 MB)</a>
319
</li><li><a href="http://www.h2database.com/automated/news.xml">Build Newsfeed</a>
320 321
</li></ul>

322 323
<h2 id="railroad">Generating Railroad Diagrams</h2>
<p>
Thomas Mueller's avatar
Thomas Mueller committed
324
The railroad diagrams of the <a href="grammar.html">SQL grammar</a> are HTML, formatted as nested tables.
325 326 327 328 329 330 331 332 333 334 335
The diagrams are generated as follows:
</p>
<ul><li>The BNF parser (<code>org.h2.bnf.Bnf</code>) reads and parses the BNF from the file <code>help.csv</code>.
</li><li>The page parser (<code>org.h2.server.web.PageParser</code>) reads the template HTML file and fills in the diagrams.
</li><li>The rail images (one straight, four junctions, two turns) are generated using a simple Java application.
</li></ul>
<p>
To generate railroad diagrams for other grammars, see the package <code>org.h2.jcr</code>.
This package is used to generate the SQL-2 railroad diagrams for the JCR 2.0 specification.
</p>

336 337
<!-- [close] { --></div></td></tr></table><!-- } --><!-- analytics --></body></html>