use of org.gradle.plugin.use.PluginId in project gradle by gradle.
the class DefaultPluginManager method addPluginInternal.
// if the plugin has already been added
@Nullable
private Runnable addPluginInternal(final PluginImplementation<?> plugin) {
final Class<?> pluginClass = plugin.asClass();
if (plugins.containsKey(pluginClass)) {
return null;
}
plugins.put(pluginClass, plugin);
return new Runnable() {
@Override
public void run() {
// Take a copy because adding to an idMappings value may result in new mappings being added (i.e. ConcurrentModificationException)
Iterable<PluginId> pluginIds = Lists.newArrayList(idMappings.keySet());
for (PluginId id : pluginIds) {
if (plugin.isAlsoKnownAs(id)) {
idMappings.get(id).add(new PluginWithId(id, pluginClass));
}
}
}
};
}
use of org.gradle.plugin.use.PluginId in project gradle by gradle.
the class TypeValidationProblemRenderer method introductionFor.
private static String introductionFor(TypeValidationProblemLocation location) {
StringBuilder builder = new StringBuilder();
Class<?> rootType = location.getType().filter(TypeValidationProblemRenderer::shouldRenderType).orElse(null);
PluginId pluginId = location.getPlugin().orElse(null);
if (rootType != null) {
if (pluginId != null) {
builder.append("In plugin '").append(pluginId).append("' type '");
} else {
builder.append("Type '");
}
builder.append(ModelType.of(rootType).getName());
builder.append("' ");
}
String property = location.getPropertyName().orElse(null);
if (property != null) {
if (rootType == null) {
if (pluginId != null) {
builder.append("In plugin '").append(pluginId).append("' property '");
} else {
builder.append("Property '");
}
} else {
builder.append("property '");
}
location.getParentPropertyName().ifPresent(parentProperty -> {
builder.append(parentProperty);
builder.append('.');
});
builder.append(property);
builder.append("' ");
}
return builder.toString();
}
use of org.gradle.plugin.use.PluginId in project gradle by gradle.
the class ExternalPluginValidationPlugin method configurePluginValidation.
private void configurePluginValidation(Project project, TaskProvider<Task> lifecycleTask, PluginRegistry registry, Map<String, List<File>> jarsByPlugin, Plugin<?> plugin) {
Class<?> pluginClass = plugin.getClass();
if (isExternal(pluginClass)) {
Optional<PluginId> pluginForClass = registry.findPluginForClass(pluginClass);
String pluginId;
pluginId = pluginForClass.map(PluginId::getId).orElseGet(() -> computePluginName(plugin));
File pluginJar = findPluginJar(pluginClass);
if (pluginJar != null) {
jarsByPlugin.computeIfAbsent(pluginId, firstSeenPlugin -> registerValidationTaskForNewPlugin(firstSeenPlugin, project, lifecycleTask)).add(pluginJar);
} else {
LOGGER.warn("Validation won't be performed for plugin '{}' because we couldn't locate its jar file", pluginId);
}
}
}
use of org.gradle.plugin.use.PluginId 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));
}
use of org.gradle.plugin.use.PluginId in project gradle by gradle.
the class CorePluginResolver method resolve.
@Override
public void resolve(PluginRequestInternal pluginRequest, PluginResolutionResult result) {
PluginId id = pluginRequest.getId();
if (!isCorePluginRequest(id)) {
result.notFound(getDescription(), format("plugin is not in '%s' namespace", CORE_PLUGIN_NAMESPACE));
return;
}
PluginImplementation<?> plugin = pluginRegistry.lookup(id);
if (plugin == null) {
result.notFound(getDescription(), format("not a core plugin, please see %s for available core plugins", documentationRegistry.getDocumentationFor("standard_plugins")));
return;
}
validate(pluginRequest);
result.found(getDescription(), new SimplePluginResolution(plugin));
}
Aggregations