Hi, i wonder how i can include a file (xsd) the native-image ? I did try -H:IncludeResources='.*/Resource.*txt$ and then try to use (io/resource "Resource.txt") but it doesn't work
I needed to included a resource file on clojure-lsp called CLOJURE_LSP_VERSION
and this way works: https://github.com/clojure-lsp/clojure-lsp/blob/master/resources/META-INF/native-image/clojure-lsp/clojure-lsp/native-image.properties#L8
Here is also an example: https://github.com/clj-kondo/clj-kondo/blob/7bad82031e3b466ece4562baccece587f1d9345e/script/compile#L20
Note that the resource pattern must be relative to your classpath, not your working dir
Wow many thanks ! and you can then use it with io/resource ?
yes
Ok many thanks can't make it work and i have almost the samle structure. I'll see with you compilation parameters if i miss something
Is that dir even on your classpath? Are you able to get it in on the JVM?
It is ok now i found my error ... Many thanks to you both, for the quick help and for the faboulous tools you bring to clojure !!!!
Also i have this code that work with lein run but not once compiled as native-image (InputSource. (http://clojure.java.io/input-stream (.getBytes data)))
** ERROR: **
Exception: #error {
:cause No matching field found: getBytes for class java.lang.String
:via
[{:type java.lang.IllegalArgumentException
:message No matching field found: getBytes for class java.lang.String
:at [clojure.lang.Reflector getInstanceField Reflector.java 397]}]
:trace
[[clojure.lang.Reflector getInstanceField Reflector.java 397]
[clojure.lang.Reflector invokeNoArgInstanceMember Reflector.java 440]
[sm_validator_cli.core$create_xml_doc invokeStatic core.clj 43]
@ouvasam You need to avoid reflection warnings with (set! *warn-on-reflection* true)
Thanks but this does not work too
Typehint seems to work for this part (InputSource. (http://clojure.java.io/input-stream (.getBytes ^java.lang.String data)))
now i have
(InputSource. (<http://clojure.java.io/input-stream|clojure.java.io/input-stream> (.getBytes data))) ** ERROR: **
Exception: #error {
:cause org.apache.xerces.parsers.ObjectFactory
:via
[{:type java.lang.NoClassDefFoundError
:message nil
:at [org.apache.xerces.parsers.ObjectFactory class$ nil -1]}
{:type java.lang.ClassNotFoundException
:message org.apache.xerces.parsers.ObjectFactory
:at [com.oracle.svm.core.hub.ClassForNameSupport forName ClassForNameSupport.java 60]}]
:trace
[[com.oracle.svm.core.hub.ClassForNameSupport forName ClassForNameSupport.java 60]
😭