How can I set up my intellij style xml file to organise imports in a specific order?
Answered
Intellij keeps reordering my imports like so:
import app.v1.myModule.db.model.InternalError;
import app.v1.myModule.db.model.*;
Whereas our maven checkstyle wants the order like so:
import app.v1.myModule.db.model.*;
import app.v1.myModule.db.model.InternalError;
I should also point out, that this doesn't apply to all the imports, only some of them. I'd like to set it so intellij organises all packages that end with a * to be sorted above fully qualified imports on the same path?
So like this:
import app.v1.myModule.db.model.*;
import app.v1.myModule.db.model.InternalError;
import app.v1.myModule.service.*;
import app.v1.myModule.service.MyService;
For the record, the extra classes are added when the import is ambiguous, so we can't use the * for those particular classes.
Please sign in to leave a comment.
Hi Paul,
There is no option at the moment to do it automatically I'm afraid, but a feature request for this already exists in our system:
I added your current feedback to the issue's comment thread for devs' reference. Feel free to upvote the issue.