GraalVM support for Apache Freemarker.
Note
|
see What does this project do for more information. |
Note
|
Whereas Apache Freemarker works on Java 8+, native supports requires Java 11+. |
Just add maven dependency :
<dependency>
<groupId>org.fugerit.java</groupId>
<artifactId>freemarker-native</artifactId>
<version>${freemarkerNativeVersion}</version>
</dependency>
Or gradle one :
implementation("org.fugerit.java:freemarker-native:$freemarkerNativeVersion")
Note
|
project specific native configuration may still be needed (for instance resource and relfect configuration). Here is an example. |
For a local build just run :
gradle build
Optionally piblish to local maven repository :
gradle build publishToMavenLocal
FreeMarker Native is currently based on Apache FreeMarker 2.3.34.
If a different version is needed, add the Apache FreeMarker dependency before FreeMarker native in Maven :
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarkerVersion}</version>
</dependency>
<dependency>
<groupId>org.fugerit.java</groupId>
<artifactId>freemarker-native</artifactId>
<version>${freemarkerNativeVersion}</version>
</dependency>
And for Gradle :
implementation("org.freemarker:freemarker:$freemarkerVersion")
implementation("org.fugerit.java:freemarker-native:$freemarkerNativeVersion") {
exclude("org.freemarker", "freemarker")
}
Note
|
for Gradle, latest version always wins, so if you want a specific versions maybe you will need to set some exclusions. |
Tested version of Apache FreeMarker :
-
2.3.33
-
2.3.34
When building with GraalVM a project including Apache FreeMarker, this could lead to errors like :
Error: Class initialization of freemarker.ext.jython.JythonWrapper failed. This error is reported at image build time because class freemarker.ext.jython.JythonWrapper is registered for linking at image build time by command line and command line. Use the option
'--initialize-at-run-time=freemarker.ext.jython.JythonWrapper'
This projects include the necessary configuration and Method substitution to have it build properly.
Note
|
For more information on how native support has beend added read here. |
A demo project, based on quarkus, is available here :
This project is inspired by the quarkus-freemarker extension (1). I want to thank Quarkus and Quarkus FreeMarker teams.
The main development tool I used is IntelliJ IDEA Ultimate. I want to thank the JetBrains Support for Open-Source Projects program for providing a license.
Note
|
(1) The main difference between this FreeMarker native and quarkus-freemarker is that with this project there are only the basic dependencies needed to run Apache Freemarker. |