Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,24 @@ Gradle project. After that, it's recommended to set these preferences (based on
- Project -> Properties -> FindBugs -> [x] Run Automatically
- There should 0 errors. But sometimes the plugin fails to take the
@SuppressFBWarnings annotations into account; then use Project -> Clean.


## Troubleshooting

### Problems building on MacOS / Apple Silicon / aarch64

If you run into build problems on MacOS (e.g. `No matching toolchains found for requested specification: {languageVersion=9, vendor=any, implementation=vendor-specific} for MAC_OS on aarch64.`) that means that you don't have JDK9 / JDK16 installed on your system.

You override the java versions used for JDK9 and JDK16:

```
./gradlew -Pfreemarker.javaVersionUsedFor.9=11 -Pfreemarker.javaVersionUsedFor.16=17 jar
```

This is helpful if you don't have a JDK9 / JDK16 for MacOS installed on your system and just want to build e.g. with another replacement locally during development.

You can append `--info` to get diagnostic output like this:

```
TOOLCHAIN :compileCore16Java: lang=17 vendor=Eclipse Temurin runtime=17.0.11+9 home=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
```
26 changes: 24 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ group = "org.freemarker"

val fmExt = freemarkerRoot


/*
* Additional diagnostic output when you want to find output
* which Java version is used for which part.
* enable with <i>--info</i>
*/
tasks.withType<JavaCompile>().configureEach {
doFirst {
val md = javaCompiler.get().metadata
logger.info(
"TOOLCHAIN ${path}: lang=${md.languageVersion.asInt()} " +
"vendor=${md.vendor} runtime=${md.javaRuntimeVersion} " +
"home=${md.installationPath.asFile}"
)
}
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
Expand All @@ -61,8 +78,8 @@ freemarkerRoot {
configureSourceSet("jython20")
configureSourceSet("jython22")
configureSourceSet("jython25") { enableTests() }
configureSourceSet("core9", "9") { enableTests() }
configureSourceSet("core16", "16") {
configureSourceSet("core9", javaVersionUsedFor(9).toString()) { enableTests() }
configureSourceSet("core16", javaVersionUsedFor(16).toString()) {
enableTests();
addDependencySourceSet("core9");
}
Expand Down Expand Up @@ -733,3 +750,8 @@ dependencies {
"testUtilsImplementation"("commons-collections:commons-collections:3.1")
"testUtilsImplementation"("commons-lang:commons-lang:2.6")
}

fun javaVersionUsedFor(requestedVersion: Int): Int {
val overrideVersion = project.findProperty("freemarker.javaVersionUsedFor.$requestedVersion")?.toString()?.toIntOrNull()
return overrideVersion ?: requestedVersion
}
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

# JDK version used for compiling, except for Source Sets where a specific version is set in build.gradle.kts.
freemarker.javaVersion=8
# JDK version used for compiling the Java 9 MR-JAR source set
freemarker.javaVersionUsedFor.9=9
# JDK version used for compiling the Java 16 MR-JAR source set
freemarker.javaVersionUsedFor.16=16
# JDK version for running javadoc
freemarker.javadoc.javaVersion=16
# JDK version for running JUnit tests
Expand Down
Loading