I want to get programmatically in any form a list of default packages imported by Groovy. Like the documentation says:
All these packages and classes are imported by default, i.e. you do not have to use an explicit import statement to use them: java.io.*
java.lang.*
java.math.BigDecimal
java.math.BigInteger
java.net.*
java.util.*
groovy.lang.*
groovy.util.*
In others words, check whether import is required (for any classes out of this list) or not. The List should be valid for current version and potentially for future versions.
The static variable org.codehaus.groovy.control.ResolveVisitor.DEFAULT_IMPORTS
is an array of String
that contains all default imported package names.
Currently it's (printed) value is:
[java.lang., java.io., java.net., java.util., groovy.lang., groovy.util.]
Check the ResolveVisitor doc for more info. If you want to know how to add custom packages to the defaults check this Jira issue.
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