You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2025/09/18 15:09:40 UTC

[D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

GitHub user pjfanning created a discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

* we want to maintain custom sorting in many of the scala files used for documentation - so if we could annotate the files that we don't want to sort automatically or exclude the docs directory, that would be ideal
* we tend to `import org.apache.pekko` so that we can save on the `org.apache` part when importing Pekko classes - so a sort tool that can handle that would be great - I am not wedded to maintaining this if it makes life easier to the tooling although I suspect that some people like them
* we waste a lot of time hand sorting imports and commenting on PRs asking for changes to imports 

GitHub link: https://github.com/apache/pekko/discussions/2228

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich edited a comment on the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> @mdedetrich I created https://github.com/apache/pekko-http/pull/791
> 
> 
> 
> Where I copied the scalafix setup to pekko-http. The repo is a bit smaller so easier to review.
> 
> The pekko import seem fine to me.
> 
> 
> 
> I would really like to automate this. This manual sorting of imports takes a lot of time.

Oh don't get me wrong, I would love to not do this manually especially since I am the one doing it

My thoughts on this would be to manually sort once so at least there is some consistency and then just wait until group imports is fixed in scalafix and then fully automate

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446710

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> @mdedetrich I created https://github.com/apache/pekko-http/pull/791
> 
> 
> 
> Where I copied the scalafix setup to pekko-http. The repo is a bit smaller so easier to review.
> 
> The pekko import seem fine to me.
> 
> 
> 
> I would really like to automate this. This manual sorting of imports takes a lot of time.

Oh don't get me wrong, I would love to not do this manually especially since I am the one doing it

My thoughts on this would be to manually sort once so at least there is some consistency and then just wait until group imports is fixed in Saladin

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446710

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "ptrdom (via GitHub)" <gi...@apache.org>.
GitHub user ptrdom edited a comment on the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> wdyt @kerr @ptrdom @raboof of https://github.com/apache/pekko-http/pull/791 ?

Result looks good, but I do remember `SortImports` breaking code frequently enough for it to become annoying to me, maybe we could achieve same result with `OrganizeImports`? If we merge instead of grouping then it should work fine.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446853

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

Lianchen has a rule

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14445688

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "ptrdom (via GitHub)" <gi...@apache.org>.
GitHub user ptrdom added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> wdyt @kerr @ptrdom @raboof of https://github.com/apache/pekko-http/pull/791 ?

Result looks good, but I do remember `SortImports` breaking code frequently enough for it to become annoying to me, maybe we could achieve same result with `OrganizeImports`? If we merge instead of grouping the it should work fine.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446853

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

refs: https://github.com/scalameta/scalafmt/issues/4977

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446981

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

It doesn't, see https://github.com/scalacenter/scalafix/issues/2100

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446342

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "kitbellew (via GitHub)" <gi...@apache.org>.
GitHub user kitbellew added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> Scalafmt cannot do anything regarding import ordering/grouping because it's possible to break behaviour since Scala is import ordering sensitive.

if using relative imports without careful grouping, that's correct. if groups are configured with FDQN prefixes such as `com`, `org.apache` and one of these domain prefixes is not used in the middle (i.e., `org.apache.xxx.yyy.org.apache.zzz`), then scalafmt will group and sort within these groups and put the rest after them.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14447288

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could get sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could get sbt or a sbt plugin to sort the imports how we want?

Yes, I think the current one is quite ok in most cases.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14463471

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

there are some issues that I need to look at but the order of imports looks pretty good and hopefully, I can resolve the issues where some code is getting damaged so it won't compile

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446715

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> > what about https://scalameta.org/scalafmt/docs/configuration.html#imports-groups
> 
> 
> 
> I think I have tried it a long while ago, but cannot remember if it had any issues or not. Often developers want to both sort imports and remove unused, and latter cannot be done by scalafmt, but scalafix with `OrganizeImports` can do both.

Scalafmt cannot do anything regarding import ordering/grouping because it's possible to break behaviour since Scala is import ordering sensitive.

It needs to be done in scalafix as only scalafix can calculate effects of import changes as it has compile time information.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14447096

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> If we want more contributors, I think we need to simplify the process and make everything as automated and tool-based as possible, rather than manually adjusting things. Everyone's local settings may be different, and without a tool to guarantee that everything is set up correctly, problems are very likely to occur. It's time-consuming and labor-intensive, and no one wants to mess around with it.

To be clear, the intention behind my PR was to do it once and only once, it wasn't to create some process to force manual sorting on users.

The idea was to have something until we could use scalafix because there was some breaking issues that I experienced when I tried it out (remember that the current scalafix config was added years ago by Akka team but they never used it because of said issues)

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446827

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

If we want more contributors, I think we need to simplify the process and make everything as automated and tool-based as possible, rather than manually adjusting things. Everyone's local settings may be different, and without a tool to guarantee that everything is set up correctly, problems are very likely to occur. It's time-consuming and labor-intensive, and no one wants to mess around with it.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446807

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> there are some issues that I need to look at but the order of imports looks pretty good and hopefully, I can resolve the issues where some code is getting damaged so it won't compile

Ah yes, I remember this issue when I tried this a year ago and that caused me to give up

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446800

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could get sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich added a comment to the discussion: Is there a way we could get sbt or a sbt plugin to sort the imports how we want?

> I tried that out in pekko-http.
> 
> It is much slower than sbt-imports because it compiles all the code.
> 
> I haven't yet found a config that deals well with the sorting the imports well with the `import org.apache.pekko`.
> 
> 
> 
> I'll happily defer to someone else who can get it work well. I have to move on to the 1.2.1 release and other stuff.

So to do proper import sorting you have to compile the code because in Scala, import order can effect behaviour of code and so you need to compile in order to make sure you don't break behaviour.

You experienced the same issues that I did in the past, shall we talk about this in the discussion thread?

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14463488

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "ptrdom (via GitHub)" <gi...@apache.org>.
GitHub user ptrdom added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> what about https://scalameta.org/scalafmt/docs/configuration.html#imports-groups

I think I have tried it a long while ago, but cannot remember if it had any issues or not. Often developers want to both sort imports and remove unused, and latter cannot be done by scalafmt, but scalafix with `OrganizeImports` can do both.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14447045

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

We can add some thing format on format off

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14445698

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

I found an example in pekko-http that is affected.

```
import org.apache.pekko
import pekko.http.scaladsl.model._
import MediaTypes._
```

The scalafix sortImports doesn't treat `import MediaTypes._` as needing to be sorted under `import pekko.http.scaladsl.model._`

It is not that common. I fixed the issue in my peko-http PR by modifying such imports to something like `import pekko.http.scaladsl.model.MediaTypes._`. A one-off change that keeps the import sorting happy going forward.


GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14453560

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could get sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning added a comment to the discussion: Is there a way we could get sbt or a sbt plugin to sort the imports how we want?

I tried that out in pekko-http.
It is much slower than sbt-imports because it compiles all the code.
I haven't yet found a config that deals well with the sorting the imports well with the `import org.apache.pekko`.

I'll happily defer to someone else who can get it work well. I have to move on to the 1.2.1 release and other stuff.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14463468

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "ptrdom (via GitHub)" <gi...@apache.org>.
GitHub user ptrdom added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> we tend to import org.apache.pekko so that we can save on the org.apache part when importing Pekko classes

It looks like https://scalacenter.github.io/scalafix/docs/rules/OrganizeImports.html#groups should support this. Either way we can use scalafix OrganizeImports rule, just either need to try to config the grouping as we want or get rid of the grouping. I personally prefer ungrouped, exploded imports, because those are easy to be made to work in both scalafix and IDEs

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14444998

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich edited a comment on the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> @mdedetrich I created https://github.com/apache/pekko-http/pull/791
> 
> 
> 
> Where I copied the scalafix setup to pekko-http. The repo is a bit smaller so easier to review.
> 
> The pekko import seem fine to me.
> 
> 
> 
> I would really like to automate this. This manual sorting of imports takes a lot of time.

Oh don't get me wrong, I would love to not do this manually especially since I am the one doing it

My thoughts on this would be to manually sort once so at least there is some consistency and then just wait until group imports is fixed in scalafix and fully automate

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446710

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

I agree with pjfaning here, the tool is not perfect, but better than hand rolling, we can tweak/fix that after the tool sort and fix that.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446781

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

refs: https://scalacenter.github.io/scalafix/docs/rules/OrganizeImports.html

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14447546

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "raboof (via GitHub)" <gi...@apache.org>.
GitHub user raboof added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

I see https://github.com/apache/pekko/pull/2229 already excludes the 'docs' project, so that might be fine?

I must admit I don't entirely understand the nuance of https://github.com/scalacenter/scalafix/issues/2100 - are we actually impacted by it? https://github.com/apache/pekko/pull/2229 looks kinda fine to me?

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14453448

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

yes, but after we tweak that, it's stable.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14454013

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
GitHub user mdedetrich added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

I already looked into it, there isn't an automated tool that satisfies our requirements, specifically

- scalafix doesn't support nested alias imports i.e. `import org.apache.pekko` followed up with `import pekko...` imports. See issue (that I have raised) https://github.com/scalacenter/scalafix/issues/2100
- Even if previous point is fixed, the biggest issue is our docs with paradox. You may have noticed that in the `docs` project, we have duplicated imports and this is intentional, its because we have paradox code snippets in multiple places i.e. `// #some snippet`. There is also an issue on this, see https://github.com/scalacenter/scalafix/issues/1793.

Aside from these problems, scalafix can solve all of our issues, there is no other tool that can sort imports the way we want (I already tried it in pekko some time ago)

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446340

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

`sbt sortInports` is a set up as a command alias in this repo and it has a `.scalafix.conf` that excludes the docs and jdocs packages. 

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446268

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

wdyt @kerr @ptrdom @raboof of https://github.com/apache/pekko-http/pull/791 ?

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446682

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

@mdedetrich The did a `sort imports` recently.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446899

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

I still remember I added that years ago, I think which actually works well, the doc of imports can be teweak anyway, but, that task will always give all a consistency result

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446509

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning edited a discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

* we want to maintain custom sorting in many of the scala files used for documentation - so if we could annotate the files that we don't want to sort automatically or exclude the docs directory, that would be ideal
* we tend to `import org.apache.pekko` so that we can save on the `org.apache` part when importing Pekko classes - so a sort tool that can handle that would be great - I am not wedded to maintaining this if it makes life easier to the tooling although I suspect that some people like them
* we waste a lot of time hand sorting imports and commenting on PRs asking for changes to imports 

In this repo, we have `sbt sortImports` - an alias setup to call scalafix commands. The output seems good but some how we don't use it.

GitHub link: https://github.com/apache/pekko/discussions/2228

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

@mdedetrich I created https://github.com/apache/pekko-http/pull/791

Where I copied the scalafix setup to pekko-http. The repo is a bit smaller so easier to review.
The pekko import seem fine to me.

I would really like to automate this. This manual sorting of imports takes a lot of time.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446653

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
GitHub user He-Pin added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

And there is https://scalameta.org/scalafmt/docs/configuration.html#imports-groups now, but I never tested that.

@kitbellew can scalafmt help, thanks

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446896

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "ptrdom (via GitHub)" <gi...@apache.org>.
GitHub user ptrdom added a comment to the discussion: Is there a way we could sbt or a sbt plugin to sort the imports how we want?

> If we merge instead of grouping then it should work fine.

Well, merge or explode. As I stated before I do prefer exploding.

GitHub link: https://github.com/apache/pekko/discussions/2228#discussioncomment-14446879

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [D] Is there a way we could get sbt or a sbt plugin to sort the imports how we want? [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
GitHub user pjfanning edited a discussion: Is there a way we could get sbt or a sbt plugin to sort the imports how we want?

* we want to maintain custom sorting in many of the scala files used for documentation - so if we could annotate the files that we don't want to sort automatically or exclude the docs directory, that would be ideal
* we tend to `import org.apache.pekko` so that we can save on the `org.apache` part when importing Pekko classes - so a sort tool that can handle that would be great - I am not wedded to maintaining this if it makes life easier to the tooling although I suspect that some people like them
* we waste a lot of time hand sorting imports and commenting on PRs asking for changes to imports 

In this repo, we have `sbt sortImports` - an alias setup to call scalafix commands. The output seems good but some how we don't use it.

GitHub link: https://github.com/apache/pekko/discussions/2228

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org