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

Handle workspaces with multiple build files. #1758

Merged
merged 3 commits into from
May 21, 2020

Conversation

ckipp01
Copy link
Member

@ckipp01 ckipp01 commented May 17, 2020

Previously this always defaulted to the first found, many times leading
to an SBT build if a workspace had both a build.sbt and a build.sc
file. Now both are grabbed and the user is prompted to choose whether
the space if for build tool A or build tool B. This choice is remembered
and they are not asked about this again.

Demo

2020-05-17 14 26 07

Chosen Approach

I went back and forth on how the flow should go for this. I really wanted that when it was detected that multiple build definitions were found that it'd prompt like the following:

New workspace found. Would you like to import:?
1. Import sbt build
2. Import mill build
3. Not now
4. Don't show again

However, after doing that it was quite messy since you have to carry a list of BuildTool round to multiple methods, which all would have to handle if there was one more many. I found it way simpler and less of a change to simply prompt the user right away when multiple were found to get their intention for the workspace. Then all of the rest of the logic can remained unchanged. I'm still open to the alternative way that I outlined I guess, but I really think it will messier and more code without much benefit.

All that to say, I wanted to throw this up here to make sure this approach was ok before I started to write tests for this.

Closes #1757

@ckipp01 ckipp01 force-pushed the choose-build branch 2 times, most recently from 63990f9 to f532f5c Compare May 17, 2020 12:38
@ckipp01 ckipp01 added the improvement Not a bug or a feature, but something general we can improve label May 17, 2020
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

I added some small comments, but I think it's a good direction. Both versions you proposed seem OK to me and if this causes less changes then I don't think we should go the other way.

@ckipp01
Copy link
Member Author

ckipp01 commented May 18, 2020

I added some small comments, but I think it's a good direction. Both versions you proposed seem OK to me and if this causes less changes then I don't think we should go the other way.

Sounds good 👍 I'll keep going this route then.

@kpbochenek
Copy link
Contributor

Cool improvement! 👍

Can we also have a possibility to see which build system was used for import?
Maybe in a Metals Doctor? Just random thought.

A db will not be wiped when I do "Build import", right? It would be good to give user an option to reset chosen build tool, what do you think?

@ckipp01
Copy link
Member Author

ckipp01 commented May 18, 2020

Cool improvement! 👍

Can we also have a possibility to see which build system was used for import?
Maybe in a Metals Doctor? Just random thought.

Ah, I hadn't thought of that, but yea, that's a cool idea. Let me play around with this to make sure there is a good minimal way to display this.

A db will not be wiped when I do "Build import", right? It would be good to give user an option to reset chosen build tool, what do you think?

Yea the decisions is persisted, so currently, apart from delete the .metals/ directory, there wouldn't be a way to reset this. However, this is sort of a problem that exists in multiple other message requests as well though right?

@kpbochenek
Copy link
Contributor

Yea the decisions is persisted, so currently, apart from delete the .metals/ directory, there wouldn't be a way to reset this. However, this is sort of a problem that exists in multiple other message requests as well though right?

You are probably right, I don't know how it works for other messages 😅

@ckipp01
Copy link
Member Author

ckipp01 commented May 18, 2020

If a user has two build definitions and they had to choose one, a short message will be added to their doctor output just saying Your <build tool> build definition has been imported. Here is an example:

Screenshot 2020-05-18 at 18 05 42

@ckipp01 ckipp01 marked this pull request as ready for review May 18, 2020 16:10
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Thanks for the great work! I have just two minor comments, but I would like to merge the Ammonite PR first, since it can have conflicts with this one.

@ckipp01
Copy link
Member Author

ckipp01 commented May 19, 2020

I would like to merge the Ammonite PR first, since it can have conflicts with this one.

No worries! I figured there would be some conflicts. I'll rebase once it's merged.

ckipp01 added 3 commits May 21, 2020 15:57
  Previously this always defaulted to the first found, manytimes leading
  to an SBT build if a workspace had both a `build.sbt` and a `build.sc`
  file. Now both are grabbed and the user is prompted to choose whether
  the space if for build tool A or build tool B. This choice is remembered
  and they are not asked about this again.
If the user has a workspace where there are multiple build files
and they have chosen one, there will be a short message in their
Doctor saying 'Your <build tool> build definition was imported'
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM! Let's merge this and I will follow up with the import formatting PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Not a bug or a feature, but something general we can improve
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better support for workspaces with multiple build tool files
3 participants