Skip to content

Commit

Permalink
Build: Some build cleanup, and documentation regarding static linking…
Browse files Browse the repository at this point in the history
… to _Java9Impl/_Java16Impl using the multi-release JAR format.
  • Loading branch information
ddekany committed Aug 4, 2024
1 parent 3f2d643 commit d03f7f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ Reproducible builds: If the resulting `freemarker.jar` is not identical with the
in the `.buildinfo` file packed into the official source distribution, and also into the Maven "sources" artifact! At
least with identical Java versions, the resulting `freemarker.jar` meant to match exactly.

Note on trying things out with an ad-hoc class that has `main` method: Don't do that, instead write it as a JUnit test.
FreeMarker needs to be loaded from `freemarker.jar` that contains the `META-INF/versions` directory (as per JEP 238,
Multi-Release JAR Files). If you run a test, Gradle ensures that you have an up-to-date `freemarker.jar`, and
that it's in the classpath. Without that, FreeMarker will behave as if you are on a lower Java version.


### Maven-related build tasks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ class FreemarkerModuleDef internal constructor(
.toString()
systemProperty("freemarker.test.resourcesDir", resourcesDestDir)

testClassesDirs = sources.output.classesDirs

// We have to build the jar and depend on that, because we depend on "JEP 238: Multi-Release JAR Files",
// which puts some classes into the jar under META-INF\versions\$javaVersion.
val jarClasspath = project.objects.fileCollection()
Expand Down
9 changes: 8 additions & 1 deletion freemarker-manual/src/main/docgen/en_US/book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30149,7 +30149,14 @@ TemplateModel x = env.getVariable("x"); // get variable x</programlisting>
<literal>16</literal>, instead of in the usual location together
with Java 8 byte code class files. This was needed as some
tools, like Maven Enforcer plugin, have seen them as problems
otherwise.</para>
otherwise. Also, now we don't look for the
<literal>_Java<replaceable>X</replaceable>Impl</literal> classes
with <literal>Class.forName(String)</literal>, instead we just
refer them normally, as now Java will link to the proper variant
according the multi-release JAR format. This can help if some
environment doesn't support class loading on runtime (however,
then you still will have problems with other optional
features).</para>
</listitem>
</itemizedlist>
</section>
Expand Down

0 comments on commit d03f7f7

Please sign in to comment.