ascheman commented on issue #11701:
URL: https://github.com/apache/maven/issues/11701#issuecomment-3897961755

   ## AC8 and AC9: Legacy Directory Handling with `<sources>`
   
   This comment clarifies the acceptance criteria for handling legacy 
directories (`<sourceDirectory>`, `<testSourceDirectory>`) when `<sources>` is 
configured (based on respective discussions in the course of #11702).
   
   ### AC8: Modular Projects
   
   For **modular projects** (projects with `<module>` attribute in `<source>` 
elements), **all legacy directories are rejected**:
   
   1. **Explicit configuration**: If legacy directory differs from Super POM 
default → **ERROR**
   2. **Physical presence**: If default directory (`src/main/java`) exists on 
filesystem → **ERROR**
   
   **Rationale**: Modular projects use paths like `src/<module>/main/java`. 
Content in legacy directories cannot be dispatched between modules and would be 
silently ignored.
   
   ### AC9: Non-Modular Projects
   
   For **non-modular projects** using `<sources>`:
   
   1. **When `<sources>` has Java for a scope**: Legacy directories are 
rejected if they differ from the default
   2. **When `<sources>` has no Java for a scope**: Legacy directories are used 
as **implicit fallback** only if they match the default
   
   | `<sources>` has Java? | Legacy differs from default? | Result |
   |-----------------------|------------------------------|--------|
   | Yes | Yes | **ERROR** |
   | Yes | No | OK (ignored, use `<sources>`) |
   | No | Yes | **ERROR** |
   | No | No | OK (implicit fallback) |
   
   **Rationale**: This allows incremental adoption of `<sources>`:
   - Customize only specific source types (e.g., resources) while keeping 
default Java directories
   - Explicit legacy overrides always trigger errors (detectable configuration 
mixing)
   
   ### Limitation
   
   Maven works with the effective model after inheritance resolution. It cannot 
distinguish whether a value matching the default was inherited (from Super POM 
or any parent) or explicitly configured. For modular projects, the physical 
presence check provides an additional safeguard.
   
   ### Example: AC9 Implicit Fallback
   
   ```xml
   <build>
     <sources>
       <!-- Only customize resources -->
       <source>
         <lang>resources</lang>
         <scope>main</scope>
         <directory>src/main/custom-resources</directory>
       </source>
     </sources>
     <!-- src/main/java is used implicitly (AC9 fallback) -->
   </build>
   ```
   


-- 
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]

Reply via email to