docs: @SuppressWarnings("unchecked")
      private void apply(File root, Iterable<? extends File> classPath) throws IOException {
          if (!root.isDirectory()) {
              throw new GradleException("Not a directory: " + root);
          }
          ClassLoaderResolver classLoaderResolver = new ClassLoaderResolver();
          try {
              List<Plugin.Factory> factories = new ArrayList<Plugin.Factory>(byteBuddyExtension.getTransformations().size());
              for (Transformation transformation : byteBuddyExtension.getTransformations()) {
                  String plugin = transformation.getPlugin();
                  try {
                      factories.add(new Plugin.Factory.UsingReflection((Class<? extends Plugin>) Class.forName(plugin,
                              false,
                              classLoaderResolver.resolve(transformation.getClassPath(root, classPath))))
                              .with(transformation.makeArgumentResolvers())
                              .with(Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(File.class, root),
                                      Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(Logger.class, project.getLogger()),
                                      Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(BuildLogger.class, new GradleBuildLogger(project.getLogger()))));
                      project.getLogger().info("Resolved plugin: {}", transformation.getRawPlugin());
                  } catch (Throwable throwable) {
                      throw new GradleException("Cannot resolve plugin: " + transformation.getRawPlugin(), throwable);
                  }
              }
              EntryPoint entryPoint = byteBuddyExtension.getInitialization().getEntryPoint(classLoaderResolver, root, classPath);
              project.getLogger().info("Resolved entry point: {}", entryPoint);
              List<ClassFileLocator> classFileLocators = new ArrayList<ClassFileLocator>();
              for (File artifact : classPath) {
                  classFileLocators.add(artifact.isFile()
                          ? ClassFileLocator.ForJarFile.of(artifact)
                          : new ClassFileLocator.ForFolder(artifact));
              }
              ClassFileLocator classFileLocator = new ClassFileLocator.Compound(classFileLocators);
              Plugin.Engine.Summary summary;
              try {
                  project.getLogger().info("Processing class files located in in: {}", root);
                  Plugin.Engine pluginEngine;
                  try {
                      ClassFileVersion classFileVersion;
                      JavaPluginConvention convention = (JavaPluginConvention) project.getConvention().getPlugins().get("java");
                      if (convention == null) {
                          classFileVersion = ClassFileVersion.ofThisVm();
                          project.getLogger().warn("Could not locate Java target version, build is JDK dependant: {}", classFileVersion.getMajorVersion());
                      } else {
                          classFileVersion = ClassFileVersion.ofJavaVersion(Integer.parseInt(convention.getTargetCompatibility().getMajorVersion()));
                          project.getLogger().debug("Java version detected: {}", convention.getTargetCompatibility().getMajorVersion());
                      }
                      pluginEngine = Plugin.Engine.Default.of(entryPoint, classFileVersion, byteBuddyExtension.getMethodNameTransformer());
                  } catch (Throwable throwable) {
                      throw new GradleException("Cannot create plugin engine", throwable);
                  }
                  try {
                      summary = pluginEngine
                              .with(byteBuddyExtension.isExtendedParsing()
                                      ? Plugin.Engine.PoolStrategy.Default.EXTENDED
                                      : Plugin.Engine.PoolStrategy.Default.FAST)
                              .with(classFileLocator)
                              .with(new TransformationLogger(project.getLogger()))
                              .withErrorHandlers(Plugin.Engine.ErrorHandler.Enforcing.ALL_TYPES_RESOLVED, byteBuddyExtension.isFailOnLiveInitializer()
                                      ? Plugin.Engine.ErrorHandler.Enforcing.NO_LIVE_INITIALIZERS
                                      : Plugin.Engine.Listener.NoOp.INSTANCE, byteBuddyExtension.isFailFast()
                                      ? Plugin.Engine.ErrorHandler.Failing.FAIL_FAST
                                      : Plugin.Engine.Listener.NoOp.INSTANCE)
                              .apply(new Plugin.Engine.Source.ForFolder(root), new Plugin.Engine.Target.ForFolder(root), factories);
                  } catch (Throwable throwable) {
                      throw new GradleException("Failed to transform class files in " + root, throwable);
                  }
              } finally {
                  classFileLocator.close();
              }
              if (!summary.getFailed().isEmpty()) {
                  throw new GradleException(summary.getFailed() + " type transformations have failed");
              } else if (summary.getTransformed().isEmpty()) {
                  project.getLogger().warn("No types were transformed during plugin execution");
              } else {
                  project.getLogger().info("Transformed {} types", summary.getTransformed().size());
              }
          } finally {
              classLoaderResolver.close();
          }
      }