@@ -422,19 +422,21 @@ void testModularSourcesInjectResourceRoots() throws Exception {
422422 }
423423
424424 /**
425- * Tests that when modular sources are configured alongside explicit legacy resources,
426- * the legacy resources are ignored and a warning is issued.
425+ * Tests that when modular sources are configured alongside explicit legacy resources, an error is raised.
427426 * <p>
428427 * This verifies the behavior described in the design:
429- * - Modular projects with explicit legacy {@code <resources>} configuration should issue a warning
428+ * - Modular projects with explicit legacy {@code <resources>} configuration should raise an error
430429 * - The modular resource roots are injected instead of using the legacy configuration
431430 * <p>
432- * Acceptance Criterion: AC2 (unified source tracking for all lang/scope combinations)
431+ * Acceptance Criteria:
432+ * - AC2 (unified source tracking for all lang/scope combinations)
433+ * - AC8 (legacy directories error - supersedes AC7 which originally used WARNING)
433434 *
434435 * @see <a href="https://github.com/apache/maven/issues/11612">Issue #11612</a>
436+ * @see <a href="https://github.com/apache/maven/issues/11701#issuecomment-3858462609">AC8 definition</a>
435437 */
436438 @ Test
437- void testModularSourcesWithExplicitResourcesIssuesWarning () throws Exception {
439+ void testModularSourcesWithExplicitResourcesIssuesError () throws Exception {
438440 File pom = getProject ("modular-sources-with-explicit-resources" );
439441
440442 MavenSession mavenSession = createMavenSession (null );
@@ -447,19 +449,19 @@ void testModularSourcesWithExplicitResourcesIssuesWarning() throws Exception {
447449
448450 MavenProject project = result .getProject ();
449451
450- // Verify warnings are issued for ignored legacy resources
451- List <ModelProblem > warnings = result .getProblems ().stream ()
452- .filter (p -> p .getSeverity () == ModelProblem .Severity .WARNING )
453- .filter (p -> p .getMessage ().contains ("Legacy" ) && p .getMessage ().contains ("ignored " ))
452+ // Verify errors are raised for conflicting legacy resources (AC8)
453+ List <ModelProblem > errors = result .getProblems ().stream ()
454+ .filter (p -> p .getSeverity () == ModelProblem .Severity .ERROR )
455+ .filter (p -> p .getMessage ().contains ("Legacy" ) && p .getMessage ().contains ("must not be used " ))
454456 .toList ();
455457
456- assertEquals (2 , warnings .size (), "Should have 2 warnings (one for resources, one for testResources)" );
458+ assertEquals (2 , errors .size (), "Should have 2 errors (one for resources, one for testResources)" );
457459 assertTrue (
458- warnings .stream ().anyMatch (w -> w .getMessage ().contains ("<resources>" )),
459- "Should warn about ignored <resources>" );
460+ errors .stream ().anyMatch (e -> e .getMessage ().contains ("<resources>" )),
461+ "Should error about conflicting <resources>" );
460462 assertTrue (
461- warnings .stream ().anyMatch (w -> w .getMessage ().contains ("<testResources>" )),
462- "Should warn about ignored <testResources>" );
463+ errors .stream ().anyMatch (e -> e .getMessage ().contains ("<testResources>" )),
464+ "Should error about conflicting <testResources>" );
463465
464466 // Verify modular resources are still injected correctly
465467 List <SourceRoot > mainResourceRoots = project .getEnabledSourceRoots (ProjectScope .MAIN , Language .RESOURCES )
@@ -478,23 +480,23 @@ void testModularSourcesWithExplicitResourcesIssuesWarning() throws Exception {
478480 }
479481
480482 /**
481- * Tests that legacy sourceDirectory and testSourceDirectory are ignored in modular projects.
483+ * Tests that legacy sourceDirectory and testSourceDirectory raise an error in modular projects.
482484 * <p>
483- * In modular projects, legacy directories are unconditionally ignored because it is not clear
484- * how to dispatch their content between different modules. A warning is emitted if these
485- * properties are explicitly set (differ from Super POM defaults).
485+ * In modular projects, legacy directories must not occur because it is not clear
486+ * how to dispatch their content between different modules. An error is raised if these
487+ * properties are explicitly set (and differ from Super POM defaults).
486488 * <p>
487489 * This verifies:
488- * - WARNINGs are emitted for explicitly set legacy directories in modular projects
489- * - sourceDirectory and testSourceDirectory are both ignored
490+ * - ERRORs are raised for explicitly set legacy directories in modular projects
490491 * - Only modular sources from {@code <sources>} are used
491492 * <p>
492493 * Acceptance Criteria:
493494 * - AC1 (boolean flags eliminated - uses hasSources() for main/test detection)
494- * - AC7 (legacy directories warning - {@code <sourceDirectory>} and {@code <testSourceDirectory>}
495- * are unconditionally ignored with a WARNING in modular projects)
495+ * - AC8 (legacy directories error - supersedes AC7 which originally used WARNING;
496+ * {@code <sourceDirectory>} and {@code <testSourceDirectory>} are raising an ERROR in modular projects)
496497 *
497498 * @see <a href="https://github.com/apache/maven/issues/11612">Issue #11612</a>
499+ * @see <a href="https://github.com/apache/maven/issues/11701#issuecomment-3858462609">AC8 definition</a>
498500 */
499501 @ Test
500502 void testMixedSourcesModularMainClassicTest () throws Exception {
@@ -510,20 +512,21 @@ void testMixedSourcesModularMainClassicTest() throws Exception {
510512
511513 MavenProject project = result .getProject ();
512514
513- // Verify WARNINGs are emitted for explicitly set legacy directories
514- List <ModelProblem > warnings = result .getProblems ().stream ()
515- .filter (p -> p .getSeverity () == ModelProblem .Severity .WARNING )
516- .filter (p -> p .getMessage ().contains ("Legacy" ) && p .getMessage ().contains ("ignored in modular project" ))
515+ // Verify ERRORs are raised for explicitly set legacy directories (AC8)
516+ List <ModelProblem > errors = result .getProblems ().stream ()
517+ .filter (p -> p .getSeverity () == ModelProblem .Severity .ERROR )
518+ .filter (p -> p .getMessage ().contains ("Legacy" )
519+ && p .getMessage ().contains ("must not be used in modular project" ))
517520 .toList ();
518521
519- // Should have 2 warnings : one for sourceDirectory, one for testSourceDirectory
520- assertEquals (2 , warnings .size (), "Should have 2 warnings for ignored legacy directories" );
522+ // Should have 2 errors : one for sourceDirectory, one for testSourceDirectory
523+ assertEquals (2 , errors .size (), "Should have 2 errors for conflicting legacy directories" );
521524 assertTrue (
522- warnings .stream ().anyMatch (w -> w .getMessage ().contains ("<sourceDirectory>" )),
523- "Should warn about ignored <sourceDirectory>" );
525+ errors .stream ().anyMatch (e -> e .getMessage ().contains ("<sourceDirectory>" )),
526+ "Should error about conflicting <sourceDirectory>" );
524527 assertTrue (
525- warnings .stream ().anyMatch (w -> w .getMessage ().contains ("<testSourceDirectory>" )),
526- "Should warn about ignored <testSourceDirectory>" );
528+ errors .stream ().anyMatch (e -> e .getMessage ().contains ("<testSourceDirectory>" )),
529+ "Should error about conflicting <testSourceDirectory>" );
527530
528531 // Get main Java source roots - should have modular sources, not classic sourceDirectory
529532 List <SourceRoot > mainJavaRoots = project .getEnabledSourceRoots (ProjectScope .MAIN , Language .JAVA_FAMILY )
@@ -541,17 +544,17 @@ void testMixedSourcesModularMainClassicTest() throws Exception {
541544 assertTrue (mainModules .contains ("org.foo.moduleA" ), "Should have main source for moduleA" );
542545 assertTrue (mainModules .contains ("org.foo.moduleB" ), "Should have main source for moduleB" );
543546
544- // Verify the classic sourceDirectory is NOT used (should be ignored )
547+ // Verify the classic sourceDirectory is NOT used (rejected in modular projects )
545548 boolean hasClassicMainSource = mainJavaRoots .stream ().anyMatch (sr -> sr .directory ()
546549 .toString ()
547550 .replace (File .separatorChar , '/' )
548551 .contains ("src/classic/main/java" ));
549- assertTrue (!hasClassicMainSource , "Classic sourceDirectory should be ignored " );
552+ assertTrue (!hasClassicMainSource , "Classic sourceDirectory must not be used " );
550553
551- // Test sources should NOT be added (legacy testSourceDirectory is ignored in modular projects)
554+ // Test sources should NOT be added (legacy testSourceDirectory is rejected in modular projects)
552555 List <SourceRoot > testJavaRoots = project .getEnabledSourceRoots (ProjectScope .TEST , Language .JAVA_FAMILY )
553556 .toList ();
554- assertEquals (0 , testJavaRoots .size (), "Should have no test Java sources (legacy is ignored )" );
557+ assertEquals (0 , testJavaRoots .size (), "Should have no test Java sources (legacy is rejected )" );
555558 }
556559
557560 /**
@@ -563,7 +566,7 @@ void testMixedSourcesModularMainClassicTest() throws Exception {
563566 * <p>
564567 * This verifies:
565568 * - An ERROR is reported when both modular and non-modular sources exist in {@code <sources>}
566- * - sourceDirectory is ignored because {@code <source scope="main" lang="java">} exists
569+ * - sourceDirectory is not used because {@code <source scope="main" lang="java">} exists
567570 * <p>
568571 * Acceptance Criteria:
569572 * - AC1 (boolean flags eliminated - uses hasSources() for source detection)
0 commit comments