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

Commit 000820a

Browse files
Merge pull request #252 from Trivadis/feature/issue-251-sqldev-231
Support SQLcl 23.1.0 and SQLDev 23.1.0
2 parents 2860597 + e417a2b commit 000820a

17 files changed

Lines changed: 1197 additions & 767 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This repository provides formatter settings for the [coding style rules](https:/
66

77
Settings are primarily provided for
88

9-
- [Oracle SQLcl, Version 22.4.0](https://www.oracle.com/tools/downloads/sqlcl-downloads.html)
10-
- [Oracle SQL Developer, Version 22.2.1](https://www.oracle.com/tools/downloads/sqldev-downloads.html) (requires `dbtools-common.jar` from SQLcl 22.4.0, however, this breaks the code completion feature)
9+
- [Oracle SQLcl, Version 23.1.0](https://www.oracle.com/tools/downloads/sqlcl-downloads.html)
10+
- [Oracle SQL Developer, Version 23.1.0](https://www.oracle.com/tools/downloads/sqldev-downloads.html)
1111

1212
These settings have been defined and tested with the product versions mentioned above. They might not work in other versions.
1313

settings/sql_developer/trivadis_custom_format.arbori

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
include "std.arbori"
1818

1919
/**
20-
* Lightweight Formatter for SQL Developer and SQLcl, version 22.4.1-SNAPSHOT
20+
* Lightweight Formatter for SQL Developer and SQLcl, version 23.1.0-SNAPSHOT
2121
* The idea is to keep the code formatted "as is" and apply chosen formatting rules only.
2222
*
2323
* The Arbori program is processed from top to bottom.
@@ -1876,7 +1876,7 @@ a15_various:
18761876
[node) insert_into_clause & [node^^) multi_table_insert
18771877
| [node) subquery & [node^) multi_table_insert
18781878
| [node) subprg_property
1879-
| [node) ')' & [node^) create_view#___0
1879+
| [node) ')' & [node^) create_view1___2
18801880
| [node) ')' & [node^) create_materialized_view2___0
18811881
;
18821882

@@ -1900,7 +1900,7 @@ a15_is_or_as:
19001900
;
19011901

19021902
a15_view_column_alias:
1903-
[parent) create_view#___0
1903+
[parent) create_view1___2
19041904
& [node) alias_in_out_constraints
19051905
& parent < node
19061906
;
@@ -1932,7 +1932,7 @@ a15_line_break_before:
19321932
-- --------------------------------------------------------------------------------------------------------------------
19331933

19341934
a14_line_break_after:
1935-
[node) 'AS' & [node^) create_view#
1935+
[node) 'AS' & [node^) create_view1
19361936
| [node) 'AS' & [node^) create_materialized_view
19371937
-> {
19381938
var node = tuple.get("node");
@@ -2417,7 +2417,7 @@ o10_join_clause_break_keywords:
24172417
& ![keyword-1) 'CROSS'
24182418
& ![keyword-1) 'NATURAL'
24192419
& ![keyword-1) outer_join_type
2420-
& ![keyword-1) "inner_cross_join_clause"___0
2420+
& ![keyword-1) "inner_cross_join_clause___0"
24212421
--| [keyword) 'PARTITION'
24222422
| [keyword) 'ON'
24232423
| [keyword) 'USING'
@@ -2960,8 +2960,8 @@ r2_case_expression_plsql:
29602960
;
29612961

29622962
r2_view:
2963-
[node) create_view#___0
2964-
| [node) subquery & [node^) create_view#
2963+
[node) create_view1___2
2964+
| [node) subquery & [node^) create_view1
29652965
;
29662966

29672967
r2_materialized_view:
@@ -3048,7 +3048,7 @@ r2_decrement_left_margin:
30483048
| [node^) xmltable
30493049
| [node^) json_table
30503050
| [node^) JSON_columns_clause
3051-
| [node^) create_view#___0
3051+
| [node^) create_view1___2
30523052
| [node^) create_materialized_view2___0
30533053
| [node^) insert_into_clause___0
30543054
| [node^) par_expr_list

sqlcl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ We recommend you download, clone, or fork this repository when you plan to use [
2828
However, [`format.js`](format.js) also works as a standalone script. Here's the usage:
2929

3030
```
31-
Trivadis PL/SQL & SQL Formatter (format.js), version 22.4.0
31+
Trivadis PL/SQL & SQL Formatter (format.js), version 23.1.0
3232
3333
usage: script format.js <rootPath> [options]
3434

sqlcl/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var javaSqlEarley = Java.type("oracle.dbtools.parser.plsql.SqlEarley");
5151
var javaProgram = Java.type("oracle.dbtools.arbori.Program");
5252

5353
var getVersion = function() {
54-
return "22.4.1-SNAPSHOT";
54+
return "23.1.0-SNAPSHOT";
5555
}
5656

5757
var getFiles = function (rootPath, extensions, ignoreMatcher) {

standalone/README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,63 @@ To run a native image open a terminal window and type
4949

5050
The parameters are the same as for the [executable JAR](#executable-jar).
5151

52+
## Important: Native Images Do not Work Anymore
53+
54+
Starting with SQLcl 23.1.0 it is not possible to build native images on all platforms anymore.
55+
The reason is that the underlying parser uses AWT/Swing components (for whatever reason).
56+
AWT/Swing components are supported on AMD/Linux platforms only by GraalVM.
57+
As a result this build process will produce a non-working native image on most platforms.
58+
59+
You will see the following stacktrace similar to the following when running the resulting native image:
60+
61+
```
62+
at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:120)
63+
at java.base@17.0.6/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
64+
at java.base@17.0.6/java.lang.Runtime.loadLibrary0(Runtime.java:818)
65+
at java.base@17.0.6/java.lang.System.loadLibrary(System.java:1989)
66+
at java.desktop@17.0.6/java.awt.Toolkit$2.run(Toolkit.java:1388)
67+
at java.desktop@17.0.6/java.awt.Toolkit$2.run(Toolkit.java:1386)
68+
at java.base@17.0.6/java.security.AccessController.executePrivileged(AccessController.java:168)
69+
at java.base@17.0.6/java.security.AccessController.doPrivileged(AccessController.java:318)
70+
at java.desktop@17.0.6/java.awt.Toolkit.loadLibraries(Toolkit.java:1385)
71+
at java.desktop@17.0.6/java.awt.Toolkit.initStatic(Toolkit.java:1423)
72+
at java.desktop@17.0.6/java.awt.Toolkit.<clinit>(Toolkit.java:1397)
73+
at java.desktop@17.0.6/java.awt.Component.<clinit>(Component.java:624)
74+
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
75+
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
76+
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
77+
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
78+
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
79+
at oracle.dbtools.parser.Visual.<init>(Visual.java:404)
80+
at oracle.dbtools.parser.Grammar.parseGrammarFile(Grammar.java:172)
81+
at oracle.dbtools.parser.Grammar.parseGrammarFile(Grammar.java:152)
82+
at oracle.dbtools.arbori.Program.getRules(Program.java:277)
83+
at oracle.dbtools.arbori.Program.getArboriParser(Program.java:187)
84+
at oracle.dbtools.arbori.Program.compile(Program.java:330)
85+
at oracle.dbtools.arbori.Program.compile(Program.java:319)
86+
at oracle.dbtools.arbori.Program.compile(Program.java:316)
87+
at oracle.dbtools.app.XML2Table.<init>(XML2Table.java:70)
88+
at oracle.dbtools.app.Persist2XML.<init>(Persist2XML.java:48)
89+
at oracle.dbtools.app.Persist2XML.read(Persist2XML.java:95)
90+
at <js>.configure(<eval>:104)
91+
at <js>.getConfiguredFormatter(<eval>:161)
92+
at <js>.run(<eval>:727)
93+
at <js>.:program(<eval>:803)
94+
at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:399)
95+
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)
96+
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:420)
97+
at com.trivadis.plsql.formatter.TvdFormat.run(TvdFormat.java:36)
98+
at com.trivadis.plsql.formatter.TvdFormat.main(TvdFormat.java:49)
99+
```
100+
101+
This is really sad. However, there is nothing we can do.
102+
We have to wait until the SQL Developer team decides to provide a parser that does not require AWT/Swing components (as in previous versions)
103+
or until the GraalVM team provides a native-image build process that works on all platforms with AWT/Swing.
104+
See also [macOS: no awt in java.library.path](https://github.com/oracle/graal/issues/4124).
105+
52106
## How to Build
53107

54-
1. [Download](https://www.oracle.com/tools/downloads/sqlcl-downloads.html) and install SQLcl 22.4.0
108+
1. [Download](https://www.oracle.com/tools/downloads/sqlcl-downloads.html) and install SQLcl 23.1.0
55109
2. [Download](https://github.com/graalvm/graalvm-ce-builds/releases) and install the GraalVM JDK 17 22.3.1
56110
3. Go to the `bin` directory of the GraalVM JDK and run `./gu install js native-image visualvm`. For native image on Windows you need to [download](https://visualstudio.microsoft.com/downloads/) Visual Studio Community 2022 and install the C++ compiler. Use `x64 Native Tools Command Prompt for VS 2022` to get a terminal window with the correct environment.
57111
4. [Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.9.1

standalone/install_sqlcl_libs.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ if ! test -f "${SQLCL_LIBDIR}/dbtools-common.jar"; then
1515
fi
1616

1717
# define common Maven properties
18-
SQLCL_VERSION="22.4.0"
18+
SQLCL_VERSION="23.1.0"
1919

2020
# install JAR files in local Maven repository, these libs are not available in public Maven repositories
21-
mvn install:install-file -Dfile=$SQLCL_LIBDIR/dbtools-common.jar \
21+
mvn install:install-file -Dfile=$SQLCL_LIBDIR/dbtools-common.jar -DgeneratePom=true \
2222
-DgroupId=oracle.dbtools -DartifactId=dbtools-common -Dversion=$SQLCL_VERSION -Dpackaging=jar
23-
mvn install:install-file -Dfile=$SQLCL_LIBDIR/dbtools-sqlcl.jar \
23+
mvn install:install-file -Dfile=$SQLCL_LIBDIR/dbtools-sqlcl.jar -DgeneratePom=true \
2424
-DgroupId=oracle.dbtools -DartifactId=dbtools-sqlcl -Dversion=$SQLCL_VERSION -Dpackaging=jar
25-
mvn install:install-file -Dfile=$SQLCL_LIBDIR/xmlparserv2_sans_jaxp_services.jar \
25+
mvn install:install-file -Dfile=$SQLCL_LIBDIR/xmlparserv2_sans_jaxp_services.jar -DgeneratePom=true \
2626
-DgroupId=oracle.xml -DartifactId=xmlparserv2-sans-jaxp-services -Dversion=$SQLCL_VERSION -Dpackaging=jar
27-
mvn install:install-file -Dfile=$SQLCL_LIBDIR/orai18n.jar \
27+
mvn install:install-file -Dfile=$SQLCL_LIBDIR/orai18n.jar -DgeneratePom=true \
2828
-DgroupId=oracle.i18n -DartifactId=orai18n -Dversion=$SQLCL_VERSION -Dpackaging=jar
29-
mvn install:install-file -Dfile=$SQLCL_LIBDIR/orai18n-mapping.jar \
29+
mvn install:install-file -Dfile=$SQLCL_LIBDIR/orai18n-mapping.jar -DgeneratePom=true \
3030
-DgroupId=oracle.i18n -DartifactId=orai18n-mapping -Dversion=$SQLCL_VERSION -Dpackaging=jar
31-
mvn install:install-file -Dfile=$SQLCL_LIBDIR/orajsoda.jar \
31+
mvn install:install-file -Dfile=$SQLCL_LIBDIR/orajsoda.jar -DgeneratePom=true \
3232
-DgroupId=oracle.soda -DartifactId=orajsoda -Dversion=$SQLCL_VERSION -Dpackaging=jar

standalone/pom.xml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
<!-- The Basics -->
77
<groupId>com.trivadis.plsql.formatter</groupId>
88
<artifactId>tvdformat</artifactId>
9-
<version>22.4.1-SNAPSHOT</version>
9+
<version>23.1.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<jdk.version>11</jdk.version>
1414
<jdk.test.version>17</jdk.test.version>
15-
<sqlcl.version>22.4.0</sqlcl.version>
15+
<sqlcl.version>23.1.0</sqlcl.version>
1616
<graalvm.version>22.3.1</graalvm.version>
17-
<native.maven.plugin.version>0.9.20</native.maven.plugin.version>
17+
<native.maven.plugin.version>0.9.21</native.maven.plugin.version>
1818
<reflections.version>0.10.2</reflections.version>
1919
<slf4j.version>2.0.7</slf4j.version>
2020
<javassist.version>3.29.2-GA</javassist.version>
@@ -152,6 +152,15 @@
152152
</testResource>
153153
</testResources>
154154
<plugins>
155+
<plugin>
156+
<!-- workaround for https://issues.apache.org/jira/browse/MRESOURCES-269 -->
157+
<!-- see also https://issues.apache.org/jira/browse/MRESOURCES-237 -->
158+
<!-- need to copy content of file not symbolic link, still an issue in 3.3.1 -->
159+
<!-- cannot use <filtering>true</filtering> because windows-1252.sql failed with MalformedInputException -->
160+
<groupId>org.apache.maven.plugins</groupId>
161+
<artifactId>maven-resources-plugin</artifactId>
162+
<version>2.7</version>
163+
</plugin>
155164
<plugin>
156165
<groupId>org.apache.maven.plugins</groupId>
157166
<artifactId>maven-shade-plugin</artifactId>
@@ -399,10 +408,18 @@
399408
<mainClass>com.trivadis.plsql.formatter.TvdFormat</mainClass>
400409
<!-- configuration files in META-INF are detected by the native image builder -->
401410
<buildArgs combine.children="append">
411+
<buildArg>-Djava.awt.headless=false</buildArg>
402412
<buildArg>--features=com.trivadis.plsql.formatter.RuntimeReflectionRegistrationFeature</buildArg>
403413
<buildArg>--language:js</buildArg>
404414
<buildArg>--no-fallback</buildArg>
415+
<!-- overriding default configuration in META-INF, to process list of files-->
405416
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
417+
<buildArg>-H:JNIConfigurationFiles=src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/jni-config.json</buildArg>
418+
<buildArg>-H:PredefinedClassesConfigurationFiles=src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/predefined-classes-config.json</buildArg>
419+
<buildArg>-H:DynamicProxyConfigurationFiles=src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/proxy-config.json,src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/proxy-config-manual.json</buildArg>
420+
<buildArg>-H:ReflectionConfigurationFiles=src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/reflect-config.json,src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/reflect-config-manual.json</buildArg>
421+
<buildArg>-H:ResourceConfigurationFiles=src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/resource-config.json</buildArg>
422+
<buildArg>-H:SerializationConfigurationFiles=src/main/resources/META-INF/native-image/com.trivadis.plsql.formatter/tvdformat/serialization-config.json</buildArg>
406423
</buildArgs>
407424
</configuration>
408425
</plugin>

0 commit comments

Comments
 (0)