-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default import of java.time.* #346
Conversation
333b05b
to
c97acd9
Compare
src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy
Outdated
Show resolved
Hide resolved
@@ -652,6 +654,31 @@ class GrailsGradlePlugin extends GroovyPlugin { | |||
output?.classesDirs ?: project.files(new File(project.buildDir, "classes/main")) | |||
} | |||
|
|||
protected void configureJavaTime(Project project) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is autoImportDateTimeApi(Project project)
a more descriptive name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this isn't just auto importing DateTime. I think it is importing java.time.*
. Is that the case? If it is, I don't think autoImportDateTimeApi
is a good name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, autoImportDateTimeApi
is at least the sentiment of what we are trying to do. There are of course a couple of sub-packages that also belong to the DateTime Api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand now. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matrei my sentiment was always just import java.time.* and that is why I named it JavaTime. Are you suggesting we should import everything else?
java.time.chrono.*
java.time.format.*
java.time.temporal.*
java.time.zone.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting we should import everything else?
I don't know. Are there any drawbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if it is necessary or needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the groovy examples only needed:
import java.time.*
import static java.time.temporal.ChronoField.*
import java.time.temporal.ChronoUnit
import java.time.format.FormatStyle
to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matrei drawback is that I am not a fan of start imports to begin with, but I feel we need to offer a smooth painless transition away from the java Date class.
src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Outdated
Show resolved
Hide resolved
src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Outdated
Show resolved
Hide resolved
src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Outdated
Show resolved
Hide resolved
@@ -654,31 +674,6 @@ class GrailsGradlePlugin extends GroovyPlugin { | |||
output?.classesDirs ?: project.files(new File(project.buildDir, "classes/main")) | |||
} | |||
|
|||
protected void configureJavaTime(Project project) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I meant to keep this method (although with a different name), and call it from the configureGroovy method.
protected void configureGroovy(Project project) {
// some other stuff
if (grailsExt.autoImportDateTimeApi) {
autoImportDateTimeApi(project)
}
}
I am going to merge this. I am not opposed to any changes. I just want to keep things moving. The discussion can continue and this can continue to evolve, but there are other areas right now where this needs to be expanded on and the work can not continue without the merge. For instance, LocalDateTime currently does not render an input. Let's continue discussion in #345 |
Enables smooth transition from legacy java.util.Date to java.time
Fixes #345