@NotNull
  private RepositorySystemSession prepareRequests(String groupId,
                                                  String artifactId,
                                                  Set<VersionConstraint> constraints,
                                                  ArtifactKind kind,
                                                  boolean includeTransitiveDependencies,
                                                  List<String> excludedDependencies,
                                                  List<ArtifactRequest> requests) throws Exception {
    RepositorySystemSession session;
    if (includeTransitiveDependencies) {
      CollectRequest collectRequest = createCollectRequest(groupId, artifactId, constraints, EnumSet.of(kind));
      var resultAndSession = mySessionFactory.retryWithClearSessionData(
        mySessionFactory.createSession(excludedDependencies),
        (s) -> ourSystem.collectDependencies(s, collectRequest)
      );
      session = resultAndSession.getSession();
      CollectResult collectResult = resultAndSession.getResult();

      ArtifactRequestBuilder builder = new ArtifactRequestBuilder(kind);
      DependencyFilter filter = createScopeFilter();
      if (!excludedDependencies.isEmpty()) {
        filter = DependencyFilterUtils.andFilter(filter, new ExcludeDependenciesFilter(excludedDependencies));
      }
      collectResult.getRoot().accept(new TreeDependencyVisitor(new FilteringDependencyVisitor(builder, filter)));
      requests.addAll(builder.getRequests());
    }
    else {
      session = mySessionFactory.createDefaultSession();
      for (Artifact artifact : toArtifacts(groupId, artifactId, constraints, Collections.singleton(kind))) {
        if (ourVersioning.parseVersionConstraint(artifact.getVersion()).getRange() != null) {
          VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifact, Collections.unmodifiableList(myRemoteRepositories), null);
          VersionRangeResult result = ourSystem.resolveVersionRange(session, versionRangeRequest);
          if (!result.getVersions().isEmpty()) {
            Artifact newArtifact = artifact.setVersion(result.getHighestVersion().toString());
            requests.add(new ArtifactRequest(newArtifact, Collections.unmodifiableList(myRemoteRepositories), null));
          }
        }
        else {
          requests.add(new ArtifactRequest(artifact, Collections.unmodifiableList(myRemoteRepositories), null));
        }
      }
    }
    return session;
  }
@NotNull
  private RepositorySystemSession prepareRequests(String groupId,
                                                  String artifactId,
                                                  Set<VersionConstraint> constraints,
                                                  ArtifactKind kind,
                                                  boolean includeTransitiveDependencies,
                                                  List<String> excludedDependencies,
                                                  List<ArtifactRequest> requests)