[ https://issues.apache.org/jira/browse/GROOVY-11513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947514#comment-17947514 ]
Paul King commented on GROOVY-11513: ------------------------------------ Just a couple of extra points to round out the conversation. You could argue that we don't need to add more default imports since frameworks can add their own default imports using compiler configuration. Having said that, java.time is a widely used package with plain groovy scripts outside any frameworks. A long time ago the idea of more flexible ways to specify default imports was discussed as an idea but never actioned. Thoughts were to add one or more of: * A known metadata file in META-INF/groovy to describe additional default imports, much like we have for source extensions and extension method classes. So, you could, as an example, only add java.time for users that have the groovy-datetime jar on their classpath, or have a groovy-autodatetime jar with nothing in it except the META-INF file. * Provide additional commandline switches In the end we just went with compiler config. One concern was when folks asked questions about why their program behaved in some strange way, we'd potentially have to ask them what default imports they might happen to have specified. > java.time.* should be imported automatically > -------------------------------------------- > > Key: GROOVY-11513 > URL: https://issues.apache.org/jira/browse/GROOVY-11513 > Project: Groovy > Issue Type: Improvement > Components: Compiler > Affects Versions: 4.0.23 > Reporter: Scott Murphy Heiberg > Assignee: Eric Milles > Priority: Major > Labels: breaking > > if java.time is the recommended way to proceed forward when dealing with > dates, > java.time.* should be included automatically similar to how java.util.Date is > currently available without import. > The preferred approach would be to make it a global import which would be in > line with existing Groovy handling of java.util.Date > > The least invasive approach would be to make the import only apply if > groovy-datetime module has been added. > > implementation "org.apache.groovy:groovy-datetime" > > should automatically import java.time.* to all classes > > This provides an easier migration path from Date -> DateTIme > [https://groovy.apache.org/blog/groovy-dates-and-times-cheat] -- This message was sent by Atlassian Jira (v8.20.10#820010)