manuelbl / SwissQRBill

Java library for Swiss QR bill payment slips (aka QR-Rechnung)
https://www.codecrete.net/qrbill
MIT License
155 stars 37 forks source link

Maven native build proposal #93

Open charizardmatok opened 2 months ago

charizardmatok commented 2 months ago

Could the library be adapted to work in maven native build? Currently it's not working due to java.awt not being fully supported: org.jboss.resteasy.spi.UnhandledException: java.lang.InternalError: java.lang.ClassNotFoundException: sun.awt.X11FontManager

manuelbl commented 2 months ago

Do you mean a build for GraalVM?

The backend of the demo application for the library (https://github.com/manuelbl/SwissQRBillDemo/tree/master, published at https://www.codecrete.net/qrbill/) actually uses a native build. It is built on top of the Quarkus framework.

AWT is known to be a challenge with GraalVM. The Quarkus people built a special addition that takes care of it. In the demo application, it's configured here: https://github.com/manuelbl/SwissQRBillDemo/blob/master/service/pom.xml#L54

If you are also using Quarkus, that should help. If you don't use it, the extension might help you to understand what's needed to get it running.

charizardmatok commented 2 months ago

Exactly, GraalVM build. I am running quarkus also. I believe I once tried to use quarkus-awt dependency to bypass this, but it resulted in the same error. I will try it again just for good measure.

manuelbl commented 2 months ago

You might want to look at this commit. It contains the relevant changes. The changes for Java classes in the namespace net.codecrete.qrbill.web... are relevant for the demo application only and not for the library in general.

charizardmatok commented 2 months ago

Yes, I understand that, and I tried it following the changes made in the provided commit, but I am still getting an issue with a bunch of classes being inited at build time instead of runtime. Error: Classes that should be initialized at run time got initialized during image building: ...