Debian Codegraph @

src/docsrc/html/build.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <!--
3 Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
4 and the EPL 1.0 (https://h2database.com/html/license.html).
5 Initial Developer: H2 Group
6 -->
7 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
8 <head>
9 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
10 <meta name="viewport" content="width=device-width, initial-scale=1" />
11 <title>
12 Build
13 </title>
14 <link rel="stylesheet" type="text/css" href="stylesheet.css" />
15 <!-- [search] { -->
16 <script type="text/javascript" src="navigation.js"></script>
17 </head><body onload="frameMe();">
18 <table class="content"><tr class="content"><td class="content"><div class="contentDiv">
19 <!-- } -->
20
21 <h1 id="build_index">Build</h1>
22 <a href="#portability">
23 Portability</a><br />
24 <a href="#environment">
25 Environment</a><br />
26 <a href="#building">
27 Building the Software</a><br />
28 <a href="#maven2">
29 Using Maven 2</a><br />
30 <a href="#native_image">
31 Native Image</a><br />
32 <a href="#using_eclipse">
33 Using Eclipse</a><br />
34 <a href="#translating">
35 Translating</a><br />
36 <a href="#providing_patches">
37 Submitting Source Code Changes</a><br />
38 <a href="#support">
39 Reporting Problems or Requests</a><br />
40 <a href="#automated">
41 Automated Build</a><br />
42 <a href="#railroad">
43 Generating Railroad Diagrams</a><br />
44
45 <h2 id="portability">Portability</h2>
46 <p>
47 This database is written in Java and therefore works on many platforms.
48 </p>
49
50 <h2 id="environment">Environment</h2>
51 <p>
52 To run this database, a Java Runtime Environment (JRE) version 8 or higher is required.
53 It it also possible to compile a standalone executable with
54 experimental <a href="#native_image">native image</a> build.
55 </p>
56 <p>
57 To create the database executables, the following software stack was used.
58 To use this database, it is not required to install this software however.
59 </p>
60 <ul><li>Mac OS X and Windows
61 </li><li><a href="https://www.oracle.com/technetwork/java/javase/downloads/index.html">Oracle JDK Version 8</a>
62 </li><li><a href="https://www.eclipse.org">Eclipse</a>
63 </li><li>Eclipse Plugins:
64 <a href="https://checkstyle.github.io/eclipse-cs/">Eclipse Checkstyle Plug-in</a>,
65 <a href="https://www.eclemma.org">EclEmma Java Code Coverage</a>
66 </li><li><a href="https://www.mozilla.com/firefox">Mozilla Firefox</a>
67 </li><li><a href="https://www.openoffice.org">OpenOffice</a>
68 </li><li><a href="https://nsis.sourceforge.net">NSIS</a> (Nullsoft Scriptable Install System)
69 </li><li><a href="https://maven.apache.org">Maven</a>
70 </li></ul>
71
72 <h2 id="building">Building the Software</h2>
73 <p>
74 You need to install a JDK, for example the Oracle JDK version 8.
75 Ensure that Java binary directory is included in the <code>PATH</code> environment variable, and that
76 the environment variable <code>JAVA_HOME</code> points to your Java installation.
77 On the command line, go to the directory <code>h2</code> and execute the following command:
78 </p>
79 <pre>
80 build -?
81 </pre>
82 <p>
83 For Linux and OS X, use <code>./build.sh</code> instead of <code>build</code>.
84 </p>
85 <p>
86 You will get a list of targets. If you want to build the <code>jar</code> file, execute (Windows):
87 </p>
88 <pre>
89 build jar
90 </pre>
91 <p>
92 To run the build tool in shell mode, use the command line option <code>-</code>:
93 </p>
94 <pre>
95 ./build.sh -
96 </pre>
97
98 <h3>Using Apache Lucene</h3>
99 <p>
100 Apache Lucene 8.5.2 is used for testing.
101 </p>
102
103 <h2 id="maven2">Using Maven 2</h2>
104 <h3>Using a Central Repository</h3>
105 <p>
106 You can include the database in your Maven 2 project as a dependency.
107 Example:
108 </p>
109 <pre>
110 &lt;dependency&gt;
111 &lt;groupId&gt;com.h2database&lt;/groupId&gt;
112 &lt;artifactId&gt;h2&lt;/artifactId&gt;
113 &lt;version&gt;${version}&lt;/version&gt;
114 &lt;/dependency&gt;
115 </pre>
116 <p>
117 New versions of this database are first uploaded to http://hsql.sourceforge.net/m2-repo/ and then automatically
118 synchronized with the main <a href="https://repo1.maven.org/maven2/com/h2database/h2/">Maven repository</a>;
119 however after a new release it may take a few hours before they are available there.
120 </p>
121 <h3>Maven Plugin to Start and Stop the TCP Server</h3>
122 <p>
123 A Maven plugin to start and stop the H2 TCP server is available from
124 <a href="https://github.com/ljnelson/h2-maven-plugin">Laird Nelson at GitHub</a>.
125 To start the H2 server, use:
126 </p>
127 <pre>
128 mvn com.edugility.h2-maven-plugin:1.0-SNAPSHOT:spawn
129 </pre>
130 <p>
131 To stop the H2 server, use:
132 </p>
133 <pre>
134 mvn com.edugility.h2-maven-plugin:1.0-SNAPSHOT:stop
135 </pre>
136
137 <h3>Using Snapshot Version</h3>
138 <p>
139 To build a <code>h2-*-SNAPSHOT.jar</code> file and upload it the to the local Maven 2 repository, execute the following command:
140 </p>
141 <pre>
142 build mavenInstallLocal
143 </pre>
144 <p>
145 Afterwards, you can include the database in your Maven 2 project as a dependency:
146 </p>
147 <pre>
148 &lt;dependency&gt;
149 &lt;groupId&gt;com.h2database&lt;/groupId&gt;
150 &lt;artifactId&gt;h2&lt;/artifactId&gt;
151 &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
152 &lt;/dependency&gt;
153 </pre>
154
155 <h2 id="native_image">Native Image</h2>
156
157 <p>
158 There is an experimental support for compilation of native executables with native-image tool.
159 To build an executable with H2 install GraalVM and use its updater to get the native-image tool:
160 </p>
161 <pre>
162 gu install native-image
163 </pre>
164 This tool can be used for compilation of native executables:
165 <pre>
166 native-image --no-fallback -jar h2-VERSION.jar h2
167 </pre>
168
169 <p>Known limitations:</p>
170 <ul><li>
171 If <code>--no-fallback</code> parameter was specified, system tray icon may not appear
172 even if <code>-Djava.awt.headless=false</code> parameter of native-image tool was used,
173 because native-image doesn't add all necessary configuration for working GUI.
174 </li><li>
175 If <code>--no-fallback</code> parameter was specified,
176 user-defined functions and triggers need an additional configuration.
177 </li><li>
178 JAVA_OBJECT data type wasn't tested and may not work at all.
179 </li><li>
180 Third-party loggers, ICU4J collators, and fulltext search weren't tested.
181 </li></ul>
182
183 <h2 id="using_eclipse">Using Eclipse</h2>
184 <p>
185 To create an Eclipse project for H2, use the following steps:
186 </p>
187 <ul><li>Install Git and <a href="https://www.eclipse.org">Eclipse</a>.
188 </li><li>Get the H2 source code from Github:<br />
189 <code>git clone https://github.com/h2database/h2database</code>
190 </li><li>Download all dependencies:<br />
191 <code>build.bat download</code>(Windows)<br />
192 <code>./build.sh download</code>(otherwise)<br />
193 </li><li>In Eclipse, create a new Java project from existing source code:
194 <code>File, New, Project, Java Project, Create project from existing source</code>.
195 </li><li>Select the <code>h2</code> folder, click <code>Next</code> and <code>Finish</code>.
196 </li><li>To resolve <code>com.sun.javadoc</code> import statements,
197 you may need to manually add the file <code>&lt;java.home&gt;/../lib/tools.jar</code> to the build path.
198 </li></ul>
199
200 <h2 id="translating">Translating</h2>
201 <p>
202 The translation of this software is split into the following parts:
203 </p>
204 <ul>
205 <li>H2 Console: <code>src/main/org/h2/server/web/res/_text_*.prop</code>
206 </li><li>Error messages: <code>src/main/org/h2/res/_messages_*.prop</code>
207 </li></ul>
208 <p>
209 To translate the H2 Console, start it and select Preferences / Translate.
210 After you are done, send the translated <code>*.prop</code> file to the Google Group.
211 The web site is currently translated using Google.
212 </p>
213
214 <h2 id="providing_patches">Submitting Source Code Changes</h2>
215 <p>
216 If you'd like to contribute bug fixes or new features, please consider the following guidelines to simplify merging them:
217 </p>
218 <ul><li>Only use Java 8 features (do not use Java 9/10/etc) (see <a href="#environment">Environment</a>).
219 </li><li>Follow the coding style used in the project, and use Checkstyle (see above) to verify.
220 For example, do not use tabs (use spaces instead).
221 The checkstyle configuration is in <code>src/installer/checkstyle.xml</code>.
222 </li><li>A template of the Eclipse settings are in
223 <code>src/installer/eclipse.settings/*</code>. If you want to use them,
224 you need to copy them to the <code>.settings</code> directory.
225 The formatting options (<code>eclipseCodeStyle</code>) are also included.
226 </li><li>Please provide test cases and integrate them into the test suite.
227 For Java level tests, see <code>src/test/org/h2/test/TestAll.java</code>.
228 For SQL level tests, see SQL files in <code>src/test/org/h2/test/scripts</code>.
229 </li><li>The test cases should cover at least 90% of the changed and new code;
230 use a code coverage tool to verify that (see above).
231 or use the build target <code>coverage</code>.
232 </li><li>Verify that you did not break other features: run the test cases by executing
233 <code>build test</code>.
234 </li><li>Provide end user documentation if required (<code>src/docsrc/html/*</code>).
235 </li><li>Document grammar changes in <code>src/main/org/h2/res/help.csv</code>
236 </li><li>Provide a change log entry (<code>src/docsrc/html/changelog.html</code>).
237 </li><li>Verify the spelling using <code>build spellcheck</code>. If required
238 add the new words to <code>src/tools/org/h2/build/doc/dictionary.txt</code>.
239 </li><li>Run <code>src/installer/buildRelease</code> to find and fix formatting errors.
240 </li><li>Verify the formatting using <code>build docs</code> and
241 <code>build javadoc</code>.
242 </li><li>Submit changes using GitHub's "pull requests". You'll require a free <a href="https://github.com/">GitHub</a>
243 account. If you are not familiar with pull requests, please read GitHub's
244 <a href="https://help.github.com/articles/using-pull-requests/">Using pull requests</a> page.
245 </li></ul>
246 <p>
247 For legal reasons, patches need to be public in the form of an
248 <a href="https://github.com/h2database/h2database/issues">issue report or attachment</a> or in the form of an email
249 to the <a href="https://groups.google.com/g/h2-database">group</a>.
250 Significant contributions need to include the following statement:
251 </p>
252 <p>
253 "I wrote the code, it's mine, and I'm contributing it to H2 for distribution
254 multiple-licensed under the MPL 2.0, and the EPL 1.0
255 (https://h2database.com/html/license.html)."
256 </p>
257
258 <h2 id="support">Reporting Problems or Requests</h2>
259 <p>
260 Please consider the following checklist if you have a question, want to report a problem,
261 or if you have a feature request:
262 </p>
263 <ul><li>For bug reports, please provide a
264 <a href="http://sscce.org/">short, self contained, correct (compilable), example</a> of the problem.
265 </li><li>Feature requests are always welcome, even if the feature is already on the
266 <a href="https://github.com/h2database/h2database/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement">issue tracker</a>
267 you can comment it.
268 If you urgently need a feature, consider <a href="#providing_patches">providing a patch</a>.
269 </li><li>Before posting problems, check the
270 <a href="faq.html">FAQ</a> and do a <a href="http://google.com">Google search</a>.
271 </li><li>When got an unexpected exception, please try the
272 <a href="https://h2database.com/html/sourceError.html">Error Analyzer tool</a>. If this doesn't help,
273 please report the problem, including the complete error message and stack trace,
274 and the root cause stack trace(s).
275 </li><li>When sending source code, please use a public web clipboard such as
276 <a href="https://pastebin.com/">Pastebin</a> or
277 <a href="https://mysticpaste.com/new">Mystic Paste</a>
278 to avoid formatting problems.
279 Please keep test cases as simple and short as possible,
280 but so that the problem can still be reproduced.
281 As a template, use:
282 <a href="https://github.com/h2database/h2database/tree/master/h2/src/test/org/h2/samples/HelloWorld.java">HelloWorld.java</a>.
283 Method that simply call other methods should be avoided,
284 as well as unnecessary exception handling.
285 Please use the JDBC API and no external tools or libraries.
286 The test should include all required initialization code, and
287 should be started with the main method.
288 </li><li>For large attachments, use a public storage such as
289 <a href="https://www.google.com/drive/">Google Drive</a>.
290 </li><li>Google Group versus issue tracking:
291 Use the
292 <a href="https://groups.google.com/g/h2-database">Google Group</a>
293 for questions or if you are not sure it's a bug.
294 If you are sure it's a bug, you can create an
295 <a href="https://github.com/h2database/h2database/issues">issue</a>,
296 but you don't need to (sending an email to the group is enough).
297 Please note that only few people monitor the issue tracking system.
298 </li><li>For out-of-memory problems, please analyze the problem yourself first,
299 for example using the command line option
300 <code>-XX:+HeapDumpOnOutOfMemoryError</code>
301 (to create a heap dump file on out of memory)
302 and a memory analysis tool such as the
303 <a href="https://www.eclipse.org/mat/">Eclipse Memory Analyzer (MAT)</a>.
304 </li><li>It may take a few days to get an answers. Please do not double post.
305 </li></ul>
306
307 <h2 id="automated">Automated Build</h2>
308 <p>
309 This build process is automated and runs regularly.
310 The build process includes running the tests and code coverage, using the command line
311 <code>./build.sh jar testCI</code>.
312 The results are available on <a href="https://github.com/h2database/h2database/actions?query=workflow%3ACI">CI workflow</a> page.
313 </p>
314
315 <h2 id="railroad">Generating Railroad Diagrams</h2>
316 <p>
317 The railroad diagrams of the <a href="grammar.html">SQL grammar</a> are HTML, formatted as nested tables.
318 The diagrams are generated as follows:
319 </p>
320 <ul><li>The BNF parser (<code>org.h2.bnf.Bnf</code>) reads and parses the BNF from the file <code>help.csv</code>.
321 </li><li>The page parser (<code>org.h2.server.web.PageParser</code>) reads the template HTML file and fills in the diagrams.
322 </li><li>The rail images (one straight, four junctions, two turns) are generated using a simple Java application.
323 </li></ul>
324 <p>
325 To generate railroad diagrams for other grammars, see the package <code>org.h2.jcr</code>.
326 This package is used to generate the SQL-2 railroad diagrams for the JCR 2.0 specification.
327 </p>
328
329 <!-- [close] { --></div></td></tr></table><!-- } --><!-- analytics --></body></html>
330