Search in sources :

Example 1 with ClassLoaderScope

use of org.gradle.api.internal.initialization.ClassLoaderScope in project gradle by gradle.

the class BuildSourceBuilder method buildAndCreateClassLoader.

public ClassLoaderScope buildAndCreateClassLoader(StartParameter startParameter) {
    ClassPath classpath = createBuildSourceClasspath(startParameter);
    ClassLoaderScope childScope = classLoaderScope.createChild(startParameter.getCurrentDir().getAbsolutePath());
    childScope.export(cachedClasspathTransformer.transform(classpath));
    childScope.lock();
    return childScope;
}
Also used : DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) ClassPath(org.gradle.internal.classpath.ClassPath) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope)

Example 2 with ClassLoaderScope

use of org.gradle.api.internal.initialization.ClassLoaderScope 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();
    ScriptPlugin configurer = configurerFactory.create(settingsScriptSource, settings.getBuildscript(), 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)

Example 3 with ClassLoaderScope

use of org.gradle.api.internal.initialization.ClassLoaderScope in project gradle by gradle.

the class SettingsFactory method createSettings.

public SettingsInternal createSettings(GradleInternal gradle, File settingsDir, ScriptSource settingsScript, Map<String, String> gradleProperties, StartParameter startParameter, ClassLoaderScope buildRootClassLoaderScope) {
    ClassLoaderScope settingsClassLoaderScope = buildRootClassLoaderScope.createChild("settings");
    ScriptHandlerInternal settingsScriptHandler = scriptHandlerFactory.create(settingsScript, settingsClassLoaderScope);
    DefaultSettings settings = instantiator.newInstance(DefaultSettings.class, serviceRegistryFactory, gradle, settingsClassLoaderScope, buildRootClassLoaderScope, settingsScriptHandler, settingsDir, settingsScript, startParameter);
    DynamicObject dynamicObject = ((DynamicObjectAware) settings).getAsDynamicObject();
    ((ExtensibleDynamicObject) dynamicObject).addProperties(gradleProperties);
    return settings;
}
Also used : ExtensibleDynamicObject(org.gradle.api.internal.ExtensibleDynamicObject) DynamicObject(org.gradle.internal.metaobject.DynamicObject) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ExtensibleDynamicObject(org.gradle.api.internal.ExtensibleDynamicObject) ScriptHandlerInternal(org.gradle.api.internal.initialization.ScriptHandlerInternal) DynamicObjectAware(org.gradle.api.internal.DynamicObjectAware)

Example 4 with ClassLoaderScope

use of org.gradle.api.internal.initialization.ClassLoaderScope in project gradle by gradle.

the class SelfResolvingRequestPluginResolver method resolve.

@Override
public void resolve(PluginRequestInternal pluginRequest, PluginResolutionResult result) throws InvalidPluginRequestException {
    if (pluginRequest instanceof SelfResolvingPluginRequest) {
        ClassLoaderScope classLoaderScope = ((SelfResolvingPluginRequest) pluginRequest).getClassLoaderScope();
        PluginResolution pluginResolution = new ClassPathPluginResolution(pluginRequest.getId(), classLoaderScope, EMPTY_CLASSPATH_FACTORY, pluginInspector);
        result.found("injected from outer build", pluginResolution);
    }
}
Also used : ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) SelfResolvingPluginRequest(org.gradle.initialization.definition.SelfResolvingPluginRequest)

Example 5 with ClassLoaderScope

use of org.gradle.api.internal.initialization.ClassLoaderScope in project gradle by gradle.

the class BuildTreePreparingProjectsPreparer method prepareProjects.

@Override
public void prepareProjects(GradleInternal gradle) {
    // Setup classloader for root project, all other projects will be derived from this.
    SettingsInternal settings = gradle.getSettings();
    ClassLoaderScope settingsClassLoaderScope = settings.getClassLoaderScope();
    ClassLoaderScope buildSrcClassLoaderScope = settingsClassLoaderScope.createChild("buildSrc[" + gradle.getIdentityPath() + "]");
    gradle.setBaseProjectClassLoaderScope(buildSrcClassLoaderScope);
    generateDependenciesAccessorsAndAssignPluginVersions(gradle.getServices(), settings, buildSrcClassLoaderScope);
    // attaches root project
    buildLoader.load(gradle.getSettings(), gradle);
    // Makes included build substitutions available
    if (gradle.isRootBuild()) {
        coordinator.registerGlobalLibrarySubstitutions();
    }
    // Build buildSrc and export classpath to root project
    buildBuildSrcAndLockClassloader(gradle, buildSrcClassLoaderScope);
    delegate.prepareProjects(gradle);
}
Also used : SettingsInternal(org.gradle.api.internal.SettingsInternal) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope)

Aggregations

ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)18 File (java.io.File)4 URI (java.net.URI)2 Nullable (javax.annotation.Nullable)2 ScriptHandler (org.gradle.api.initialization.dsl.ScriptHandler)2 DynamicObjectAware (org.gradle.api.internal.DynamicObjectAware)2 SettingsInternal (org.gradle.api.internal.SettingsInternal)2 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 ProjectState (org.gradle.api.internal.project.ProjectState)2 ScriptPlugin (org.gradle.configuration.ScriptPlugin)2 ScriptSource (org.gradle.groovy.scripts.ScriptSource)2 ClassPath (org.gradle.internal.classpath.ClassPath)2 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 StringWriter (java.io.StringWriter)1 URLClassLoader (java.net.URLClassLoader)1 Collections (java.util.Collections)1