desruisseaux commented on code in PR #11505:
URL: https://github.com/apache/maven/pull/11505#discussion_r2637950437


##########
impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java:
##########
@@ -1099,6 +1123,193 @@ public Set<Entry<K, V>> entrySet() {
         }
     }
 
+    /**
+     * Context object for resource handling configuration.
+     * Groups parameters shared between main and test resource handling to 
reduce method parameter count.
+     */
+    private record ResourceHandlingContext(
+            MavenProject project,
+            Path baseDir,
+            Set<String> modules,
+            boolean modularProject,
+            ModelBuilderResult result) {}
+
+    /**
+     * Handles resource configuration for a given scope (main or test).
+     * This method applies the resource priority rules:
+     * <ol>
+     *   <li>Modular project: use resources from {@code <sources>} if present, 
otherwise inject defaults</li>
+     *   <li>Classic project: use resources from {@code <sources>} if present, 
otherwise use legacy resources</li>
+     * </ol>
+     *
+     * @param context the resource handling context containing project info
+     * @param resources the legacy resource list (from {@code <resources>} or 
{@code <testResources>})
+     * @param hasResourcesInSources whether resources are configured via 
{@code <sources>}
+     * @param scope the project scope (MAIN or TEST)
+     */
+    private void handleResourceConfiguration(

Review Comment:
   If `hasExplicitLegacyResources` and `createModularResourceRoot` methods 
become static, then the only field that `handleResourceConfiguration` uses is 
`logger`. We could:
   
   * Add the logger field in `ResourceHandlingContext`.
   * Move this method into `ResourceHandlingContext`. It would simplify a 
little bit the code (remove 15 occurrences of `context`, can access protected 
fields such as `baseDir` directly).
   * Rename `ResourceHandlingContext` as `ResourceHandling` and promote as a 
package-private (non inner) class. It would allow to isolate the resource 
handling code in a separated source Java file.
   * Move the static `hasExplicitLegacyResources` and 
`createModularResourceRoot` methods in `ResourceHandling` too. It would 
complete the isolation of resource handling code.



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