Class JdkProviderPlugin

java.lang.Object
com.dua3.gradle.jdkprovider.plugin.JdkProviderPlugin
All Implemented Interfaces:
org.gradle.api.Plugin<org.gradle.api.Project>

public abstract class JdkProviderPlugin extends Object implements org.gradle.api.Plugin<org.gradle.api.Project>
A Gradle plugin for managing JDK dependencies in a project. This plugin resolves and configures a specific JDK based on user-defined criteria, downloads it if necessary, and integrates it into the build tasks such as compilation, execution, testing, and documentation generation.

The plugin registers an extension named "jdk" of type JdkExtension. This extension allows users to specify JDK requirements such as version, vendor, operating system, architecture, and additional capabilities (e.g., native image support or bundled JavaFX).

Upon evaluation of the project: 1. The plugin resolves the requested JDK based on the specification provided through the extension. 2. If automatic download is enabled and the Gradle offline mode is not active, the plugin attempts to download the matching JDK if not found in standard installation paths or in the local cache. 3. The identified JDK is copied or linked into the project's build directory. 4. The plugin updates relevant build tasks (e.g., JavaExec, JavaCompile, Test, Javadoc) to use the resolved JDK executables.

If no matching JDK is found, or if an error occurs during resolution or installation, the plugin throws a GradleException with details about the failure.

  • Constructor Details

    • JdkProviderPlugin

      public JdkProviderPlugin()
      Default constructor.
  • Method Details

    • apply

      public void apply(org.gradle.api.Project project)
      Apply the plugin to the project as described in the plugin class description.
      Specified by:
      apply in interface org.gradle.api.Plugin<org.gradle.api.Project>
      Parameters:
      project - the project to apply the plugin to