Skip to content

Add Apple Silicon build workaround#131

Open
chrisrueger wants to merge 1 commit into
apache:2.3-gaefrom
chrisrueger:add-skipJava9And16SourceSets-for-local-dev
Open

Add Apple Silicon build workaround#131
chrisrueger wants to merge 1 commit into
apache:2.3-gaefrom
chrisrueger:add-skipJava9And16SourceSets-for-local-dev

Conversation

@chrisrueger
Copy link
Copy Markdown
Contributor

@chrisrueger chrisrueger commented May 29, 2026

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.

./gradlew jar                                                   

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':jar'.
> Could not resolve all dependencies for configuration ':combinedClasspath'.
   > Failed to calculate the value of task ':compileCore9Java' property 'javaCompiler'.
      > No matching toolchains found for requested specification: {languageVersion=9, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.
         > No locally installed toolchains match and the configured toolchain download repositories aren't able to provide a match either.

* Try:
> Learn more about toolchain auto-detection at https://docs.gradle.org/8.5/userguide/toolchains.html#sec:auto_detection.
> Learn more about toolchain repositories at https://docs.gradle.org/8.5/userguide/toolchains.html#sub:download_repositories.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 9s
5 actionable tasks: 1 executed, 4 up-to-date

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.

./gradlew -Pfreemarker.skipJavaMRJSourceSets=true jar

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.

@chrisrueger chrisrueger marked this pull request as ready for review May 29, 2026 20:05
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.
@chrisrueger chrisrueger force-pushed the add-skipJava9And16SourceSets-for-local-dev branch from bae00b7 to 83bf98e Compare May 30, 2026 06:01
@ddekany
Copy link
Copy Markdown
Contributor

ddekany commented May 30, 2026

But then the resulting jar won't support the Java 9 and 16 features (will miss META-INF\versions\${javaVersion}).

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 configureSourceSet(sourceSetName, sourceSetJavaVersion). And also have to override the freemarker.javadoc.javaVersion and freemarker.test.javaVersion in gradle.properties then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants