private MavenArtifactResolveResult resolveArtifactsTransitively(
    @NotNull List<MavenArtifactInfo> artifacts,
    @NotNull List<MavenRemoteRepository> remoteRepositories) {
    MavenExecutionRequest request = createRequest(null, null, null);

    Map<org.apache.maven.api.Artifact, Path> resolvedArtifactMap = new HashMap<>();

    executeWithMavenSession(request, MavenWorkspaceMap.empty(), null, mavenSession -> {
      Session session = mavenSession.getSession();
      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());
      }
    });


    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);
  }
private MavenArtifactResolveResult resolveArtifactsTransitively(
    @NotNull List<MavenArtifactInfo> artifacts,
    @NotNull List<MavenRemoteRepository> remoteRepositories)