Search in sources :

Example 1 with InvalidPluginRequestException

use of org.gradle.plugin.management.internal.InvalidPluginRequestException in project gradle by gradle.

the class NotNonCorePluginOnClasspathCheckPluginResolver method resolve.

public void resolve(PluginRequestInternal pluginRequest, PluginResolutionResult result) {
    PluginId pluginId = pluginRequest.getId();
    PluginDescriptor pluginDescriptor = pluginDescriptorLocator.findPluginDescriptor(pluginId.toString());
    if (pluginDescriptor == null || isCorePlugin(pluginId)) {
        delegate.resolve(pluginRequest, result);
    } else {
        throw new InvalidPluginRequestException(pluginRequest, pluginOnClasspathErrorMessage(pluginId.toString()));
    }
}
Also used : InvalidPluginRequestException(org.gradle.plugin.management.internal.InvalidPluginRequestException) PluginDescriptor(org.gradle.api.internal.plugins.PluginDescriptor) PluginId(org.gradle.plugin.use.PluginId)

Example 2 with InvalidPluginRequestException

use of org.gradle.plugin.management.internal.InvalidPluginRequestException in project gradle by gradle.

the class PluginRequestCollector method listPluginRequests.

public List<PluginRequestInternal> listPluginRequests() {
    List<PluginRequestInternal> pluginRequests = collect(specs, new Transformer<PluginRequestInternal, DependencySpecImpl>() {

        public PluginRequestInternal transform(DependencySpecImpl original) {
            return new DefaultPluginRequest(original.id, original.version, original.apply, original.lineNumber, scriptSource);
        }
    });
    ListMultimap<PluginId, PluginRequestInternal> groupedById = CollectionUtils.groupBy(pluginRequests, new Transformer<PluginId, PluginRequestInternal>() {

        public PluginId transform(PluginRequestInternal pluginRequest) {
            return pluginRequest.getId();
        }
    });
    // Check for duplicates
    for (PluginId key : groupedById.keySet()) {
        List<PluginRequestInternal> pluginRequestsForId = groupedById.get(key);
        if (pluginRequestsForId.size() > 1) {
            PluginRequestInternal first = pluginRequests.get(0);
            PluginRequestInternal second = pluginRequests.get(1);
            InvalidPluginRequestException exception = new InvalidPluginRequestException(second, "Plugin with id '" + key + "' was already requested at line " + first.getLineNumber());
            throw new LocationAwareException(exception, second.getScriptDisplayName(), second.getLineNumber());
        }
    }
    return pluginRequests;
}
Also used : InvalidPluginRequestException(org.gradle.plugin.management.internal.InvalidPluginRequestException) LocationAwareException(org.gradle.internal.exceptions.LocationAwareException) DefaultPluginRequest(org.gradle.plugin.management.internal.DefaultPluginRequest) PluginRequestInternal(org.gradle.plugin.management.internal.PluginRequestInternal) PluginId(org.gradle.plugin.use.PluginId)

Aggregations

InvalidPluginRequestException (org.gradle.plugin.management.internal.InvalidPluginRequestException)2 PluginId (org.gradle.plugin.use.PluginId)2 PluginDescriptor (org.gradle.api.internal.plugins.PluginDescriptor)1 LocationAwareException (org.gradle.internal.exceptions.LocationAwareException)1 DefaultPluginRequest (org.gradle.plugin.management.internal.DefaultPluginRequest)1 PluginRequestInternal (org.gradle.plugin.management.internal.PluginRequestInternal)1