8000 Use java.nio.file.Path in CoursierPaths instead of java.io.File by vasilmkd · Pull Request #3364 · coursier/coursier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use java.nio.file.Path in CoursierPaths instead of java.io.File #3364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025

Conversation

vasilmkd
Copy link
Contributor
@vasilmkd vasilmkd commented Apr 4, 2025

Hello. The Scala Plugin for IDEA has a copy of the CoursierPaths source code in our project.
https://github.com/JetBrains/intellij-scala/blob/idea251.x/scala/scala-impl/src/org/jetbrains/plugins/scala/project/sdkdetect/repository/CoursierPaths.java

I'd like to remove this copy and use the version provided by coursier directly, since coursier is itself a dependency of the Scala Plugin for IDEA.

Unfortunately, we've recently started a migration to java.nio.file.Path and away from java.io.File. This will be necessary for proper support of remote development and WSL support in IDEA. Ideally, the CoursierPaths implementation would also use java.nio.file.Path behind the scenes.

This draft PR is the first step towards that, to kickstart the process. As an initial idea, I've added new methods which return a java.nio.file.Path and deprecated the already existing methods returning a java.io.File. I've also replaced the private implementation with java.nio.file.Path. I've not touched anything else.

Should we continue along this way, or do you have some other suggestions? Thank you.

@alexarchambault
Copy link
Member

Hi @vasilmkd, about these changes, I assume you'd like the methods returning Paths not to rely on File-based ones under-the-hood, right?

I've been wanting to switch entirely to NIO already. I ran into some issues, so I didn't fully make the switch (#3120, #3132 are merged, while #3124 isn't). Could you not deprecate the methods returning Files for now? I think I'll deprecate them later, maybe cutting a release with solely the switch to the new Path-based methods. Some code that relies on them is quite sensitive (addressing issues seen only in large CIs, so not tested here), I'd rather make the switch later.

@vasilmkd
Copy link
Contributor Author
vasilmkd commented Apr 7, 2025

I assume you'd like the methods returning Paths not to rely on File-based ones under-the-hood, right?

Ideally, yes. I assume you're referring to other usages of java.io.File within coursier in general, right? I understand that will take time and it is not urgent for us at all. For the initial step I wish to do (remove the copy pasted code we have), only converting CoursierPaths is enough. I believe I've covered that, right?

Could you not deprecate the methods returning Files for now?

Of course! This is exactly why I opened this PR as a draft. I will push the change as soon as possible.

@vasilmkd vasilmkd marked this pull request as ready for review April 7, 2025 13:07
Copy link
Member
@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@alexarchambault alexarchambault merged commit b91995e into coursier:main Apr 8, 2025
57 of 60 checks passed
unkarjedy pushed a commit to JetBrains/intellij-scala that referenced this pull request Apr 15, 2025
…ith the real Coursier API #SCL-23312

- I upstreamed the changes that we had made to our own copy of CoursierPaths (java.io.File -> java.nio.file.Path migration).
- coursier/coursier#3364
- We need to update the version again when the non-milestone artifact is released.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0