Skip to content

Unify source tracking with SourceHandlingContext (#11612)#11632

Merged
desruisseaux merged 5 commits intoapache:masterfrom
support-and-care:feature/11612-source-handling-context
Feb 5, 2026
Merged

Unify source tracking with SourceHandlingContext (#11612)#11632
desruisseaux merged 5 commits intoapache:masterfrom
support-and-care:feature/11612-source-handling-context

Conversation

@ascheman
Copy link
Contributor

@ascheman ascheman commented Jan 7, 2026

Summary

  • Replace boolean flags (hasMain, hasTest, hasMainResources, etc.) with flexible set-based tracking using SourceHandlingContext
  • Rename ResourceHandlingContext to SourceHandlingContext to reflect unified handling of all source types
  • Add duplicate detection: first enabled source wins, duplicates trigger WARNING
  • Add hasSources(Language, ProjectScope) method for checking source existence
  • Replace Collectors.toList() with .toList() (Java 17+ idiom)

Closes #11612 (Phase 2: build-sources-validation)

Test plan

  • ProjectBuilderTest passes (19 tests)
  • New tests added:
    • testModularSourcesInjectResourceRoots - verifies module-aware resource injection
    • testModularSourcesWithExplicitResourcesIssuesWarning - verifies legacy resource warnings
    • testMixedSourcesModularMainClassicTest - mixed modular/classic configuration
    • testSourcesMixedModulesWithinSources - mixed modules within <sources>
    • testMultipleDirectoriesSameModule - multiple directories per module
    • testDuplicateEnabledSources - duplicate detection with WARNING

🤖 Generated with Claude Code

@ascheman ascheman force-pushed the feature/11612-source-handling-context branch from 159d2ae to 63d43d5 Compare January 13, 2026 21:14
ascheman and others added 4 commits February 1, 2026 14:48
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>
@ascheman ascheman force-pushed the feature/11612-source-handling-context branch from 63d43d5 to 19fd98d Compare February 1, 2026 13:56
- 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 desruisseaux self-requested a review February 1, 2026 16:35
@desruisseaux
Copy link
Contributor

@gnodet or others, any objection in merging this commit?

@desruisseaux desruisseaux merged commit f97bac3 into apache:master Feb 5, 2026
22 checks passed
@github-actions github-actions bot added this to the 4.1.0 milestone Feb 5, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-4.0.x enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unified source handling for all lang/scope combinations with modular sources (Phase 2)

3 participants