use of org.gradle.api.internal.plugins.PluginImplementation in project gradle by gradle.
the class DefaultPluginRequestApplicator method applyPlugins.
@Override
public void applyPlugins(final PluginRequests requests, final ScriptHandlerInternal scriptHandler, @Nullable final PluginManagerInternal target, final ClassLoaderScope classLoaderScope) {
if (target == null || requests.isEmpty()) {
defineScriptHandlerClassScope(scriptHandler, classLoaderScope, Collections.emptyList());
return;
}
// This should move to settings finalization
pluginRepositoriesProvider.prepareForPluginResolution();
final PluginResolver effectivePluginResolver = wrapInAlreadyInClasspathResolver(classLoaderScope);
if (!requests.isEmpty()) {
addPluginArtifactRepositories(scriptHandler.getRepositories());
}
List<Result> results = resolvePluginRequests(requests, effectivePluginResolver);
final List<Consumer<PluginManagerInternal>> pluginApplyActions = newLinkedList();
final Map<Result, PluginImplementation<?>> pluginImplsFromOtherLoaders = newLinkedHashMap();
if (!results.isEmpty()) {
for (final Result result : results) {
applyPlugin(result.request, result.found.getPluginId(), new Runnable() {
@Override
public void run() {
result.found.execute(new PluginResolveContext() {
@Override
public void addLegacy(PluginId pluginId, Object dependencyNotation) {
pluginApplyActions.add(target -> applyLegacyPlugin(target, result, pluginId));
scriptHandler.addScriptClassPathDependency(dependencyNotation);
}
@Override
public void add(PluginImplementation<?> plugin) {
pluginApplyActions.add(target -> applyPlugin(target, result, plugin));
}
@Override
public void addFromDifferentLoader(PluginImplementation<?> plugin) {
pluginApplyActions.add(target -> applyPlugin(target, result, plugin));
pluginImplsFromOtherLoaders.put(result, plugin);
}
});
String pluginVersion = result.found.getPluginVersion();
if (pluginVersion != null) {
pluginVersionTracker.setPluginVersionAt(classLoaderScope, result.found.getPluginId().getId(), pluginVersion);
}
}
});
}
}
defineScriptHandlerClassScope(scriptHandler, classLoaderScope, pluginImplsFromOtherLoaders.values());
pluginApplyActions.forEach(pluginApplyAction -> pluginApplyAction.accept(target));
}
Aggregations