downloadCompatibleJdk
Provides the latest JDK of the Java version of JniLibProducerExtension.expectedJdkVersion built for the platform of this binary's target, to link against.
This is how a target that is not the host is linked, because Gradle serves Java toolchains for the host only. The platform is worked out from the target itself, so only the version is left to say:
binaries {
sharedLib("native") {
linkJvm() // the host, where a toolchain is enough
linkJvm(downloadCompatibleJdk()) // any other target, expectedJdkVersion
linkJvm(downloadCompatibleJdk(21)) // or a named major version
linkJvm(downloadCompatibleJdk("17.0.13.11.1")) // or an exact build
}
}The JDK is looked up through the foojay Disco API, which means a build that downloads one needs network access. A major version resolves to whichever build the distribution published last at the time of the first download, and to that same one afterwards, since the JDK is then reused from disk. Pass a version as a String to pin it.
Parameters
operating system to build the JDK for, which is this target's one by default.
architecture to build the JDK for, which is this target's one by default.
distribution to download from, for example "corretto" or "zulu".
Provides the latest JDK of a major version built for the platform of this binary's target, to link against.
See downloadCompatibleJdk for the details.
Provides the JDK of exactly version built for the platform of this binary's target, to link against.
See downloadCompatibleJdk for what this is for; this overload pins the JDK to one build.
Parameters
exact version as the distribution publishes it, for example 17.0.13.11.1.