Unify source tracking with SourceHandlingContext (#11612)#11632
Merged
desruisseaux merged 5 commits intoapache:masterfrom Feb 5, 2026
Merged
Conversation
impl/maven-core/src/main/java/org/apache/maven/project/SourceHandlingContext.java
Outdated
Show resolved
Hide resolved
impl/maven-core/src/main/java/org/apache/maven/project/SourceHandlingContext.java
Outdated
Show resolved
Hide resolved
impl/maven-core/src/main/java/org/apache/maven/project/SourceHandlingContext.java
Outdated
Show resolved
Hide resolved
impl/maven-core/src/main/java/org/apache/maven/project/SourceHandlingContext.java
Show resolved
Hide resolved
impl/maven-core/src/main/java/org/apache/maven/project/SourceHandlingContext.java
Show resolved
Hide resolved
impl/maven-core/src/test/projects/project-builder/mixed-sources/pom.xml
Outdated
Show resolved
Hide resolved
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
impl/maven-core/src/test/projects/project-builder/sources-mixed-modules/pom.xml
Outdated
Show resolved
Hide resolved
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
159d2ae to
63d43d5
Compare
Replace boolean flags (hasMain, hasTest, etc.) with flexible set-based tracking for all language/scope combinations. - Rename ResourceHandlingContext to SourceHandlingContext - Add duplicate detection with WARNING for enabled sources - Add hasSources() method for checking language/scope combinations - Rename 'src' variable to 'sourceRoot' for clarity 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use Java 17+ Stream.toList() instead of Collectors.toList(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Normalize path separators to forward slashes before comparing directory paths in tests. On Windows, Path.toString() returns backslashes, causing contains() checks with forward slashes to fail. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement validation rules for modular source handling (apache#11612): - AC6: ERROR when mixing modular (with module) and classic (without module) sources within <sources> - AC7: WARNING when legacy <sourceDirectory>/<testSourceDirectory> are used in modular projects (both explicit config and filesystem existence) Changes: - Add validateNoMixedModularAndClassicSources() to SourceHandlingContext - Add warnIfExplicitLegacyDirectory() to DefaultProjectBuilder - Update tests to verify AC6 and AC7 behavior - Update test project comments to reflect correct behavior Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
63d43d5 to
19fd98d
Compare
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
Outdated
Show resolved
Hide resolved
desruisseaux
reviewed
Feb 1, 2026
impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
Outdated
Show resolved
Hide resolved
- Use flatMap(Optional::stream) instead of filter/map - Use File.separatorChar instead of hardcoded backslash - Simplify module checks with orElse(null) - Make getProfileIds() static Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
desruisseaux
approved these changes
Feb 1, 2026
Contributor
|
@gnodet or others, any objection in merging this commit? |
rmannibucau
approved these changes
Feb 4, 2026
desruisseaux
pushed a commit
to Geomatys/maven
that referenced
this pull request
Feb 5, 2026
This is a combination of pull requests apache#11505 and apache#11632 on master branch. Summary: Maven 4.x introduces a unified <sources> element that supports modular project layouts (src/<module>/<scope>/<lang>). However, resource handling did not follow the modular layout - resources were always loaded from the legacy <resources> element which defaults to src/main/resources. This change implements automatic module-aware resource injection. - For modular projects without resource configuration in <sources>, automatically inject resource roots following the modular layout: src/<module>/main/resources and src/<module>/test/resources - Resources configured via <sources> take priority over legacy <resources> - Issue warnings (as ModelProblem) when explicit legacy resources are ignored
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hasMain,hasTest,hasMainResources, etc.) with flexible set-based tracking usingSourceHandlingContextResourceHandlingContexttoSourceHandlingContextto reflect unified handling of all source typeshasSources(Language, ProjectScope)method for checking source existenceCollectors.toList()with.toList()(Java 17+ idiom)Closes #11612 (Phase 2: build-sources-validation)
Test plan
ProjectBuilderTestpasses (19 tests)testModularSourcesInjectResourceRoots- verifies module-aware resource injectiontestModularSourcesWithExplicitResourcesIssuesWarning- verifies legacy resource warningstestMixedSourcesModularMainClassicTest- mixed modular/classic configurationtestSourcesMixedModulesWithinSources- mixed modules within<sources>testMultipleDirectoriesSameModule- multiple directories per moduletestDuplicateEnabledSources- duplicate detection with WARNING🤖 Generated with Claude Code