ScriptAware scriptAware = null;
if (target instanceof ScriptAware) {
scriptAware = (ScriptAware) target;
scriptAware.beforeCompile(this);
}
ScriptClassLoaderProvider classLoaderProvider = this.classLoaderProvider;
ScriptSource withImports = importsReader.withImports(scriptSource);
if (classLoaderProvider == null) {
ScriptHandlerInternal defaultScriptHandler = scriptHandlerFactory.create(withImports, classLoader);
services.add(ScriptHandlerInternal.class, defaultScriptHandler);
classLoaderProvider = defaultScriptHandler;
}
ScriptCompiler compiler = scriptCompilerFactory.createCompiler(withImports);
compiler.setClassloader(classLoaderProvider.getClassLoader());
BuildScriptClasspathScriptTransformer classpathScriptTransformer
= new BuildScriptClasspathScriptTransformer(classpathClosureName);
compiler.setTransformer(classpathScriptTransformer);
ScriptRunner<? extends BasicScript> classPathScriptRunner = compiler.compile(scriptType);
classPathScriptRunner.getScript().init(target, services);
classPathScriptRunner.run();
classLoaderProvider.updateClassPath();
compiler.setTransformer(new BuildScriptTransformer(classpathScriptTransformer));
ScriptRunner<? extends BasicScript> runner = compiler.compile(scriptType);
runner.getScript().init(target, services);