Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit af680c3

Browse files
update README
1 parent ff3d3cb commit af680c3

File tree

1 file changed

+79
-10
lines changed

1 file changed

+79
-10
lines changed

standalone/README.md

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,66 @@
22

33
## Introduction
44

5-
This Maven project produces a standalone command line executable `tvdformat.jar` for the SQLcl script [`format.js`](../sqlcl/format.js). Optionally it produces also a GraalVM native image `tvdformat`.
5+
This Maven project produces a standalone command line executable `tvdformat.jar` for the SQLcl script [`format.js`](../sqlcl/format.js). Optionally it produces also a GraalVM [native image](https://www.graalvm.org/reference-manual/native-image/) `tvdformat`.
66

7-
The startup time of standalone JAR file and the native image are identical since the image still requires a JDK to execute. However, it is faster than running `format.js` from SQLcl.
7+
The startup time of standalone JAR file and the native image are similar since the image still requires a JDK to execute. However, it is faster than running `format.js` from SQLcl.
88

99
This project contains JUnit tests for
1010

1111
- the SQLDev/SQLcl formatter settings `trivadis_advanced_format.xml` and `trivadis_custom_format.arbori`
1212
- the SQLcl script `format.js`
1313
- the SQLcl command `tvdformat`
14-
- the standalone executable `tvdformat`
14+
- the standalone exectable `tvdformat`
1515

16-
The project requires a JDK 17, but it produces a Java 8 JAR file. A GraalVM JDK is required only if you want to produce a native image.
16+
The project requires a JDK 17, but it produces a Java 8 executable JAR file. A GraalVM JDK is required only if you want to build a [native image](https://www.graalvm.org/reference-manual/native-image/).
17+
18+
## Running the Standalone Formatter
19+
20+
### Configure Logging
21+
22+
Optionally, you can define the following environment variables:
23+
24+
Variable | Description
25+
-------- | -----------
26+
`TVDFORMAT_LOGGING_CONF_FILE` | Path to a [java.util.logging](https://docs.oracle.com/en/java/javase/17/core/java-logging-overview.html#GUID-B83B652C-17EA-48D9-93D2-563AE1FF8EDA) configuration file. Fully qualified or relative paths are supported. [This file](src/test/resources/logging.conf) is used for tests.
27+
`TVDFORMAT_DEBUG` | `true` enables Arbori debug messages.
28+
`TVDFORMAT_TIMING` |`true` enables Arbori query/callback timing messages.
29+
30+
### Executable JAR
31+
32+
The `tvdformat.jar` is a shaded, executable JAR. This means it contains all dependend Java classes. However, it still needs a JDK 8 or higher.
33+
34+
To run it, open a terminal window and type
35+
36+
```
37+
java -jar tvdformat.jar
38+
```
39+
40+
The parameters are the same as for the [SQLcl command `tvdformat`](../sqlcl/README.md#register-script-formatjs-as-sqlcl-command-tvdformat). Except for formatting the SQLcl buffer, of course.
41+
42+
### Native Image
43+
44+
A native image is a platform specific executable. The following images can be produced with a GraalVM JDK 17:
45+
46+
OS | amd64)? | aarch64? | Requires JDK 8+? | No JDK required?
47+
------- | ------- | -------- | ---------------- | ----------------
48+
macOS | yes | no | yes | yes
49+
Linux | yes | yes | yes | yes
50+
Windows | yes | no | yes | yes
51+
52+
Currently there is no way to produce an ARM based (aarch64) native image for macOS and Windows. This reduces the possible combinations from 12 to 8 native images. Native images are not part of a release. You have to build them yourself as described [below](#how-to-build).
53+
54+
Native images produced with the `--force-fallback` option have a size of around 14 MB. They require a JDK 8+ at runtime and are considered stable.
55+
56+
Native images produced with the `--no-fallback` option have a size of around 500 MB. They do not require a JDK at runtime. Due to the absence of automatic tests, these images are considered experimental.
57+
58+
To run a native image open a terminal window and type
59+
60+
```
61+
./tvdformat
62+
```
63+
64+
The parameters are the same as for the [executable JAR](#executable-jar).
1765

1866
## How to Build
1967

@@ -25,12 +73,33 @@ The project requires a JDK 17, but it produces a Java 8 JAR file. A GraalVM JDK
2573
6. Clone the plsql-formatter-settings repository
2674
7. Open a terminal window in the plsql-formatter-settings root folder and type
2775

28-
cd standalone
76+
```
77+
cd standalone
78+
```
79+
80+
8. Run Maven build by the following command
81+
82+
```
83+
mvn -Dsqlcl.libdir=/usr/local/bin/sqlcl/lib clean package
84+
```
85+
86+
Amend the parameter `sqlcl.libdir` to match the path of the lib directory of your SQLcl installation. This folder is used to reference libraries such as `dbtools-common.jar` which contains the formatter and its dependencies. These libraries are not available in public Maven repositories.
87+
88+
You can define the following optional parameters:
2989
30-
6. Run maven build by the following command
90+
| Parameter | Value | Meaning |
91+
| -------------------------- | ------- | ------- |
92+
| `skip.native` | `true` | Do not produce a native image (default) |
93+
| | `false` | Produce a native image |
94+
| `native.image.fallback` | `no` | Produce a native image of about 14 MB which requires a JDK at runtime (default) |
95+
| | `force` | Produce a native image of about 500 MB that runs without JDK |
96+
| `skipTests` | `true` | Run tests (default) |
97+
| | `false` | Do not run tests |
98+
| `disable.logging` | `true` | Disable logging message during test run (default) |
99+
| | `false` | Enable logging message during test run |
31100
32-
mvn -Dsqlcl.libdir=/usr/local/bin/sqlcl/lib -Dskip.native=false clean package
101+
Here's a fully qualified example to produce a native image:
33102
34-
Amend the parameter `sqlcl.libdir` to match the path of the lib directory of you SQLcl installation. This folder is used to reference the `dbtools-common.jar` library (containing the formatter and its dependencies) which is not available in public Maven repositories.
35-
36-
When you specifiy the parameter `-Dskip.native=false` a native image for your platform is created. When you pass the value `true` (default) then no native image is produced.
103+
```
104+
mvn -Dsqlcl.libdir=/usr/local/bin/sqlcl/lib -Dskip.native=false -Dnative.image.fallback=no -DskipTests=true -Ddisable.logging=true clean package
105+
```

0 commit comments

Comments
 (0)