简体   繁体   中英

Getting Eclipse Java Organize Imports to work with Google checkstyle

So when I use the Ctrl+Shift+O shortcut to organize my Java imports it puts a space between packages that begin with a different root package. For example:

import java.util.Map;
import java.util.Set;

import work.enumeration.Generation;

This is incompatible with Google's checkstyle and I would like to fix this. I have tried going to Window > Preferences > Java > Code Style > Formatter > Edit > Blank Lines > Blank lines within compilation unit > Between import groups and setting it to 0, but this has not fixed the Organize Imports action.

So I'm wondering how I go about resolving this. I would also like to set up Organize Imports to put a line between static and regular imports.

As @greg-449 said in a comment on the question, adding a single "*" import group in the Organize Imports preference and deleting the existing ones (java, javax, com, org) will eliminate the single line spaces between packages.

As I said in the following comment, adding a single "*" static import group in the Organize Imports preference and placing it above the regular import group should keep the static imports and imports separated by one line.

The Organize Imports preference can be found at Window > Preferences > Java > Code Style > Organize Imports .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM