Search in sources :

Example 1 with UriScriptSource

use of org.gradle.groovy.scripts.UriScriptSource 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 UriScriptSource

use of org.gradle.groovy.scripts.UriScriptSource in project gradle by gradle.

the class InitScriptHandler method executeScripts.

public void executeScripts(final GradleInternal gradle) {
    final List<File> initScripts = gradle.getStartParameter().getAllInitScripts();
    if (initScripts.isEmpty()) {
        return;
    }
    BuildOperationDetails operationDetails = BuildOperationDetails.displayName("Run init scripts").progressDisplayName("init scripts").build();
    buildOperationExecutor.run(operationDetails, new Action<BuildOperationContext>() {

        @Override
        public void execute(BuildOperationContext buildOperationContext) {
            for (File script : initScripts) {
                processor.process(new UriScriptSource("initialization script", script), gradle);
            }
        }
    });
}
Also used : BuildOperationDetails(org.gradle.internal.progress.BuildOperationDetails) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) UriScriptSource(org.gradle.groovy.scripts.UriScriptSource) File(java.io.File)

Aggregations

UriScriptSource (org.gradle.groovy.scripts.UriScriptSource)2 File (java.io.File)1 URI (java.net.URI)1 ScriptHandler (org.gradle.api.initialization.dsl.ScriptHandler)1 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)1 ScriptPlugin (org.gradle.configuration.ScriptPlugin)1 ScriptSource (org.gradle.groovy.scripts.ScriptSource)1 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)1 BuildOperationDetails (org.gradle.internal.progress.BuildOperationDetails)1