use of org.gradle.api.internal.initialization.ClassLoaderScope in project gradle by gradle.
the class CompileGroovyScriptPluginsTask method compileScripts.
@TaskAction
void compileScripts() {
ClassLoaderScope classLoaderScope = getClassLoaderScopeRegistry().getCoreAndPluginsScope();
ClassLoader compileClassLoader = new URLClassLoader(DefaultClassPath.of(getClasspath()).getAsURLArray(), classLoaderScope.getLocalClassLoader());
FileSystemOperations fileSystemOperations = getFileSystemOperations();
fileSystemOperations.delete(spec -> spec.delete(intermediatePluginMetadataDirectory, intermediatePluginClassesDirectory));
intermediatePluginMetadataDirectory.get().getAsFile().mkdirs();
intermediatePluginClassesDirectory.get().getAsFile().mkdirs();
// TODO: Use worker API?
for (PrecompiledGroovyScript scriptPlugin : getScriptPlugins().get()) {
compileBuildScript(scriptPlugin, compileClassLoader);
}
fileSystemOperations.sync(copySpec -> {
copySpec.from(intermediatePluginClassesDirectory.get().getAsFileTree().getFiles());
copySpec.into(getPrecompiledGroovyScriptsOutputDirectory());
});
ClassLoaderUtils.tryClose(compileClassLoader);
}
use of org.gradle.api.internal.initialization.ClassLoaderScope in project gradle by gradle.
the class DefaultPluginRequestApplicator method wrapInAlreadyInClasspathResolver.
private PluginResolver wrapInAlreadyInClasspathResolver(ClassLoaderScope classLoaderScope) {
ClassLoaderScope parentLoaderScope = classLoaderScope.getParent();
PluginDescriptorLocator scriptClasspathPluginDescriptorLocator = new ClassloaderBackedPluginDescriptorLocator(parentLoaderScope.getExportClassLoader());
PluginResolver pluginResolver = pluginResolverFactory.create();
return new AlreadyOnClasspathPluginResolver(pluginResolver, pluginRegistry, parentLoaderScope, scriptClasspathPluginDescriptorLocator, pluginInspector, pluginVersionTracker);
}
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 PluginVersionTracker method findPluginVersionAt.
@Nullable
public String findPluginVersionAt(ClassLoaderScope scope, String pluginId) {
while (scope != null) {
String pluginVersion = pluginVersionsPerScope.getOrDefault(scope, emptyMap()).get(pluginId);
if (pluginVersion != null) {
return pluginVersion;
}
ClassLoaderScope parent = scope.getParent();
if (scope == parent) {
// See RootClassLoaderScope#getParent()
break;
}
scope = parent;
}
return null;
}
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, GradleProperties gradleProperties, StartParameter startParameter, ClassLoaderScope baseClassLoaderScope) {
ClassLoaderScope classLoaderScope = baseClassLoaderScope.createChild("settings[" + gradle.getIdentityPath() + "]");
DefaultSettings settings = instantiator.newInstance(DefaultSettings.class, serviceRegistryFactory, gradle, classLoaderScope, baseClassLoaderScope, scriptHandlerFactory.create(settingsScript, classLoaderScope), settingsDir, settingsScript, startParameter);
Map<String, Object> properties = gradleProperties.mergeProperties(emptyMap());
DynamicObject dynamicObject = ((DynamicObjectAware) settings).getAsDynamicObject();
((ExtensibleDynamicObject) dynamicObject).addProperties(properties);
return settings;
}
Aggregations