boolean supportsPluginsBlock = ProjectScript.class.isAssignableFrom(scriptType);
String onPluginBlockError = supportsPluginsBlock ? null : "Only Project build scripts can contain plugins {} blocks";
PluginsAndBuildscriptTransformer scriptBlockTransformer = new PluginsAndBuildscriptTransformer(classpathClosureName, onPluginBlockError, documentationRegistry);
StatementExtractingScriptTransformer classpathScriptTransformer = new StatementExtractingScriptTransformer(classpathClosureName, scriptBlockTransformer);
compiler.setTransformer(classpathScriptTransformer);
ScriptRunner<? extends BasicScript> classPathScriptRunner = compiler.compile(scriptType);
classPathScriptRunner.getScript().init(target, services);
classPathScriptRunner.run();
List<PluginRequest> pluginRequests = pluginDependenciesService.getRequests();
PluginAware pluginAware = target instanceof PluginAware ? (PluginAware) target : null;
pluginRequestApplicator.applyPlugins(pluginRequests, scriptHandler, pluginAware, targetScope);
compiler.setClassloader(targetScope.getLocalClassLoader());
BuildScriptTransformer transformer = new BuildScriptTransformer("no_" + classpathScriptTransformer.getId(), classpathScriptTransformer.invert(), scriptSource);
compiler.setTransformer(transformer);
// TODO - find a less tangled way of getting this in here, see the verifier impl for why it's needed
compiler.setVerifier(new ClosureCreationInterceptingVerifier());