Search in sources :

Example 1 with TextResourceScriptSource

use of org.gradle.groovy.scripts.TextResourceScriptSource 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;
    }
    buildOperationExecutor.run(new RunnableBuildOperation() {

        @Override
        public void run(BuildOperationContext context) {
            BasicTextResourceLoader resourceLoader = new BasicTextResourceLoader();
            for (File script : initScripts) {
                TextResource resource = resourceLoader.loadFile("initialization script", script);
                processor.process(new TextResourceScriptSource(resource), gradle);
            }
        }

        @Override
        public BuildOperationDescriptor.Builder description() {
            return BuildOperationDescriptor.displayName("Run init scripts").progressDisplayName("Running init scripts");
        }
    });
}
Also used : BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) TextResource(org.gradle.internal.resource.TextResource) TextResourceScriptSource(org.gradle.groovy.scripts.TextResourceScriptSource) BasicTextResourceLoader(org.gradle.internal.resource.BasicTextResourceLoader) File(java.io.File) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation)

Example 2 with TextResourceScriptSource

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

the class DefaultObjectConfigurationAction method applyScript.

private void applyScript(Object script) {
    URI scriptUri = resolver.resolveUri(script);
    TextResource resource = resourceLoader.loadUri("script", scriptUri);
    ScriptSource scriptSource = new TextResourceScriptSource(resource);
    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 : TextResource(org.gradle.internal.resource.TextResource) TextResourceScriptSource(org.gradle.groovy.scripts.TextResourceScriptSource) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ScriptPlugin(org.gradle.configuration.ScriptPlugin) URI(java.net.URI) TextResourceScriptSource(org.gradle.groovy.scripts.TextResourceScriptSource) ScriptSource(org.gradle.groovy.scripts.ScriptSource) ScriptHandler(org.gradle.api.initialization.dsl.ScriptHandler)

Example 3 with TextResourceScriptSource

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

the class ProjectFactory method createProject.

public DefaultProject createProject(ProjectDescriptor projectDescriptor, ProjectInternal parent, GradleInternal gradle, ClassLoaderScope selfClassLoaderScope, ClassLoaderScope baseClassLoaderScope) {
    File buildFile = projectDescriptor.getBuildFile();
    TextResource resource = resourceLoader.loadFile("build file", buildFile);
    ScriptSource source = new TextResourceScriptSource(resource);
    NameValidator.validate(projectDescriptor.getName(), "project name", DefaultProjectDescriptor.INVALID_NAME_IN_INCLUDE_HINT);
    DefaultProject project = instantiator.newInstance(DefaultProject.class, projectDescriptor.getName(), parent, projectDescriptor.getProjectDir(), buildFile, source, gradle, gradle.getServiceRegistryFactory(), selfClassLoaderScope, baseClassLoaderScope);
    if (parent != null) {
        parent.addChildProject(project);
    }
    projectRegistry.addProject(project);
    return project;
}
Also used : TextResource(org.gradle.internal.resource.TextResource) TextResourceScriptSource(org.gradle.groovy.scripts.TextResourceScriptSource) File(java.io.File) ScriptSource(org.gradle.groovy.scripts.ScriptSource) TextResourceScriptSource(org.gradle.groovy.scripts.TextResourceScriptSource)

Aggregations

TextResourceScriptSource (org.gradle.groovy.scripts.TextResourceScriptSource)3 TextResource (org.gradle.internal.resource.TextResource)3 File (java.io.File)2 ScriptSource (org.gradle.groovy.scripts.ScriptSource)2 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 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)1 RunnableBuildOperation (org.gradle.internal.operations.RunnableBuildOperation)1 BasicTextResourceLoader (org.gradle.internal.resource.BasicTextResourceLoader)1