Search in sources :

Example 1 with ScriptHandler

use of org.gradle.api.initialization.dsl.ScriptHandler in project gradle by gradle.

the class DefaultObjectConfigurationAction method applyScript.

private void applyScript(Object script) {
    URI scriptUri = resolver.resolveUri(script);
    ScriptSource scriptSource = new UriScriptSource("script", scriptUri);
    ClassLoaderScope classLoaderScopeChild = classLoaderScope.createChild("script-" + scriptUri.toString());
    ScriptHandler scriptHandler = scriptHandlerFactory.create(scriptSource, classLoaderScopeChild);
    ScriptPlugin configurer = configurerFactory.create(scriptSource, scriptHandler, classLoaderScopeChild, classLoaderScope, false);
    for (Object target : targets) {
        configurer.apply(target);
    }
}
Also used : UriScriptSource(org.gradle.groovy.scripts.UriScriptSource) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ScriptPlugin(org.gradle.configuration.ScriptPlugin) URI(java.net.URI) ScriptSource(org.gradle.groovy.scripts.ScriptSource) UriScriptSource(org.gradle.groovy.scripts.UriScriptSource) ScriptHandler(org.gradle.api.initialization.dsl.ScriptHandler)

Example 2 with ScriptHandler

use of org.gradle.api.initialization.dsl.ScriptHandler in project gradle by gradle.

the class ScriptEvaluatingSettingsProcessor method applySettingsScript.

private void applySettingsScript(SettingsLocation settingsLocation, final SettingsInternal settings) {
    ScriptSource settingsScriptSource = settingsLocation.getSettingsScriptSource();
    ClassLoaderScope settingsClassLoaderScope = settings.getClassLoaderScope();
    ScriptHandler scriptHandler = scriptHandlerFactory.create(settingsScriptSource, settingsClassLoaderScope);
    ScriptPlugin configurer = configurerFactory.create(settingsScriptSource, scriptHandler, settingsClassLoaderScope, settings.getRootClassLoaderScope(), true);
    configurer.apply(settings);
}
Also used : ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ScriptPlugin(org.gradle.configuration.ScriptPlugin) ScriptSource(org.gradle.groovy.scripts.ScriptSource) ScriptHandler(org.gradle.api.initialization.dsl.ScriptHandler)

Example 3 with ScriptHandler

use of org.gradle.api.initialization.dsl.ScriptHandler in project gradle by gradle.

the class DefaultInitScriptProcessor method process.

public void process(final ScriptSource initScript, GradleInternal gradle) {
    ClassLoaderScope baseScope = gradle.getClassLoaderScope();
    URI uri = initScript.getResource().getLocation().getURI();
    String id = uri == null ? idGenerator.generateId().toString() : uri.toString();
    ClassLoaderScope scriptScope = baseScope.createChild("init-" + id);
    ScriptHandler scriptHandler = scriptHandlerFactory.create(initScript, scriptScope);
    ScriptPlugin configurer = configurerFactory.create(initScript, scriptHandler, scriptScope, baseScope, true);
    configurer.apply(gradle);
}
Also used : ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) URI(java.net.URI) ScriptHandler(org.gradle.api.initialization.dsl.ScriptHandler)

Aggregations

ScriptHandler (org.gradle.api.initialization.dsl.ScriptHandler)3 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)3 URI (java.net.URI)2 ScriptPlugin (org.gradle.configuration.ScriptPlugin)2 ScriptSource (org.gradle.groovy.scripts.ScriptSource)2 UriScriptSource (org.gradle.groovy.scripts.UriScriptSource)1