Add Apple Silicon build workaround#131
Conversation
Document a local workaround for building on MacOS Apple Silicon and add a Gradle flag to enable it. README.md shows running ./gradlew -Pfreemarker.skipJavaMRJSourceSets=true jar to avoid MR-JAR toolchain errors when JDK9/16 are unavailable. build.gradle.kts adds the skipJavaMRJSourceSets property, conditionally omits configuring the core9/core16 MR-JAR source sets, and updates the Eclipse classpath assembly to avoid referencing those configurations when skipped.
bae00b7 to
83bf98e
Compare
|
But then the resulting jar won't support the Java 9 and 16 features (will miss What if instead you add an option to use Java 11 instead of 9, and Java 17 instead of 16? Maybe those Java version are available for Mac. In principle all you have to do is replacing the 2nd argument to |
This reverts commit 83bf98e.
Introduce freemarker.core9.javaVersion and freemarker.core16.javaVersion properties and read them in build.gradle.kts via providers.gradleProperty(); pass those values to configureSourceSet for core9 and core16. Also bump freemarker.javadoc.javaVersion and freemarker.test.javaVersion to 17. This allows compiling the MR-JAR source sets with independent JDK versions (e.g. Java 11 for core9 and Java 17 for core16) configurable from gradle.properties.
|
For debugging I added the following temporary task to which prints Gradle Toolchains look like this: |
|
Something like that, except, you have committed the Java version overrides needed on Mac into The ultimate solution is maybe having something like |
Add a local-only hack / workaround for building on MacOS Apple Silicon and add a Gradle flag to enable it.
Problem was:
On my Macbook M3 I had trouble building freemarker.
Can't remember exactly but AIs of this world recommended Azul somehow.
I managed to get an old Azul JDK 1.8 and 16, but could not find a Azul JDK 9 (https://www.azul.com/downloads/?package=jdk#zulu) .
So I started commenting out some sections in
build.gradle.kts.But then I decided to make a PR and introduce a property so other could use that too if needed.
Use this to avoid MR-JAR toolchain errors when JDK9/16 are unavailable. build.gradle.kts adds the skipJavaMRJSourceSets property, conditionally omits configuring the core9/core16 MR-JAR source sets, and updates the Eclipse classpath assembly to avoid referencing those configurations when skipped.
@ddekany That might not be optimal, but if anything it is an idea / base for discussion. Feel free to reject it. I am open for ideas. It is just what I did locally, as I want to try out and idea for another PR.