Search in sources :

Example 1 with DefaultPluginRequest

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

the class DefaultAutoAppliedPluginRegistry method createGradleEnterprisePluginRequest.

private static PluginRequestInternal createGradleEnterprisePluginRequest() {
    ModuleIdentifier moduleIdentifier = DefaultModuleIdentifier.newId(AutoAppliedGradleEnterprisePlugin.GROUP, AutoAppliedGradleEnterprisePlugin.NAME);
    ModuleVersionSelector artifact = DefaultModuleVersionSelector.newSelector(moduleIdentifier, AutoAppliedGradleEnterprisePlugin.VERSION);
    return new DefaultPluginRequest(AutoAppliedGradleEnterprisePlugin.ID, AutoAppliedGradleEnterprisePlugin.VERSION, true, null, getScriptDisplayName(), artifact);
}
Also used : DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultPluginRequest(org.gradle.plugin.management.internal.DefaultPluginRequest) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier)

Example 2 with DefaultPluginRequest

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

the class PluginRequestCollector method listPluginRequests.

@VisibleForTesting
List<PluginRequestInternal> listPluginRequests() {
    List<PluginRequestInternal> pluginRequests = collect(specs, new Transformer<PluginRequestInternal, PluginDependencySpecImpl>() {

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

        @Override
        public PluginId transform(PluginRequestInternal pluginRequest) {
            return pluginRequest.getId();
        }
    });
    // Check for duplicates
    for (PluginId key : groupedById.keySet()) {
        Collection<PluginRequestInternal> pluginRequestsForId = groupedById.get(key);
        if (pluginRequestsForId.size() > 1) {
            Iterator<PluginRequestInternal> iterator = pluginRequestsForId.iterator();
            PluginRequestInternal first = iterator.next();
            PluginRequestInternal second = iterator.next();
            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) DefaultPluginRequest(org.gradle.plugin.management.internal.DefaultPluginRequest) PluginId(org.gradle.plugin.use.PluginId) LocationAwareException(org.gradle.internal.exceptions.LocationAwareException) PluginRequestInternal(org.gradle.plugin.management.internal.PluginRequestInternal) Collection(java.util.Collection) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DefaultPluginRequest (org.gradle.plugin.management.internal.DefaultPluginRequest)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Collection (java.util.Collection)1 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)1 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)1 DefaultModuleIdentifier (org.gradle.api.internal.artifacts.DefaultModuleIdentifier)1 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)1 LocationAwareException (org.gradle.internal.exceptions.LocationAwareException)1 InvalidPluginRequestException (org.gradle.plugin.management.internal.InvalidPluginRequestException)1 PluginRequestInternal (org.gradle.plugin.management.internal.PluginRequestInternal)1 PluginId (org.gradle.plugin.use.PluginId)1