Class AotCacheTrainingPlugin

java.lang.Object
io.github.vpelikh.aot.gradle.AotCacheTrainingPlugin
All Implemented Interfaces:
org.gradle.api.Plugin<org.gradle.api.Project>

public class AotCacheTrainingPlugin extends Object implements org.gradle.api.Plugin<org.gradle.api.Project>
Gradle plugin that records a JVM AOT cache (JEP 483 / JEP 514) from the project's integration tests.

Apply the plugin and opt in:

plugins {
    id 'io.github.vpelikh.aot-cache-training'
}

aotCacheTraining {
    enabled = true
}

When enabled, the plugin:

  1. packages the application into its boot JAR;
  2. starts the packaged application in its own JVM through io.github.vpelikh.aot.trainer.OutOfProcessTrainingLauncher with -XX:AOTCacheOutput=<buildDir>/aot-cache/application.aot (optionally inside a container image);
  3. runs the integration tests as an external HTTP client of that application;
  4. verifies through the verifyAotCache task that a non-empty cache was produced.

The cache is recorded against the packaged application's own class path, so it is usable by the packaged application (including a container image built from it). This is deliberately separate from the normal test task, which boots the application in-process and cannot produce a cache the packaged application can load.

  • Field Details

    • RECORD_TASK_NAME

      public static final String RECORD_TASK_NAME
      The name of the task that records the cache.
      See Also:
    • VERIFY_TASK_NAME

      public static final String VERIFY_TASK_NAME
      The name of the verification task.
      See Also:
    • EMBED_IMAGE_JAR_TASK_NAME

      public static final String EMBED_IMAGE_JAR_TASK_NAME
      The name of the task that embeds the recorded cache into a copy of the boot JAR, so bootBuildImage ships the cache inside the image.
      See Also:
  • Constructor Details

    • AotCacheTrainingPlugin

      public AotCacheTrainingPlugin()
      Create the plugin. Gradle instantiates it when the plugin is applied.
  • Method Details

    • apply

      public void apply(org.gradle.api.Project project)
      Specified by:
      apply in interface org.gradle.api.Plugin<org.gradle.api.Project>