ascheman commented on code in PR #11632:
URL: https://github.com/apache/maven/pull/11632#discussion_r2688175826
##########
impl/maven-core/src/main/java/org/apache/maven/project/SourceHandlingContext.java:
##########
@@ -59,6 +80,73 @@ class ResourceHandlingContext {
this.result = result;
}
+ /**
+ * Determines if a source root should be added to the project and tracks
it for duplicate detection.
+ * <p>
+ * Rules:
+ * <ul>
+ * <li>Disabled sources are always added (they're filtered by {@code
getEnabledSourceRoots()})</li>
+ * <li>First enabled source for an identity is added and tracked</li>
+ * <li>Subsequent enabled sources with same identity trigger a WARNING
and are NOT added</li>
+ * </ul>
+ *
+ * @param sourceRoot the source root to evaluate
+ * @return true if the source should be added to the project, false if
it's a duplicate enabled source
+ */
+ boolean shouldAddSource(SourceRoot sourceRoot) {
+ if (!sourceRoot.enabled()) {
+ // Disabled sources are always added - they're filtered out by
getEnabledSourceRoots()
+ LOGGER.debug(
+ "Adding disabled source (will be filtered by
getEnabledSourceRoots): lang={}, scope={}, module={}, dir={}",
+ sourceRoot.language(),
+ sourceRoot.scope(),
+ sourceRoot.module().orElse(null),
+ sourceRoot.directory());
+ return true;
+ }
+
+ SourceKey key = new SourceKey(
+ sourceRoot.language(), sourceRoot.scope(),
sourceRoot.module().orElse(null), sourceRoot.directory());
Review Comment:
Used `.toAbsolutePath().normalize()` instead in commit 63d43d5154.
`toRealPath()` requires the file to exist on the filesystem and throws
IOException if it doesn't, which would break duplicate detection for source
directories that don't exist yet. The `normalize()` approach handles relative
paths and `..` components without requiring filesystem access.
--
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]