void (@NotNull DataNode<LibraryDependencyData> libraryDependencyDataNode) { final DataNode<?> libraryNodeParent = libraryDependencyDataNode.getParent(); if (libraryNodeParent == null) return; final LibraryDependencyData libraryDependencyData = libraryDependencyDataNode.getData(); final LibraryData libraryData = libraryDependencyData.getTarget(); final Set<String> libraryPaths = libraryData.getPaths(LibraryPathType.BINARY); if (libraryPaths.isEmpty()) return; if (StringUtil.isNotEmpty(libraryData.getExternalName())) { if (gradleUserHomeDir != null) { attachSourcesAndJavadocFromGradleCacheIfNeeded(resolverContext, gradleUserHomeDir, libraryData); } return; } boolean shouldKeepTransitiveDependencies = !libraryPaths.isEmpty() && !libraryDependencyDataNode.getChildren().isEmpty(); Collection<AbstractDependencyData<?>> dependenciesToShift = collectDependenciesOrderedAfter(libraryNodeParent, libraryDependencyData.getOrder()); int classpathOrderShift = -1; final ArrayDeque<String> unprocessedPaths = new ArrayDeque<>(libraryPaths); while (!unprocessedPaths.isEmpty()) { final String path = unprocessedPaths.remove(); Collection<ModuleLookupResult> lookupResults = lookupTargetModule(path); for (ModuleLookupResult result : lookupResults) { if (createAndMaybeAttachNewModuleDependency(libraryDependencyDataNode, result, libraryPaths, shouldKeepTransitiveDependencies, unprocessedPaths, classpathOrderShift, path)) { classpathOrderShift++; } } ModuleMappingInfo mapping = resolverContext.getArtifactsMap().getModuleMapping(path); if (!lookupResults.isEmpty() && (mapping == null || !mapping.getHasNonModulesContent())) { libraryPaths.remove(path); } if (libraryPaths.isEmpty()) { libraryDependencyDataNode.clear(true); break; } } applyClasspathShift(dependenciesToShift, classpathOrderShift); if (libraryDependencyDataNode.getParent() != null) { if (libraryPaths.size() > 1) { List<String> toRemove = new SmartList<>(); for (String path : libraryPaths) { final File binaryPath = new File(path); if (binaryPath.isFile()) { final LibraryData extractedLibrary = new LibraryData(libraryDependencyData.getOwner(), ""); extractedLibrary.addPath(LibraryPathType.BINARY, path); if (gradleHomeDir != null && gradleVersion != null) { attachGradleSdkSources(binaryPath, extractedLibrary, gradleHomeDir, gradleVersion); } LibraryDependencyData extractedDependencyData = new LibraryDependencyData( libraryDependencyData.getOwnerModule(), extractedLibrary, LibraryLevel.MODULE); libraryDependencyDataNode.getParent().createChild(ProjectKeys.LIBRARY_DEPENDENCY, extractedDependencyData); toRemove.add(path); } } libraryPaths.removeAll(toRemove); if (libraryPaths.isEmpty()) { libraryDependencyDataNode.clear(true); } } } }