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


##########
grails-core/src/main/groovy/org/grails/compiler/injection/GlobalGrailsClassInjectorTransformation.groovy:
##########
@@ -56,140 +61,156 @@ import org.grails.io.support.GrailsResourceUtils
 import org.grails.io.support.UrlResource
 
 /**
- * A global transformation that applies Grails' transformations to classes 
within a Grails project
+ * Global AST transformation that applies Grails compiler injection to Grails 
project sources,
+ * including applications and plugins.
+ *
+ * <p>It identifies Grails artefacts, applies the relevant {@link 
ClassInjector} and
+ * {@link grails.compiler.traits.TraitInjector} implementations, and registers 
artefact handlers
+ * and injector implementations. When compiling a plugin descriptor, it also 
creates or updates
+ * the {@code META-INF/grails-plugin.xml} descriptor and records transformed 
plugin resources.</p>
  *
- * @author Graeme Rocher
  * @since 3.0
  */
-@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
+@Slf4j
 @CompileStatic
+@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
 class GlobalGrailsClassInjectorTransformation implements ASTTransformation, 
CompilationUnitAware, TransformWithPriority {
 
+    /**
+     * The system property signalling that a multi-project build compiles each 
project into its own
+     * isolated output directory. When set, the transform must never fall back 
to a shared or guessed
+     * location, which could leak one module's generated metadata into another.
+     */
+    public static final String ISOLATED_BUILD_PROPERTY = 
'grails.isolated.build'
+
+    public static final ClassNode ARTEFACT_CLASS_NODE = new ClassNode(Artefact)
     public static final ClassNode ARTEFACT_HANDLER_CLASS = 
ClassHelper.make('grails.core.ArtefactHandler')
     public static final ClassNode TRAIT_INJECTOR_CLASS = 
ClassHelper.make('grails.compiler.traits.TraitInjector')
 
+    static LinkedHashSet<String> pendingPluginClassNames = []
+    static Collection<String> pluginExcludePatterns = []

Review Comment:
   Both `pendingPluginClassNames` and `pluginExcludePatterns` are mutable 
`static` state that is updated/cleared during compilation. If compilation runs 
concurrently (e.g., parallel Gradle workers / multiple compilation units in the 
same JVM), this can cause cross-talk between projects/source units and produce 
incorrect plugin descriptors. A safer approach is to store this state on the 
`CompilationUnit`, `SourceUnit`, or in node metadata (or use a `ThreadLocal` 
keyed by compilation), so concurrent compilations can’t interfere with each 
other.



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