codeconsole commented on code in PR #15118:
URL: https://github.com/apache/grails-core/pull/15118#discussion_r2412453816


##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -226,17 +226,47 @@ class GrailsGradlePlugin extends GroovyPlugin {
 
     protected Closure<String> getGroovyCompilerScript(GroovyCompile compile, 
Project project) {
         GrailsExtension grails = project.extensions.findByType(GrailsExtension)
-        if (!grails.importJavaTime) {
+
+        List<String> starImports = []
+
+        // Add java.time if enabled
+        if (grails.importJavaTime) {
+            starImports.add('java.time')
+        }
+
+        // Add Grails annotation packages if enabled and dependencies are 
present
+        if (grails.importGrailsAnnotations) {
+            // Check for grails-datamapping-core (grails.gorm.annotation.*)
+            def datamappingCoreDep = 
project.configurations.getByName('compileClasspath').dependencies.find { 
Dependency d ->
+                d.group == 'org.apache.grails.data' && d.name == 
'grails-datamapping-core'
+            }
+            if (datamappingCoreDep) {
+                starImports.add('grails.gorm.annotation')
+            }
+
+            // Check for grails-scaffolding 
(grails.plugin.scaffolding.annotation.*)
+            def scaffoldingDep = 
project.configurations.getByName('compileClasspath').dependencies.find { 
Dependency d ->
+                d.group == 'org.apache.grails' && d.name == 
'grails-scaffolding'
+            }
+            if (scaffoldingDep) {
+                starImports.add('grails.plugin.scaffolding.annotation')
+            }

Review Comment:
   @sbglasius I agree it could of been in a separate PR, but it's kind of a 
gray area because the added config is `importGrailsAnnotations` and that is 
just adding 1 annotation `@Scaffold`.  Plus there is a lot I want to address 
and the latency in getting PRs reviewed is a bit slow at the moment for what I 
want to get added/fixed.
   
   The motivation for this PR is actually for `importGrailsAnnotations`.    I 
was originally against 
   @matrei  's suggest of having 2 different annotations for AutoTimestamp 
because of the extra import statement on every domain class, but with 
`importGrailsAnnotations`, I don't mind. 
   
    In fact, with `importGrailsAnnotations`, I am even willing to get rid of 
`@AutoTimestamp` now. @matrei what are your thoughts about getting rid of 
`@AutoTimestamp`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to