org.jetbrains.idea.maven.project.MavenProjectsManager#scheduleArtifactsDownloading is gone

Answered

I used to trigger the download of sources for maven artifacts using `org.jetbrains.idea.maven.project.MavenProjectsManager#scheduleArtifactsDownloading`. This method is gone in 2023.2. It wasn't scheduled for removal, as far as I can see. 

I found `org.jetbrains.idea.maven.project.MavenAsyncProjectsManager#downloadArtifacts` but the class is marked Experimental. Is this still a valid method to download the artifacts? How do I use it? I'm not sure how to use the Continuation parameter or what to do with the returned object.

Thanks!

0
2 comments

Yes, downloadArtifacts is the right method to use. It is a kotlin suspend function, but you can call it from java code too. Please let me know if something along these lines would work for you:

public MavenArtifactDownloader.DownloadResult downloadArtifactsJava() throws InterruptedException {
  Collection<? extends MavenProject> projects = ...;
  Collection<? extends MavenArtifact> artifacts = ...;
  return BuildersKt.runBlocking(
    EmptyCoroutineContext.INSTANCE,
    (scope, continuation) -> MavenProjectsManager.getInstance(myProject).downloadArtifacts(projects, artifacts, true, true, continuation)
  );
}
0

Thanks, that works. I may need to convert my code to kotlin at some point.

0

Please sign in to leave a comment.