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

Java importOrder support for sorting wildcards last #954

Merged

Conversation

hakanai
Copy link
Contributor

@hakanai hakanai commented Oct 1, 2021

Adds support for sorting wildcards after non-wildcards in the import list. Gradle config like so:

importOrder('java', 'javax', 'com.acme', '').wildcardsLast()

Not implemented here: Maven plugin support

Fixes #879.

Allow edits from maintainers

After creating the PR, please add a commit that adds a bullet-point under the -SNAPSHOT section of CHANGES.md, plugin-gradle/CHANGES.md, and plugin-maven/CHANGES.md which includes:

  • a summary of the change
  • either
    • a link to the issue you are resolving (for small changes)
    • a link to the PR you just created (for big changes likely to have discussion)

If your change only affects a build plugin, and not the lib, then you only need to update the CHANGES.md for that plugin.

If your change affects lib in an end-user-visible way (fixing a bug, updating a version) then you need to update CHANGES.md for both the lib and the build plugins. Users of a build plugin shouldn't have to refer to lib to see changes that affect them.

This makes it easier for the maintainers to quickly release your changes :)

Adds support for sorting wildcards after non-wildcards in the import list. Gradle config like so:

```
importOrder('java', 'javax', 'com.acme', '').wildcardsLast()
```

Not implemented here: Maven plugin support

Fixes diffplug#879.
@hakanai
Copy link
Contributor Author

hakanai commented Oct 1, 2021

What to do about Maven? Do all new features have to be added for both at the same time to get in?

@tisoft
Copy link
Contributor

tisoft commented Oct 1, 2021

I could do maven support as soon as this is in

@nedtwigg
Copy link
Member

nedtwigg commented Oct 1, 2021

Do all new features have to be added for both at the same time to get in?

Nope, from our readme:

If you want to add Bazel support, we'd happily accept the PR even if it only supports the one formatter you use. And if you want to add FooFormatter support, we'll happily accept the PR even if it only supports the one build system you use. ... Once someone has filled in one square of the formatter/build system matrix, it's easy for interested parties to fill in any empty squares, since you'll now have a working example for every piece needed.

Copy link
Member

@nedtwigg nedtwigg left a comment

Choose a reason for hiding this comment

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

Great PR! Needs just a few minor changes.

@hakanai
Copy link
Contributor Author

hakanai commented Oct 1, 2021

Requested changes made, separate commit for now but could squash later if necessary.

@nedtwigg
Copy link
Member

nedtwigg commented Oct 1, 2021

Run spotlessApply to fix CI and this is good :)

@hakanai
Copy link
Contributor Author

hakanai commented Oct 1, 2021

Results in no changes. Though spotlessCheck fails, it's on one of the dotfiles that I haven't actually touched.

@nedtwigg
Copy link
Member

nedtwigg commented Oct 1, 2021

Hm, very strange. Can you confirm that you have origin/main in your checkout? Maybe you called origin something else? CI is giving the failure I would expect around license dates.

https://app.circleci.com/pipelines/github/diffplug/spotless/1297/workflows/e52e8deb-cf23-4ff4-bf4f-f1027d15653d/jobs/7362

I can run spotlessApply myself, but I'd like to debug why yours isn't working. What dotfile is Spotless failing on?

@hakanai
Copy link
Contributor Author

hakanai commented Oct 1, 2021

It was .editorconfig but it looked like the diff contained the whole file so I'm guessing it's line endings.

I applied the diffs that were in the CI failure for the Java files so those should be OK now.

As for my remotes,

> git remote -v
origin  https://github.com/hakanai/spotless (fetch)
origin  https://github.com/hakanai/spotless (push)

@nedtwigg nedtwigg merged commit 72e8c21 into diffplug:main Oct 1, 2021
@nedtwigg
Copy link
Member

nedtwigg commented Oct 2, 2021

Fixed in plugin-gradle 5.16.0, thanks for the PR!

@jbduncan
Copy link
Member

jbduncan commented Oct 2, 2021

Great addition @hakanai, so thank you for your PR. :)

@hakanai
Copy link
Contributor Author

hakanai commented Oct 2, 2021

Just glad I finally found a bit of time to do the work. Should reduce IDEA-related suffering at work quite a bit.

nedtwigg added a commit that referenced this pull request Oct 4, 2021
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.

Ability to configure static import sorting to match behaviour of IntelliJ IDEA
4 participants