For some imports, I may want to keep a *
import even I am currently using only 1-2 classes/methods. For example, I may want to import org.mockito.Mockito.*
even I am currently using only a few of them, because when my test grows, I will need to use more static method under Mockito
. However Organize Imports function in Eclipse always break down my import to import individual methods (which is the preferred behavior in most case).
Is there a way to let me control such behavior in package basis? i.e. I want to keep importing *
for some packages (or disabling auto-break-down feature), but for other packages, I would want to use Eclipse's default behavior (deciding *
base on number of classes/methods used)
You can't change the policy for individual imported packages or classes, but you can set the overall threshold lower so that Organize Imports won't convert the wildcard import to individual ones. Go to Preferences > Java > Code Style > Organize Imports and then edit the Number of static imports needed... value to something small, like 2.
With it set to a small number, you can manually add a wildcard import and as long as the class uses at least the threshold number of methods, Eclipse will leave it alone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With