plsql-formatter-settings icon indicating copy to clipboard operation
plsql-formatter-settings copied to clipboard

Building native image on Windows 11 - mvn failure

Open jgebal opened this issue 2 years ago • 16 comments

Hi @PhilippSalvisberg

I have followed your instructions for building native image but when running it on Windows 11 platform I face some issues,

I run the command from windows CMD.

C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone>mvn -X -Dskip.native=false -DskipTests=true -Ddisable.logging=true clean package > clean_package.log

See the clean_package.log file for full log.

The error is:

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 109: C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target/tvdformat-22.2.2-SNAPSHOT.jar:C:\Users\JacekGebal\.m2\repository/oracle/dbtools/dbtools-common/22.2.1/dbtools-common-22.2.1.jar:C:\Users\JacekGebal\.m2\repository/org/reflections/reflections/0.10.2/reflections-0.10.2.jar:C:\Users\JacekGebal\.m2\repository/org/javassist/javassist/3.29.0-GA/javassist-3.29.0-GA.jar:C:\Users\JacekGebal\.m2\repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:C:\Users\JacekGebal\.m2\repository/org/slf4j/slf4j-jdk14/1.7.36/slf4j-jdk14-1.7.36.jar:C:\Users\JacekGebal\.m2\repository/org/graalvm/js/js-scriptengine/22.2.0/js-scriptengine-22.2.0.jar

It could be due to a mix of windows style \ and linux/mac style / path delimiters in the path as mentioned here

Do you have any suggestion on how to solve this?

jgebal avatar Aug 17 '22 11:08 jgebal

I have tried using ${path.separator} instead of : and ${file.separator} instead of / in the pom file But still get the same error, even thought the Windows-style path looks good.

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 111: C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\tvdformat-22.2.2-SNAPSHOT.jar;C:\Users\JacekGebal\.m2\repository\oracle\dbtools\dbtools-common\22.2.1\dbtools-common-22.2.1.jar;C:\Users\JacekGebal\.m2\repository\org\reflections\reflections\0.10.2\reflections-0.10.2.jar;C:\Users\JacekGebal\.m2\repository\org\javassist\javassist\3.29.0-GA\javassist-3.29.0-GA.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-jdk14\1.7.36\slf4j-jdk14-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\graalvm\js\js-scriptengine\22.2.0\js-scriptengine-22.2.0.jar

The odd thing is that it is complaining about : at position 111 which is the second occurrence C:\...

jgebal avatar Aug 17 '22 12:08 jgebal

After I have disabled the entire <classpath> section it began to work.

<!--                                    <classpath>-->
<!--                                        ${project.build.directory}${file.separator}${project.build.finalName}.jar${path.separator}${settings.localRepository}${file.separator}oracle${file.separator}dbtools${file.separator}dbtools-common${file.separator}${sqlcl.version}${file.separator}dbtools-common-${sqlcl.version}.jar${path.separator}${settings.localRepository}${file.separator}org${file.separator}reflections${file.separator}reflections${file.separator}${reflections.version}${file.separator}reflections-${reflections.version}.jar${path.separator}${settings.localRepository}${file.separator}org${file.separator}javassist${file.separator}javassist${file.separator}${javassist.version}${file.separator}javassist-${javassist.version}.jar${path.separator}${settings.localRepository}${file.separator}org${file.separator}slf4j${file.separator}slf4j-api${file.separator}${slf4j.version}${file.separator}slf4j-api-${slf4j.version}.jar${path.separator}${settings.localRepository}${file.separator}org${file.separator}slf4j${file.separator}slf4j-jdk14${file.separator}${slf4j.version}${file.separator}slf4j-jdk14-${slf4j.version}.jar${path.separator}${settings.localRepository}${file.separator}org${file.separator}graalvm${file.separator}js${file.separator}js-scriptengine${file.separator}${graalvm.version}${file.separator}js-scriptengine-${graalvm.version}.jar-->
<!--                                    </classpath>-->

jgebal avatar Aug 17 '22 12:08 jgebal

[2/7] Performing analysis...  [*******]                                                                 (42.1s @ 4.32GB)
  20,565 (94.63%) of 21,733 classes reachable
  36,962 (66.44%) of 55,631 fields reachable
 109,625 (68.59%) of 159,829 methods reachable
  12,304 ( 7.70%) of 159,829 methods included for runtime compilation
     516 classes, 1,461 fields, and 5,896 methods registered for reflection
      74 classes,    54 fields, and    66 methods registered for JNI access
       4 native libraries: crypt32, ncrypt, psapi, version
[3/7] Building universe...                                                                               (3.2s @ 5.18GB)
[4/7] Parsing methods...      [***]                                                                      (5.4s @ 2.25GB)
[5/7] Inlining methods...     [****]                                                                     (3.2s @ 4.48GB)
[6/7] Compiling methods...    [*****]                                                                   (26.5s @ 3.50GB)
[7/7] Creating image...                                                                                  (9.5s @ 4.35GB)
  67.47MB (34.32%) for code area:    88,473 compilation units
 128.42MB (65.33%) for image heap:  775,443 objects and 3,742 resources
 687.53KB ( 0.34%) for other data
 196.55MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 packages in code area:                               Top 10 object types in image heap:
   8.25MB com.oracle.truffle.js.builtins                      51.36MB byte[] for embedded resources
   2.64MB com.oracle.truffle.js.nodes.access                  19.10MB byte[] for code metadata
   2.23MB com.oracle.truffle.js.nodes.binary                   8.68MB byte[] for graph encodings
   2.04MB com.oracle.truffle.js.builtins.temporal              5.81MB java.lang.Class
   1.61MB com.oracle.truffle.polyglot                          4.62MB java.lang.String
   1.37MB java.util                                            4.44MB char[]
   1.20MB com.oracle.truffle.host                              4.41MB byte[] for general heap data
   1.04MB com.oracle.truffle.js.runtime.builtins               4.39MB byte[] for java.lang.String
   1.04MB com.oracle.truffle.api.interop                       2.01MB com.oracle.svm.graal.meta.SubstrateField
   1.01MB com.ibm.icu.text                                     1.89MB c.o.truffle.api.nodes.NodeClassImpl$NodeFieldData
  44.38MB for 476 more packages                               21.16MB for 4550 more object types
------------------------------------------------------------------------------------------------------------------------
                        5.6s (5.1% of total time) in 59 GCs | Peak RSS: 7.55GB | CPU load: 9.20
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\awt.dll (jdk_lib)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\fontmanager.dll (jdk_lib)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\freetype.dll (jdk_lib)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\java.dll (jdk_lib_shim)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\javaaccessbridge.dll (jdk_lib)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\javajpeg.dll (jdk_lib)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\jawt.dll (jdk_lib)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\jvm.dll (jdk_lib_shim)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\lcms.dll (jdk_lib)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\tvdformat.build_artifacts.txt (txt)
 C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\tvdformat.exe (executable)
========================================================================================================================

jgebal avatar Aug 17 '22 12:08 jgebal

Well, that was not so good either. The EXE build ok but it doesn't really work.

C:\Users\JacekGebal>cd DataGripProjects\plsql-formatter-settings\standalone\target

C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target>tvdformat.exe ACCOUNT.sql
Exception in thread "main" javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: SyntaxError: <eval>:1:0 Expected an operand but found .
../../../../sqlcl/format.js
^

        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.toScriptException(GraalJSScriptEngine.java:503)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:480)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:420)
        at com.trivadis.plsql.formatter.TvdFormat.run(TvdFormat.java:36)
        at com.trivadis.plsql.formatter.TvdFormat.main(TvdFormat.java:49)
Caused by: org.graalvm.polyglot.PolyglotException: SyntaxError: <eval>:1:0 Expected an operand but found .
../../../../sqlcl/format.js
^

        at org.graalvm.polyglot.Context.eval(Context.java:399)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)
        ... 3 more

I must say I'm walking quite blind here as I'm totally inexperienced in this topic. Perhaps it's wrong build libraries version or some other problems. No clue really.

If you would have some time to help me out - it would be great. Thanks Jacek

jgebal avatar Aug 17 '22 13:08 jgebal

It works on macOS. I cannot test it on Windows at the moment, but I suspect, that this line is as you suspected platform specific.

: (colon) is used as path separator. That's ok for all *nix systems. But on Windows it's ; (semicolon). Could you please change this line on your system to:

${project.build.directory}/${project.build.finalName}.jar;${settings.localRepository}/oracle/dbtools/dbtools-common/${sqlcl.version}/dbtools-common-${sqlcl.version}.jar;${settings.localRepository}/org/reflections/reflections/${reflections.version}/reflections-${reflections.version}.jar;${settings.localRepository}/org/javassist/javassist/${javassist.version}/javassist-${javassist.version}.jar;${settings.localRepository}/org/slf4j/slf4j-api/${slf4j.version}/slf4j-api-${slf4j.version}.jar;${settings.localRepository}/org/slf4j/slf4j-jdk14/${slf4j.version}/slf4j-jdk14-${slf4j.version}.jar;${settings.localRepository}/org/graalvm/js/js-scriptengine/${graalvm.version}/js-scriptengine-${graalvm.version}.jar

and try again?

It should be possible to make the POM truly platform independent.

Thx.

PhilippSalvisberg avatar Aug 17 '22 13:08 PhilippSalvisberg

Unfortunately that doesn't work :/

[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.371 s
[INFO] Finished at: 2022-08-17T17:58:41+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build (build-native) on project tvdformat: Execution build-native of goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build failed: Illegal char <:> at index 111: C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\tvdformat-22.2.2-SNAPSHOT.jar;C:\Users\JacekGebal\.m2\repository\oracle\dbtools\dbtools-common\22.2.1\dbtools-common-22.2.1.jar;C:\Users\JacekGebal\.m2\repository\org\reflections\reflections\0.10.2\reflections-0.10.2.jar;C:\Users\JacekGebal\.m2\repository\org\javassist\javassist\3.29.0-GA\javassist-3.29.0-GA.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-jdk14\1.7.36\slf4j-jdk14-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\graalvm\js\js-scriptengine\22.2.0\js-scriptengine-22.2.0.jar -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build (build-native) on project tvdformat: Execution build-native of goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build failed: Illegal char <:> at index 111: C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\tvdformat-22.2.2-SNAPSHOT.jar;C:\Users\JacekGebal\.m2\repository\oracle\dbtools\dbtools-common\22.2.1\dbtools-common-22.2.1.jar;C:\Users\JacekGebal\.m2\repository\org\reflections\reflections\0.10.2\reflections-0.10.2.jar;C:\Users\JacekGebal\.m2\repository\org\javassist\javassist\3.29.0-GA\javassist-3.29.0-GA.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-jdk14\1.7.36\slf4j-jdk14-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\graalvm\js\js-scriptengine\22.2.0\js-scriptengine-22.2.0.jar
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution build-native of goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build failed: Illegal char <:> at index 111: C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\tvdformat-22.2.2-SNAPSHOT.jar;C:\Users\JacekGebal\.m2\repository\oracle\dbtools\dbtools-common\22.2.1\dbtools-common-22.2.1.jar;C:\Users\JacekGebal\.m2\repository\org\reflections\reflections\0.10.2\reflections-0.10.2.jar;C:\Users\JacekGebal\.m2\repository\org\javassist\javassist\3.29.0-GA\javassist-3.29.0-GA.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-jdk14\1.7.36\slf4j-jdk14-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\graalvm\js\js-scriptengine\22.2.0\js-scriptengine-22.2.0.jar
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 111: C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\tvdformat-22.2.2-SNAPSHOT.jar;C:\Users\JacekGebal\.m2\repository\oracle\dbtools\dbtools-common\22.2.1\dbtools-common-22.2.1.jar;C:\Users\JacekGebal\.m2\repository\org\reflections\reflections\0.10.2\reflections-0.10.2.jar;C:\Users\JacekGebal\.m2\repository\org\javassist\javassist\3.29.0-GA\javassist-3.29.0-GA.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\slf4j\slf4j-jdk14\1.7.36\slf4j-jdk14-1.7.36.jar;C:\Users\JacekGebal\.m2\repository\org\graalvm\js\js-scriptengine\22.2.0\js-scriptengine-22.2.0.jar
    at sun.nio.fs.WindowsPathParser.normalize (WindowsPathParser.java:182)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:153)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse (WindowsPath.java:92)
    at sun.nio.fs.WindowsFileSystem.getPath (WindowsFileSystem.java:232)
    at java.nio.file.Path.of (Path.java:147)
    at java.nio.file.Paths.get (Paths.java:69)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.lambda$populateClasspath$5 (AbstractNativeMojo.java:367)
    at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:197)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1625)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:499)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:921)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:682)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.populateClasspath (AbstractNativeMojo.java:369)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.getClasspath (AbstractNativeMojo.java:378)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.getBuildArgs (AbstractNativeMojo.java:211)
    at org.graalvm.buildtools.maven.AbstractNativeMojo.buildImage (AbstractNativeMojo.java:393)
    at org.graalvm.buildtools.maven.NativeBuildMojo.execute (NativeBuildMojo.java:91)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone>

jgebal avatar Aug 17 '22 15:08 jgebal

Ok. Thanks. I have to setup an environment to reproduce this myself. It looks like the colon in the drive letter is now the problem.

PhilippSalvisberg avatar Aug 17 '22 15:08 PhilippSalvisberg

As a workaround can comment out the classpath argument as follows:

                            <execution>
                                <id>build-native</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>package</phase>
                                <!-- Override classpath to ensure js is not added to the classpath.
                                     This reduces resuting image size by 24 MB (162 MB instead of 186 MB). -->
                                <configuration>
                                    <!--classpath>
                                        ${project.build.directory}/${project.build.finalName}.jar:${settings.localRepository}/oracle/dbtools/dbtools-common/${sqlcl.version}/dbtools-common-${sqlcl.version}.jar:${settings.localRepository}/org/reflections/reflections/${reflections.version}/reflections-${reflections.version}.jar:${settings.localRepository}/org/javassist/javassist/${javassist.version}/javassist-${javassist.version}.jar:${settings.localRepository}/org/slf4j/slf4j-api/${slf4j.version}/slf4j-api-${slf4j.version}.jar:${settings.localRepository}/org/slf4j/slf4j-jdk14/${slf4j.version}/slf4j-jdk14-${slf4j.version}.jar:${settings.localRepository}/org/graalvm/js/js-scriptengine/${graalvm.version}/js-scriptengine-${graalvm.version}.jar
                                    </classpath-->
                                    <buildArgs combine.children="append">
                                        <!-- including all charsets works for build-native only!?! -->
                                        <buildArg>-H:+AddAllCharsets</buildArg>
                                    </buildArgs>
                                </configuration>
                            </execution>
                        </executions>

As mentioned in the comment the classpath just leads to a smaller native executable.

PhilippSalvisberg avatar Aug 17 '22 15:08 PhilippSalvisberg

Looks like comma (,) works The property is defined as java.util.List(String)

                                    <classpath>
                                        ${project.build.directory}${file.separator}${project.build.finalName}.jar,${settings.localRepository}${file.separator}oracle${file.separator}dbtools${file.separator}dbtools-common${file.separator}${sqlcl.version}${file.separator}dbtools-common-${sqlcl.version}.jar,${settings.localRepository}${file.separator}org${file.separator}reflections${file.separator}reflections${file.separator}${reflections.version}${file.separator}reflections-${reflections.version}.jar,${settings.localRepository}${file.separator}org${file.separator}javassist${file.separator}javassist${file.separator}${javassist.version}${file.separator}javassist-${javassist.version}.jar,${settings.localRepository}${file.separator}org${file.separator}slf4j${file.separator}slf4j-api${file.separator}${slf4j.version}${file.separator}slf4j-api-${slf4j.version}.jar,${settings.localRepository}${file.separator}org${file.separator}slf4j${file.separator}slf4j-jdk14${file.separator}${slf4j.version}${file.separator}slf4j-jdk14-${slf4j.version}.jar,${settings.localRepository}${file.separator}org${file.separator}graalvm${file.separator}js${file.separator}js-scriptengine${file.separator}${graalvm.version}${file.separator}js-scriptengine-${graalvm.version}.jar
                                    </classpath>

jgebal avatar Aug 17 '22 15:08 jgebal

This is really strange. I assume it is a maven plugin (datatype) issue

jgebal avatar Aug 17 '22 15:08 jgebal

Interesting. I tried to use , inststead of : and it built successfully. The native image worked as expected.

Does it work now on Windows 11 as well?

PhilippSalvisberg avatar Aug 17 '22 15:08 PhilippSalvisberg

No. I get the following issue:

PS C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target> .\tvdformat.exe
Exception in thread "main" javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: SyntaxError: <eval>:1:0 Expected an operand but found .
../../../../sqlcl/format.js
^

        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.toScriptException(GraalJSScriptEngine.java:503)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:480)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:420)
        at com.trivadis.plsql.formatter.TvdFormat.run(TvdFormat.java:36)
        at com.trivadis.plsql.formatter.TvdFormat.main(TvdFormat.java:49)
Caused by: org.graalvm.polyglot.PolyglotException: SyntaxError: <eval>:1:0 Expected an operand but found .
../../../../sqlcl/format.js
^

        at org.graalvm.polyglot.Context.eval(Context.java:399)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)
        ... 3 more
PS C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target>

jgebal avatar Aug 17 '22 16:08 jgebal

I was building in VS 2022 v17.3.0 command prompt.

**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.3.0
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools>

jgebal avatar Aug 17 '22 16:08 jgebal

Seems that copy & paste of formatter.js file from sqlcl to standalone/src/main/resourece did the trick. Another small glitch but now I get:

PS C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target> .\tvdformat.exe SPM_ACCOUNT_OLD.Table.sql

file or directory C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target\SPM_ACCOUNT_OLD.Table.sql does not exist.

Trivadis PL/SQL & SQL Formatter (tvdformat), version 22.2.2-SNAPSHOT

usage: tvdformat <rootPath> [options]

mandatory argument: (one of the following)
  <rootPath>      file or path to directory containing files to format (content will be replaced!)
  <config.json>   configuration file in JSON format (must end with .json)

options:
  ext=<ext>       comma separated list of file extensions to process, e.g. ext=sql,pks,pkb
  mext=<ext>      comma separated list of markdown file extensions to process, e.g. ext=md,mdown
  xml=<file>      path to the file containing the xml file for advanced format settings
                  xml=default uses default advanced settings included in sqlcl
                  xml=embedded uses advanced settings defined in format.js
  arbori=<file>   path to the file containing the Arbori program for custom format settings
                  arbori=default uses default Arbori program included in sqlcl
  ignore=<file>   path to the file containing file patterns to ignore. Patterns are defined
                  per line. Each line represent a glob pattern. Empty lines and lines starting
                  with a hash sign (#) are ignored.
  serr=<scope>    scope of syntax errors to be reported. By default all errors are reported.
                  serr=none reports no syntax errors
                  serr=all reports all syntax errors
                  serr=ext reports syntax errors for files defined with ext option
                  serr=mext reports syntax errors for files defined with mext option
  --help, -h,     print this help screen and exit
  --version, -v   print version and exit
PS C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target>

jgebal avatar Aug 17 '22 16:08 jgebal

And it actually formats.

PS C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target> .\tvdformat.exe scratch_1.json ext=sql,prc,fnc,pks,pkb,trg,vw,tps,tpb,tbp,plb,pls,rcv,spc,typ,aqt,aqp,ctx,dbl,tab,dim,snp,con,collt,seq,syn,grt,sp,spb,sps,pck mext=markdown,mdown,mkdn,md xml=trivadis_advanced_format.xml arbori=trivadis_custom_format.arbori

Formatting file 1 of 2: IMPEXP_CONFIGURATION_TO_CSV.pkb... done.
Formatting file 2 of 2: IMPEXP_CONFIGURATION_TO_CSV.pks... done.
PS C:\Users\JacekGebal\DataGripProjects\plsql-formatter-settings\standalone\target>

The start-up speed is amazing!

Not it can be used as a pre-commit hook actually.

jgebal avatar Aug 17 '22 17:08 jgebal

@PhilippSalvisberg Is the solution for issue #228 provided in #231 applicable for native image?

If not, is there anything I can/should do to make native image work with UTF-8 files on Windows?

jgebal avatar Aug 17 '22 18:08 jgebal

Seems that copy & paste of formatter.js file from sqlcl to standalone/src/main/resourece did the trick.

https://github.com/Trivadis/plsql-formatter-settings/blob/sqlcl-22.2.1/standalone/src/main/resources/format.js is a symbolic link.

Should work under Windows. But not per default. See https://github.com/git-for-windows/git/wiki/Symbolic-Links for more information.

I've run git clone -c core.symlinks=true https://github.com/Trivadis/plsql-formatter-settings.git as Administrator in a command window. Works.

Is the solution for issue https://github.com/Trivadis/plsql-formatter-settings/issues/228 provided in https://github.com/Trivadis/plsql-formatter-settings/pull/231 applicable for native image?

Yes. It should work out-of-the box.

PhilippSalvisberg avatar Aug 17 '22 20:08 PhilippSalvisberg