GradleProjectResolverExtension (@Nullable DefaultProjectResolverContext resolverContext, @Nullable Predicate<? super GradleProjectResolverExtension> extensionsFilter) { Stream<GradleProjectResolverExtension> extensions = GradleProjectResolverUtil.createProjectResolvers(resolverContext); if (extensionsFilter != null) { extensions = extensions.filter(extensionsFilter.or(BaseResolverExtension.class::isInstance)); } Deque<GradleProjectResolverExtension> deque = new ArrayDeque<>(); extensions.forEachOrdered(extension -> { final GradleProjectResolverExtension previous = deque.peekLast(); if (previous != null) { previous.setNext(extension); if (previous.getNext() != extension) { throw new AssertionError("Illegal next resolver got, current resolver class is " + previous.getClass().getName()); } } deque.add(extension); }); GradleProjectResolverExtension firstResolver = deque.peekFirst(); GradleProjectResolverExtension resolverExtension = firstResolver; assert resolverExtension != null; while (resolverExtension.getNext() != null) { resolverExtension = resolverExtension.getNext(); } if (!(resolverExtension instanceof BaseResolverExtension)) { throw new AssertionError("Illegal last resolver got of class " + resolverExtension.getClass().getName()); } GradleProjectResolverExtension chainWrapper = new AbstractProjectResolverExtension() { @NotNull @Override public ExternalSystemException getUserFriendlyError(@Nullable BuildEnvironment buildEnvironment, @NotNull Throwable error, @NotNull String projectPath, @Nullable String buildFilePath) { ExternalSystemException friendlyError = super.getUserFriendlyError(buildEnvironment, error, projectPath, buildFilePath); return new BaseProjectImportErrorHandler() .checkErrorsWithoutQuickFixes(buildEnvironment, error, projectPath, buildFilePath, friendlyError); } }; chainWrapper.setNext(firstResolver); return chainWrapper; }