The JVM Toolchains Plugins
Two related core plugins provide Java toolchain support: jvm-toolchains works at the project level, and jvm-toolchain-management works at the settings level.
Both are applied automatically in the situations described below, so you rarely apply them by hand.
For the concepts — how a toolchain is selected, provisioned, and used by JVM tasks — see Toolchains for JVM projects. For writing and registering toolchain download repositories, see Toolchain Resolver Plugins.
The jvm-toolchains plugin
The jvm-toolchains plugin (a Plugin<Project>) makes the JavaToolchainService available to a project so that toolchains can be selected and provisioned for JVM tools such as compilation, testing, and execution.
It adds the following extension:
javaToolchains— JavaToolchainService-
Used to query for and provision toolchains — for example, to obtain a
JavaLauncher,JavaCompiler, orJavadocToolfor a specificJavaLanguageVersion.
The JVM language plugins (via the java-base plugin) apply jvm-toolchains automatically, so most builds never apply it directly.
Apply it explicitly only when you need the javaToolchains service in a project that does not apply a JVM language plugin:
plugins {
id("jvm-toolchains")
}
plugins {
id 'jvm-toolchains'
}
The jvm-toolchain-management plugin
The jvm-toolchain-management plugin (a Plugin<Settings>) adds a jvm block to the settings-level toolchainManagement container, where Java toolchain download repositories are configured:
toolchainManagement {
jvm {
javaRepositories {
// register toolchain resolver repositories here
}
}
}
Toolchain resolver plugins apply jvm-toolchain-management automatically, so you normally do not apply it yourself.
See also
-
Toolchains for JVM projects — selecting and provisioning toolchains.
-
Toolchain Resolver Plugins — writing and registering toolchain download repositories.