MavenEmbedderWrapper (final Project project, final boolean alwaysOnline, @NotNull String multiModuleProjectDirectory) { return new MavenEmbedderWrapper(project) { private MavenServerConnector myConnector; @NotNull @Override protected synchronized MavenServerEmbedder create() throws RemoteException { MavenServerSettings settings = convertSettings(project, MavenProjectsManager.getInstance(project).getGeneralSettings(), multiModuleProjectDirectory); if (alwaysOnline && settings.isOffline()) { settings = settings.clone(); settings.setOffline(false); } RemotePathTransformerFactory.Transformer transformer = RemotePathTransformerFactory.createForProject(project); String sdkPath = MavenUtil.getSdkPath(ProjectRootManager.getInstance(project).getProjectSdk()); if (sdkPath != null) { sdkPath = transformer.toRemotePath(sdkPath); } settings.setProjectJdk(sdkPath); var forceResolveDependenciesSequentially = Registry.is("maven.server.force.resolve.dependencies.sequentially"); var useCustomDependenciesResolver = Registry.is("maven.server.use.custom.dependencies.resolver"); myConnector = MavenServerManagerImpl.this.getConnector(project, multiModuleProjectDirectory); return myConnector.createEmbedder(new MavenEmbedderSettings( settings, transformer.toRemotePath(multiModuleProjectDirectory), forceResolveDependenciesSequentially, useCustomDependenciesResolver )); } @Override protected synchronized void cleanup() { super.cleanup(); if (myConnector != null) { shutdownConnector(myConnector, false); } } }; }