void (@Nullable MavenWorkspaceMap workspaceMap) { super.customizeComponents(workspaceMap); if (myEmbedderSettings.useCustomDependenciesResolver()) { ArtifactResolver artifactResolver = getComponent(ArtifactResolver.class); if (artifactResolver instanceof DefaultArtifactResolver) { artifactResolver = new CustomMaven36ArtifactResolver(artifactResolver); addComponent(artifactResolver, ArtifactResolver.class); } ArtifactDescriptorReader artifactDescriptorReader = getComponent(ArtifactDescriptorReader.class); if (artifactDescriptorReader instanceof DefaultArtifactDescriptorReader) { ((DefaultArtifactDescriptorReader)artifactDescriptorReader).setArtifactResolver(artifactResolver); artifactDescriptorReader = new CustomMaven36ArtifactDescriptorReader(artifactDescriptorReader); addComponent(artifactDescriptorReader, ArtifactDescriptorReader.class); } RepositorySystem repositorySystem = getComponent(RepositorySystem.class); if (repositorySystem instanceof DefaultRepositorySystem) { DefaultRepositorySystem defaultRepositorySystem = (DefaultRepositorySystem)repositorySystem; defaultRepositorySystem.setArtifactResolver(artifactResolver); defaultRepositorySystem.setArtifactDescriptorReader(artifactDescriptorReader); DependencyCollector dependencyCollector; if (VersionComparatorUtil.compare(getMavenVersion(), "3.9.0") >= 0) { // depth-first dependency collector, available since maven 3.9.0 dependencyCollector = getComponentIfExists(DependencyCollector.class, "df"); } else { // default dependency collector, maven 3.8 dependencyCollector = getComponentIfExists(DependencyCollector.class); } try { Method method = dependencyCollector.getClass().getMethod("setArtifactDescriptorReader", ArtifactDescriptorReader.class); method.invoke(dependencyCollector, artifactDescriptorReader); defaultRepositorySystem.setDependencyCollector(dependencyCollector); } catch (Throwable e) { MavenServerGlobals.getLogger().warn(e); } } // TODO: redundant? ProjectDependenciesResolver projectDependenciesResolver = getComponent(ProjectDependenciesResolver.class); if (projectDependenciesResolver instanceof DefaultProjectDependenciesResolver) { try { DefaultProjectDependenciesResolver defaultResolver = (DefaultProjectDependenciesResolver)projectDependenciesResolver; Field repoSystemField = defaultResolver.getClass().getDeclaredField("repoSystem"); repoSystemField.setAccessible(true); repoSystemField.set(defaultResolver, repositorySystem); } catch (Exception e) { MavenServerGlobals.getLogger().warn(e); } } // TODO: redundant? PluginDependenciesResolver pluginDependenciesResolver = getComponent(PluginDependenciesResolver.class); if (pluginDependenciesResolver instanceof DefaultPluginDependenciesResolver) { try { DefaultPluginDependenciesResolver defaultResolver = (DefaultPluginDependenciesResolver)pluginDependenciesResolver; Field repoSystemField = defaultResolver.getClass().getDeclaredField("repoSystem"); repoSystemField.setAccessible(true); repoSystemField.set(defaultResolver, repositorySystem); } catch (Exception e) { MavenServerGlobals.getLogger().warn(e); } } } }