Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Sep 8, 2025

Summary

This PR improves the warning message for deprecated source root collection modifications to address concerns raised in #11089.

Changes Made

  • More specific method recommendations: Instead of generic "add/remove methods", now shows exact method names:

    • For compileSourceRoots: "Use MavenProject.addCompileSourceRoot()/removeCompileSourceRoot() methods instead"
    • For testCompileSourceRoots: "Use MavenProject.addTestCompileSourceRoot()/removeTestCompileSourceRoot() methods instead"
  • Clearer language: Changed "Direct modification of" to "Plugin is modifying" to make it clearer what's happening

  • More concise messaging: Removed redundant phrases while keeping essential information

  • Better debugging information: Improved the debug stack trace message description

  • Ecosystem health: Encourages reporting issues to plugin maintainers to help prepare the Maven ecosystem for 4.0.0

  • Preserved helpful configuration guidance: Kept the valuable information about where users can set the disable property

Before and After

Before:

[WARNING] Direct modification of testCompileSourceRoots through iterator.remove() 
is deprecated and will not work in Maven 4.0.0. Please use the add/remove methods 
instead. If you're using a plugin that causes this warning, please upgrade to the latest 
version and report an issue if the warning persists. To disable these warnings, set 
-Dmaven.project.sourceRoots.warningsDisabled=true on the command line, in the 
.mvn/maven.config file, or in project POM properties.

After:

[WARNING] Plugin is modifying testCompileSourceRoots through iterator.remove(), 
which will not work in Maven 4.0.0. 
Use MavenProject.addTestCompileSourceRoot()/removeTestCompileSourceRoot() 
methods instead. If using a plugin, please upgrade to the latest version or report the 
issue to the plugin maintainer. To disable these warnings, set 
-Dmaven.project.sourceRoots.warningsDisabled=true on the command line, in the 
.mvn/maven.config file, or in project POM properties.

Addresses Issues Raised in #11089

  1. Confusion about "add/remove methods": Now provides specific method names
  2. More actionable: Clearer about what methods to use
  3. Less confusing: Removes the contradiction about adding through iterators
  4. Maintains helpful configuration info: Keeps the guidance on where to set the disable property
  5. Better debugging: Improved stack trace description for developers
  6. Ecosystem health: Encourages issue reporting to help Maven 4.0.0 readiness

The changes maintain backward compatibility while making the warning message much more helpful and less confusing for both end users and plugin developers.

Fixes #11089


Pull Request opened by Augment Code with guidance from the PR author

- Make warning message more specific by showing exact method names to use
- Change from 'Direct modification' to 'Plugin is modifying' for clarity
- Provide specific method recommendations (addCompileSourceRoot/removeCompileSourceRoot, etc.)
- Encourage reporting issues to plugin maintainers for ecosystem health
- Improve debug stack trace description
- Address concerns raised in MNG-11089 about message clarity and actionability

The improved message is more helpful for both end users and plugin developers
while maintaining the important guidance on disabling warnings.
@gnodet gnodet added the mvn3 label Sep 10, 2025
@gnodet gnodet merged commit fa779df into apache:maven-3.9.x Sep 17, 2025
18 checks passed
@github-actions github-actions bot added this to the 3.9.12 milestone Sep 17, 2025
@gnodet gnodet added the bug Something isn't working label Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants