Skip to content

Fail on legacy config in modular projects#11702

Open
ascheman wants to merge 1 commit intoapache:masterfrom
support-and-care:bugfix/11701-fail-on-modular-sources-with-legacy-dirs
Open

Fail on legacy config in modular projects#11702
ascheman wants to merge 1 commit intoapache:masterfrom
support-and-care:bugfix/11701-fail-on-modular-sources-with-legacy-dirs

Conversation

@ascheman
Copy link
Contributor

@ascheman ascheman commented Feb 6, 2026

Summary

  • Legacy directories and resources that conflict with modular sources now trigger an ERROR instead of WARNING
  • Prevents silent loss of user-configured sources/resources
  • AC8 supersedes AC7 which originally used WARNING

Affected configurations in modular projects:

  • Explicit <sourceDirectory>/<testSourceDirectory> differing from defaults
  • Default src/main/java or src/test/java existing on filesystem
  • Explicit <resources>/<testResources> differing from Super POM defaults

Test plan

  • ProjectBuilderTest#testModularSourcesWithExplicitResourcesIssuesError passes
  • ProjectBuilderTest#testMixedSourcesModularMainClassicTest passes

Fixes #11701
See #11701 (comment)

🤖 Generated with Claude Code

In modular projects, legacy directories and resources that would be
silently ignored now trigger an ERROR instead of WARNING:

- Explicit <sourceDirectory>/<testSourceDirectory> differing from defaults
- Default src/main/java or src/test/java existing on filesystem
- Explicit <resources>/<testResources> differing from Super POM defaults

This prevents silent loss of user-configured sources/resources.
AC8 supersedes AC7 which originally used WARNING.

Fixes apache#11701
See apache#11701 (comment)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ascheman ascheman force-pushed the bugfix/11701-fail-on-modular-sources-with-legacy-dirs branch from 70a7358 to c1b431b Compare February 6, 2026 10:05
@ascheman ascheman marked this pull request as ready for review February 6, 2026 13:27
@ascheman
Copy link
Contributor Author

ascheman commented Feb 6, 2026

Reviews are welcome, in particular from @elharo and @desruisseaux - thanks!

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not obvious to me how claude code is being used here. Generally I would not expect simply pointing it at this issue without human editing to produce correct results.

*
* Additionally, for modular projects, legacy directories are unconditionally
* ignored because it is not clear how to dispatch their content between
* rejected because it is not clear how to dispatch their content between
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is what we were looking for. The build fails completely, not simply a warning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposal: replace "A warning is emitted if …" by "The build fails if …".

* </ul>
* Legacy directories are unconditionally ignored in modular projects because it is not clear
* how to dispatch their content between different modules.
* In both cases, the legacy directory conflicts with modular sources and must not be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not "and must not be used" but rather the complete build fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not "and must not be used" but rather the complete build fails.

Isn't what the next line below is saying?

scopeId,
sourcesConfig);
String message = String.format(
"Legacy %s element must not be used because %s resources are configured via %s in <sources>.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must not be used --> cannot be used in modular projects

if (hasExplicitLegacyResources(resources, scopeId)) {
String message = "Legacy " + legacyElement
+ " element is ignored because modular sources are configured. "
+ " element must not be used because modular sources are configured. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must not --> cannot

scopeId,
sourcesConfig);
String message = String.format(
"Legacy %s element must not be used because %s resources are configured via %s in <sources>.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot

* Acceptance Criterion: AC2 (unified source tracking for all lang/scope combinations)
* Acceptance Criteria:
* - AC2 (unified source tracking for all lang/scope combinations)
* - AC8 (legacy directories error - supersedes AC7 which originally used WARNING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how the AC are being used, but shouldn't AC7 be changed rather than superseded?

* In modular projects, legacy directories are unconditionally ignored because it is not clear
* how to dispatch their content between different modules. A warning is emitted if these
* properties are explicitly set (differ from Super POM defaults).
* In modular projects, legacy directories must not occur because it is not clear
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In modular projects, legacy directories must not occur --> Legacy directories cannot be used in modular projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy resources in modular build should fail

3 participants