ascheman commented on code in PR #11505:
URL: https://github.com/apache/maven/pull/11505#discussion_r2642159709
##########
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(
+ ResourceHandlingContext context,
+ List<Resource> resources,
+ boolean hasResourcesInSources,
+ ProjectScope scope) {
+
+ String scopeId = scope.id();
+ String scopeName = scope == ProjectScope.MAIN ? "Main" : "Test";
+ String legacyElement = scope == ProjectScope.MAIN ? "<resources>" :
"<testResources>";
+ String sourcesConfig = scope == ProjectScope.MAIN
+ ? "<source><lang>resources</lang></source>"
+ : "<source><lang>resources</lang><scope>test</scope></source>";
+
+ if (context.modularProject()) {
+ if (hasResourcesInSources) {
+ // Modular project with resources configured via <sources> -
already added above
+ if (hasExplicitLegacyResources(resources, context.baseDir(),
scopeId)) {
+ logger.warn(
+ "Legacy {} element is ignored because {} resources
are configured via {} in <sources>",
Review Comment:
Done in d2ce972700. Added periods to all log and warning messages.
--
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]