gnodet opened a new pull request, #11538:
URL: https://github.com/apache/maven/pull/11538

   ## Summary
   
   This PR addresses API compatibility issues introduced in commit 
731700abc62808ce7ab8aad64323ed16e9950516 on master (4.1.0-SNAPSHOT), which made 
InputLocation constructors package-private and added static factory methods. 
Since Maven 4.0 hasn't been released yet, we're backporting these changes in a 
backward-compatible way.
   
   ## Changes
   
   - Added static factory methods `of(...)` to `InputLocation` and 
`InputSource` classes
   - Deprecated all constructors with `since 4.0.0-rc-6` message
   - Made both `InputLocation` and `InputSource` classes `final` to prevent 
extension
   - Updated internal Maven code to use factory methods instead of constructors
   - Applied changes to both hand-written files and Modello templates
   
   ## Rationale
   
   ### Why add factory methods?
   - Aligns with modern Java best practices
   - Provides flexibility for future optimizations (e.g., caching, validation)
   - Consistent with the API design in 4.1.0-SNAPSHOT
   
   ### Why make classes final?
   - These are immutable value objects that shouldn't be extended
   - Prevents extensions from depending on subclassing, which would break in 
4.1.0 anyway
   - Better API design and clearer intent
   
   ### Why keep constructors public (deprecated)?
   - Maintains backward compatibility with extensions like mason
   - Allows existing code to continue working without immediate changes
   - Provides clear migration path with deprecation warnings
   
   ## Compatibility
   
   ✅ **Backward compatible** - Constructors remain public (just deprecated)
   ✅ **Forward compatible** - Aligns with 4.1.0-SNAPSHOT API design
   ✅ **Build verified** - Full build with tests passes successfully
   
   ## Files Modified
   
   - 
`api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java`
   - 
`api/maven-api-model/src/main/java/org/apache/maven/api/model/InputSource.java`
   - 
`compat/maven-model/src/main/java/org/apache/maven/model/InputLocation.java`
   - `impl/maven-impl/src/main/java/org/apache/maven/impl/SettingsUtilsV4.java`
   - `src/mdo/java/InputLocation.java` (template)
   - `src/mdo/java/InputSource.java` (template)
   
   ## Testing
   
   - ✅ Full build completed successfully: `mvn clean install`
   - ✅ All tests pass
   - ✅ Deprecation warnings appear as expected
   - ✅ Generated code (maven-api-settings, maven-api-toolchain) updated 
correctly
   
   ---
   Pull Request opened by [Augment Code](https://www.augmentcode.com/) with 
guidance from the PR author


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