Search in sources :

Example 6 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 7 with ClassLoaderScope

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

the class ClassPathPluginResolution method execute.

@Override
public void execute(PluginResolveContext pluginResolveContext) {
    ClassPath classPath = classPathFactory.create();
    ClassLoaderScope loaderScope = parent.createChild("plugin-" + pluginId.getId());
    loaderScope.local(classPath);
    loaderScope.lock();
    PluginRegistry pluginRegistry = new DefaultPluginRegistry(pluginInspector, loaderScope);
    PluginImplementation<?> plugin = pluginRegistry.lookup(pluginId);
    if (plugin == null) {
        throw new UnknownPluginException("Plugin with id '" + pluginId + "' not found.");
    }
    pluginResolveContext.add(plugin);
}
Also used : ClassPath(org.gradle.internal.classpath.ClassPath) DefaultPluginRegistry(org.gradle.api.internal.plugins.DefaultPluginRegistry) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) PluginRegistry(org.gradle.api.internal.plugins.PluginRegistry) DefaultPluginRegistry(org.gradle.api.internal.plugins.DefaultPluginRegistry) UnknownPluginException(org.gradle.api.plugins.UnknownPluginException)

Example 8 with ClassLoaderScope

use of org.gradle.api.internal.initialization.ClassLoaderScope 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)

Example 9 with ClassLoaderScope

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

the class DefaultSettingsLoader method findSettingsAndLoadIfAppropriate.

/**
 * Finds the settings.gradle for the given startParameter, and loads it if contains the project selected by the
 * startParameter, or if the startParameter explicitly specifies a settings script.  If the settings file is not
 * loaded (executed), then a null is returned.
 */
private SettingsInternal findSettingsAndLoadIfAppropriate(GradleInternal gradle, StartParameter startParameter) {
    SettingsLocation settingsLocation = findSettings(startParameter);
    // We found the desired settings file, now build the associated buildSrc before loading settings.  This allows
    // the settings script to reference classes in the buildSrc.
    ClassLoaderScope buildSourceClassLoaderScope = buildSourceBuilder.buildAndCreateClassLoader(gradle, settingsLocation.getSettingsDir(), startParameter);
    return settingsProcessor.process(gradle, settingsLocation, buildSourceClassLoaderScope, startParameter);
}
Also used : ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope)

Example 10 with ClassLoaderScope

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

the class ProjectBuilderImpl method createProject.

public Project createProject(String name, File inputProjectDir, File gradleUserHomeDir) {
    File projectDir = prepareProjectDir(inputProjectDir);
    final File homeDir = new File(projectDir, "gradleHome");
    StartParameter startParameter = new StartParameterInternal();
    File userHomeDir = gradleUserHomeDir == null ? new File(projectDir, "userHome") : FileUtils.canonicalize(gradleUserHomeDir);
    startParameter.setGradleUserHomeDir(userHomeDir);
    NativeServices.initialize(userHomeDir);
    BuildRequestMetaData buildRequestMetaData = new DefaultBuildRequestMetaData(Time.currentTimeMillis());
    CrossBuildSessionScopeServices crossBuildSessionScopeServices = new CrossBuildSessionScopeServices(getGlobalServices(), startParameter);
    ServiceRegistry userHomeServices = getUserHomeServices(userHomeDir);
    BuildSessionScopeServices buildSessionScopeServices = new BuildSessionScopeServices(userHomeServices, crossBuildSessionScopeServices, startParameter, buildRequestMetaData, ClassPath.EMPTY);
    BuildTreeScopeServices buildTreeScopeServices = new BuildTreeScopeServices(buildSessionScopeServices);
    ServiceRegistry topLevelRegistry = new TestBuildScopeServices(buildTreeScopeServices, homeDir);
    GradleInternal gradle = CLASS_GENERATOR.newInstance(DefaultGradle.class, null, startParameter, topLevelRegistry.get(ServiceRegistryFactory.class));
    DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, new DefaultProjectDescriptorRegistry(), topLevelRegistry.get(FileResolver.class));
    ClassLoaderScope baseScope = gradle.getClassLoaderScope();
    ClassLoaderScope rootProjectScope = baseScope.createChild("root-project");
    ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, rootProjectScope, baseScope);
    gradle.setRootProject(project);
    gradle.setDefaultProject(project);
    // Take a root worker lease, it won't ever be released as ProjectBuilder has no lifecycle
    ResourceLockCoordinationService coordinationService = topLevelRegistry.get(ResourceLockCoordinationService.class);
    WorkerLeaseService workerLeaseService = topLevelRegistry.get(WorkerLeaseService.class);
    coordinationService.withStateLock(DefaultResourceLockCoordinationService.lock(workerLeaseService.getWorkerLease()));
    return project;
}
Also used : DefaultProjectDescriptorRegistry(org.gradle.initialization.DefaultProjectDescriptorRegistry) StartParameter(org.gradle.StartParameter) WorkerLeaseService(org.gradle.internal.work.WorkerLeaseService) BuildRequestMetaData(org.gradle.initialization.BuildRequestMetaData) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) BuildTreeScopeServices(org.gradle.internal.service.scopes.BuildTreeScopeServices) BuildSessionScopeServices(org.gradle.internal.service.scopes.BuildSessionScopeServices) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) DefaultProjectDescriptor(org.gradle.initialization.DefaultProjectDescriptor) GradleInternal(org.gradle.api.internal.GradleInternal) IProjectFactory(org.gradle.api.internal.project.IProjectFactory) ServiceRegistryFactory(org.gradle.internal.service.scopes.ServiceRegistryFactory) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry) FileResolver(org.gradle.api.internal.file.FileResolver) ResourceLockCoordinationService(org.gradle.internal.resources.ResourceLockCoordinationService) DefaultResourceLockCoordinationService(org.gradle.internal.resources.DefaultResourceLockCoordinationService) File(java.io.File)

Aggregations

ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)10 URI (java.net.URI)2 ScriptHandler (org.gradle.api.initialization.dsl.ScriptHandler)2 ScriptPlugin (org.gradle.configuration.ScriptPlugin)2 ScriptSource (org.gradle.groovy.scripts.ScriptSource)2 ClassPath (org.gradle.internal.classpath.ClassPath)2 File (java.io.File)1 StartParameter (org.gradle.StartParameter)1 DynamicObjectAware (org.gradle.api.internal.DynamicObjectAware)1 ExtensibleDynamicObject (org.gradle.api.internal.ExtensibleDynamicObject)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 FileResolver (org.gradle.api.internal.file.FileResolver)1 ScriptHandlerInternal (org.gradle.api.internal.initialization.ScriptHandlerInternal)1 ClassloaderBackedPluginDescriptorLocator (org.gradle.api.internal.plugins.ClassloaderBackedPluginDescriptorLocator)1 DefaultPluginRegistry (org.gradle.api.internal.plugins.DefaultPluginRegistry)1 PluginDescriptorLocator (org.gradle.api.internal.plugins.PluginDescriptorLocator)1 PluginRegistry (org.gradle.api.internal.plugins.PluginRegistry)1 IProjectFactory (org.gradle.api.internal.project.IProjectFactory)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1