MavenArtifactResolveResult ( @NotNull List<MavenArtifactInfo> artifacts, @NotNull List<MavenRemoteRepository> remoteRepositories) { DefaultSessionFactory sessionFactory = getComponent(DefaultSessionFactory.class); MavenExecutionRequest request = createRequest(null, null, null); request.setRemoteRepositories(convertRepositories(remoteRepositories)); DefaultMaven maven = (DefaultMaven)getComponent(Maven.class); MavenSession mavenSession = createMavenSession(request, maven); Session session = sessionFactory.getSession(mavenSession); Map<org.apache.maven.api.Artifact, Path> resolvedArtifactMap = new HashMap<>(); SessionScope sessionScope = getComponent(SessionScope.class); try { sessionScope.enter(); sessionScope.seed(DefaultSession.class, (DefaultSession)session); for (MavenArtifactInfo mavenArtifactInfo : artifacts) { ArtifactCoordinate coordinate = session.createArtifactCoordinate( mavenArtifactInfo.getGroupId(), mavenArtifactInfo.getArtifactId(), mavenArtifactInfo.getVersion(), mavenArtifactInfo.getClassifier(), mavenArtifactInfo.getPackaging(), null); ArtifactResolver artifactResolver = session.getService(ArtifactResolver.class); ArtifactResolverResult resolved = artifactResolver.resolve(session, Collections.singleton(coordinate)); resolvedArtifactMap.putAll(resolved.getArtifacts()); DependencyCoordinate dependencyCoordinate = session.createDependencyCoordinate(coordinate); Node dependencyNode = session.collectDependencies(dependencyCoordinate); List<DependencyCoordinate> dependencyCoordinates = dependencyNode.stream() .filter(node -> node != dependencyNode) .filter(node -> node.getDependency() != null) .map(node -> node.getDependency().toCoordinate()) .collect(Collectors.toList()); ArtifactResolverResult resolvedChildren = artifactResolver.resolve(session, dependencyCoordinates); resolvedArtifactMap.putAll(resolvedChildren.getArtifacts()); } } finally { sessionScope.exit(); } File localRepositoryFile = getLocalRepositoryFile(); List<MavenArtifact> resolvedArtifacts = new ArrayList<>(); for (org.apache.maven.api.Artifact apiArtifact : resolvedArtifactMap.keySet()) { Path artifactPath = resolvedArtifactMap.get(apiArtifact); MavenArtifact mavenArtifact = Maven40ApiModelConverter.convertArtifactAndPath(apiArtifact, artifactPath, localRepositoryFile); resolvedArtifacts.add(mavenArtifact); } return new MavenArtifactResolveResult(resolvedArtifacts, null); }