By default some packages are imported in a Groovy class. I know that you can add new one with an ImportCustomizer but is there a way to remove them programmatically?
Thanks in advance for your answers.
By default some packages are imported in a Groovy class. I know that you can add new one with an ImportCustomizer but is there a way to remove them programmatically?
Thanks in advance for your answers.
No. If you look through the code, then you'll see that the standard imports like
java.io
andjava.math.BigDecimal
are not handled byImportCustomizer
.Which is a pity.
The default imports are handled in ResolveVisitor.java. The code doesn't allow to modify the default imports or the method where they are added.
Kudos to andrei-krotkov for finding the code.
It is not a pretty good solution but it works: