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);
}
}
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);
}
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);
}
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);
}
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;
}
Aggregations