Skip to content
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

Mill support: enable importing projects which contain build.mill(.scala) but not wrapper script #674

Closed
wants to merge 5 commits into from

Conversation

sideeffffect
Copy link
Contributor

Not all Mill projects necessarily have a wrapper script in the root. The wrapper script may be on the PATH.

But all Mill projects contain build.mill or build.mill.scala, so that's the robust way to recognize them.

/cc @lihaoyi

…la) but not wrapper script

Not all Mill projects necessarily have a wrapper script in the root. The wrapper script may be on the PATH.

But _all_ Mill projects contain `build.mill` or `build.mill.scala`, so that's _the_ robust way to recognize them.
@nafg
Copy link

nafg commented Nov 18, 2024

What about pre-0.12 projects, they would have build.sc

@sideeffffect
Copy link
Contributor Author

They would need to update to >= 0.12? My attitude towards this is "who cares about old Mill"?

But if there's an actual demand, I'm not opposed. And the change is trivial, so I actually did it :)

lefou added a commit to lefou/mill that referenced this pull request Nov 19, 2024
This info may be still valuable to debug IDE issues as well as running with more rare setups like `vim` or `emacs`.

Inspired by JetBrains/intellij-scala#674 from https://github.com/sideeffffect
@nafg
Copy link

nafg commented Nov 20, 2024

"old mill"

Right now I'm blocked on com-lihaoyi/mill#3955, which was fixed but needs to be released as 0.12.3

@sideeffffect
Copy link
Contributor Author

@nafg fair enough.

Btw I thought I did it, but I didn't, so I've made the change now: build.sc is now also used to detect if it's a Mill project 👍

@sideeffffect
Copy link
Contributor Author

Hello @azdrojowa123 @vasilmkd @SrTobi @timaliberdov @unkarjedy , could you please have a look at this PR? 🙏

Copy link

@lefou lefou 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 to me.

@unkarjedy unkarjedy self-requested a review January 7, 2025 11:21
@unkarjedy unkarjedy self-assigned this Jan 7, 2025
@@ -34,7 +34,8 @@ class MillProjectInstaller extends BspProjectInstallProvider {
Success(Seq(file.getAbsolutePath, "-i", "mill.bsp.BSP/install"))
case Some(file) if isLegacyMill =>
Success(Seq(file.getAbsolutePath, "-i", "mill.contrib.BSP/install"))
case _ => Failure(new IllegalStateException("Unable to install BSP as this is not a Mill project"))
case None =>
Success(Seq("mill", "-i", "mill.bsp.BSP/install"))
Copy link
Member

Choose a reason for hiding this comment

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

Did you check how it would look on UI when there is also no mill available on PATH?
The process will fail with some non zero exit code, but will there be a meaningful error message in the UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't. I assume it will fail the same way as when Seq(file.getAbsolutePath, "-i", "mill.bsp.BSP/install") fails -- which is it will print the errors in the terminal (build view).

Copy link
Contributor

Choose a reason for hiding this comment

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

I decided to check this and have some thoughts - in the "old implementation" when Success(Seq(file.getAbsolutePath, "-i", "mill.contrib.BSP/install")) was executed indeed the errors were displayed in the terminal, but because we were sure that the mill script existed we can assume that these errors were useful (at least to some certain level).
Now If the Mill is not installed globally, a very unclear error message is displayed in the terminal.
Screenshot 2025-01-22 at 13 51 41

To prevent this, we can implement the same solution as in the ScalaCliProjectInstaller. In the #installCommand, there should be a check to verify if Mill is installed globally. If it's not, a more meaningful error message should be displayed. Perhaps the best approach would be to add this check to the #canImport method, but for now, let's stay consistent with the implementation in ScalaCliProjectInstaller. If needed, it can always be refactored and moved in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the #installCommand, there should be a check to verify if Mill is installed globally.

I'm not against. But I'm not familiar with the code base. Can you please make this improvement after this PR is merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sideeffffect
I will add this before merging (anyway I have to pass it on my own through our internal CI) but I'll take care of it tomorrow :)

@sideeffffect
Copy link
Contributor Author

Hello everybody, what can I do to help this move forward?

I see that there is an error in CI, but it doesn't seem related to this PR:

Can you please re-run?

@unkarjedy
Copy link
Member

The tests failure is indeed unrelated and is actually muted on our CI.

@unkarjedy
Copy link
Member

unkarjedy commented Jan 22, 2025

@azdrojowa123 Could you or Antoni please take a look at it and merge it to 243 Nightly via personal branch?

@azdrojowa123
Copy link
Contributor

Hello,
It’s merged and will be available in the next IntelliJ IDEA 2024.3 minor release (likely in a week or two). Alternatively, you can try it out in IntelliJ IDEA 2025.1 EAP (Early Access Program), which you can download directly or via the Toolbox App, with the Scala plugin version 2025.1.446 or newer.

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.

5 participants