Copilot commented on code in PR #15570:
URL: https://github.com/apache/grails-core/pull/15570#discussion_r3068305903


##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -23,11 +23,13 @@ import java.nio.charset.StandardCharsets
 import java.util.concurrent.atomic.AtomicBoolean
 
 import groovy.transform.CompileStatic
+import groovy.transform.TypeCheckingMode
 
 import org.gradle.api.Plugin
 import org.gradle.api.Project
 import org.gradle.api.file.DuplicatesStrategy
 import org.gradle.api.plugins.JavaPluginExtension
+import org.gradle.api.tasks.SourceSetContainer

Review Comment:
   `SourceSetContainer` is imported but not used anywhere in this file. The 
build-logic code style rules include `UnusedImport` / `UnusedImports`, so this 
will likely fail CodeNarc/Checkstyle—please remove the unused import.



##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy:
##########
@@ -111,6 +114,33 @@ class CompilePlugin implements Plugin<Project> {
         }
     }
 
+    @CompileStatic(TypeCheckingMode.SKIP)
+    private static void configureAnnotationProcessors(Project project) {
+        // Configure Spring Boot configuration processor for modules with 
@ConfigurationProperties.
+        // Groovy modules intentionally avoid annotation processors due to 
incompatibility
+        // with incremental Groovy compilation (see issue #15211).
+        // Modules must opt-in via 'enableAnnotationProcessor = true' property.
+        project.afterEvaluate {
+            try {
+                // Check if this module has opted in to annotation processor 
support
+                def ext = project.extensions.extraProperties
+                def enableProcessor = ext.has('enableAnnotationProcessor') && 
ext.get('enableAnnotationProcessor') == true
+                
+                if (enableProcessor) {
+                    // Add annotation processor dependencies for modules with 
@ConfigurationProperties
+                    
project.configurations.getByName('annotationProcessor').dependencies.add(
+                        
project.dependencies.platform(project.project(':grails-bom'))
+                    )
+                    
project.configurations.getByName('annotationProcessor').dependencies.add(
+                        
project.dependencies.create('org.springframework.boot:spring-boot-configuration-processor')
+                    )
+                }
+            } catch (Exception ignored) {
+                // Configuration not available for this module
+            }

Review Comment:
   `configureAnnotationProcessors` swallows *all* exceptions and silently does 
nothing. If a module opts in (`enableAnnotationProcessor = true`) and wiring 
fails (e.g., missing `annotationProcessor` configuration or `:grails-bom` 
project), this will be hard to detect and can lead to missing metadata 
generation. Prefer checking `configurations.findByName('annotationProcessor')` 
/ `rootProject.findProject(':grails-bom')` and either fail fast or at least log 
a warning when opt-in is true but setup cannot be applied; avoid catching 
generic `Exception`.



-- 
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