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

Skip to content

[WARNING] Direct modification of testCompileSourceRoots through iterator.remove() is deprecated and will not work in Maven 4.0.0 is not useful #11089

@laeubi

Description

@laeubi

Affected version

3.9.11 / 4.0.0

Bug description

Currently Maven 3.9.11 emit the following warning in some cases:

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

This warning is not really useful in general for the following reasons:

  1. If I run Maven 3.9.x as I user I do not care about Maven 4 (yet) and it is only annoying, most of the time I can only disable the warning as it is not actionable (given I can not force a plugin to change and make a new release just for me)
  2. Even if I can convince the plugin-devloper, as the API is only available to 3.9.11 this will immediately force the plugin to use 3.9.11 as minimum maven version or using ugly reflection based hacks, given that maven-core developers hardly can agree on using 3.8.x as a minimum maven version its unlikely other plugin developers will be happy to upgrade yet as 3.9.11 is quite "fresh" at the moment
  3. The maybe even more worse thing is that in Maven 4 the method was deprecated (!) so one is asked to upgrade to a new way to be compatible with Maven 4 only to getting then to something it is deprecated there if one actually would upgrade, that makes the whole thing here completely useless as it buys you nothing neither from the user side (I get annoying message) nor from the plugin developer side (I need latest maven 3 API that is deprecated in Maven 4)
  4. As a nitpic, the message is confusing, as it talks about using the add/remove methods instead, but you can never add something through an iterator anyways... Also a stacktrace (maybe in debug mode) would help to identify the actual source of the call what is not that obvious when it happens inside a method so one has to search indirect references to an iterator.remove method what can be cumbersome.

I therefore think such warning would be more suitable for the maven-3 compact layer, or when enabling some kind of strict mode that a plugin developer might use during development/testing of a mojo.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions