|
59 | 59 | </resource> |
60 | 60 | </resources> |
61 | 61 | <plugins> |
| 62 | + <plugin> |
| 63 | + <groupId>com.googlecode.addjars-maven-plugin</groupId> |
| 64 | + <artifactId>addjars-maven-plugin</artifactId> |
| 65 | + <version>1.0.5</version> |
| 66 | + <executions> |
| 67 | + <execution> |
| 68 | + <goals> |
| 69 | + <goal>add-jars</goal> |
| 70 | + </goals> |
| 71 | + <configuration> |
| 72 | + <resources> |
| 73 | + <resource> |
| 74 | + <directory>${sqlcl.libdir}</directory> |
| 75 | + <includes> |
| 76 | + <include>**/dbtools-common.jar</include> |
| 77 | + </includes> |
| 78 | + </resource> |
| 79 | + </resources> |
| 80 | + </configuration> |
| 81 | + </execution> |
| 82 | + </executions> |
| 83 | + </plugin> |
62 | 84 | <plugin> |
63 | 85 | <groupId>org.apache.maven.plugins</groupId> |
64 | 86 | <version>3.8.1</version> |
|
70 | 92 | </plugin> |
71 | 93 | <plugin> |
72 | 94 | <groupId>org.apache.maven.plugins</groupId> |
73 | | - <artifactId>maven-jar-plugin</artifactId> |
74 | | - <version>3.2.0</version> |
75 | | - <configuration> |
76 | | - <finalName>${project.artifactId}</finalName> |
77 | | - <archive> |
78 | | - <addMavenDescriptor>false</addMavenDescriptor> |
79 | | - <manifest> |
80 | | - <addClasspath>true</addClasspath> |
81 | | - <useUniqueVersions>false</useUniqueVersions> |
82 | | - <classpathPrefix>lib/</classpathPrefix> |
83 | | - <mainClass>com.trivadis.plsql.formatter.TvdFormat</mainClass> |
84 | | - <addDefaultImplementationEntries>true</addDefaultImplementationEntries> |
85 | | - </manifest> |
86 | | - <manifestEntries> |
87 | | - <Class-Path>lib/dbtools-common-21.2.0.jar</Class-Path> |
88 | | - </manifestEntries> |
89 | | - </archive> |
90 | | - </configuration> |
91 | | - </plugin> |
92 | | - <plugin> |
93 | | - <groupId>org.apache.maven.plugins</groupId> |
94 | | - <artifactId>maven-dependency-plugin</artifactId> |
95 | | - <version>3.1.1</version> |
| 95 | + <artifactId>maven-shade-plugin</artifactId> |
| 96 | + <version>3.2.4</version> |
96 | 97 | <executions> |
97 | 98 | <execution> |
98 | | - <id>copy-dependencies</id> |
99 | 99 | <phase>package</phase> |
100 | 100 | <goals> |
101 | | - <goal>copy-dependencies</goal> |
| 101 | + <goal>shade</goal> |
102 | 102 | </goals> |
103 | | - <configuration> |
104 | | - <outputDirectory>target/lib</outputDirectory> |
105 | | - <overWriteReleases>false</overWriteReleases> |
106 | | - <overWriteSnapshots>true</overWriteSnapshots> |
107 | | - <overWriteIfNewer>true</overWriteIfNewer> |
108 | | - <excludeTransitive>false</excludeTransitive> |
109 | | - <includeScope>compile</includeScope> |
110 | | - <stripVersion>false</stripVersion> |
111 | | - </configuration> |
112 | 103 | </execution> |
113 | 104 | </executions> |
114 | | - </plugin> |
115 | | - <plugin> |
116 | | - <groupId>org.apache.maven.plugins</groupId> |
117 | | - <artifactId>maven-surefire-plugin</artifactId> |
118 | | - <version>2.22.2</version> |
119 | 105 | <configuration> |
120 | | - <includes> |
121 | | - <include>**/*.java</include> |
122 | | - </includes> |
| 106 | + <finalName>${artifactId}</finalName> |
| 107 | + <shadedArtifactAttached>false</shadedArtifactAttached> |
| 108 | + <transformers> |
| 109 | + <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> |
| 110 | + <transformer |
| 111 | + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> |
| 112 | + <manifestEntries> |
| 113 | + <Main-Class>com.trivadis.plsql.formatter.TvdFormat</Main-Class> |
| 114 | + <Class-Path>.</Class-Path> |
| 115 | + </manifestEntries> |
| 116 | + </transformer> |
| 117 | + </transformers> |
| 118 | + <filters> |
| 119 | + <filter> |
| 120 | + <!-- remove conflicting resources (not required) --> |
| 121 | + <artifact>*:*</artifact> |
| 122 | + <excludes> |
| 123 | + <exclude>META-INF/MANIFEST.MF</exclude> |
| 124 | + <exclude>module-info.class</exclude> |
| 125 | + <exclude>META-INF/versions/**</exclude> |
| 126 | + </excludes> |
| 127 | + </filter> |
| 128 | + <filter> |
| 129 | + <!-- include required packages for formatter --> |
| 130 | + <artifact>*:*dbtools-common*</artifact> |
| 131 | + <includes> |
| 132 | + <include>oracle/dbtools/app/**</include> |
| 133 | + <include>oracle/dbtools/arbori/**</include> |
| 134 | + <include>oracle/dbtools/parser/**</include> |
| 135 | + <include>oracle/dbtools/raptor/*</include> |
| 136 | + <include>oracle/dbtools/raptor/utils/**</include> |
| 137 | + <include>oracle/dbtools/util/**</include> |
| 138 | + </includes> |
| 139 | + </filter> |
| 140 | + <filter> |
| 141 | + <!-- include all classes and resources from this project --> |
| 142 | + <artifact>*:tvdformat</artifact> |
| 143 | + <includes> |
| 144 | + <include>**</include> |
| 145 | + </includes> |
| 146 | + </filter> |
| 147 | + </filters> |
123 | 148 | </configuration> |
124 | 149 | </plugin> |
125 | 150 | <plugin> |
|
136 | 161 | </executions> |
137 | 162 | <configuration> |
138 | 163 | <skip>${skip.native}</skip> |
139 | | - <imageName>tvdformat</imageName> |
140 | | - <!-- "-language:js -no-fallback" leads to a runtime error: |
141 | | - Exception in thread "main" javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: TypeError: Access to host class java.lang.String is not allowed or does not exist. |
142 | | - at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.toScriptException(GraalJSScriptEngine.java:483) |
143 | | - at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:460) |
144 | | - at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:400) |
145 | | - at com.trivadis.plsql.formatter.TvdFormat.run(TvdFormat.java:40) |
146 | | - at com.trivadis.plsql.formatter.TvdFormat.main(TvdFormat.java:46) |
147 | | - Caused by: org.graalvm.polyglot.PolyglotException: TypeError: Access to host class java.lang.String is not allowed or does not exist. |
148 | | - at <js>.:program(<eval>:19) |
149 | | - at org.graalvm.polyglot.Context.eval(Context.java:375) |
150 | | - at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) |
| 164 | + <imageName>${project.artifactId}</imageName> |
| 165 | + <mainClass>com.trivadis.plsql.formatter.TvdFormat</mainClass> |
| 166 | + <!-- Creating a native image with "-language:js -no-fallback -H:ReflectionConfigurationFiles=..." |
| 167 | + was e dead end. There were various issues, such as |
| 168 | + - different behavior between JS/Java Strings and their methods |
| 169 | + - laborious identification of classes used via reflection |
| 170 | + - long build times (~280 seconds) |
| 171 | + - very large image size (437MB) |
| 172 | + Therefore, creating a native image which requires a JDK was much simpler. |
| 173 | + The drawback is a slower startup time. However, loading 437MB is not fast ether, at least the first time. |
151 | 174 | --> |
152 | 175 | <buildArgs> |
153 | 176 | -H:IncludeResources=.* --force-fallback |
|
0 commit comments