SonarScanner for Maven and Maven 4: error

Hi,

maven-3.9.11 and sonar-maven-plugin:5.1.0.4751 show a warning:

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

and indeed with Maven 4.0.0-rc-3 (3952d00ce65df6753b63a51e86b1f626c55a8df2) and the latest 4.1.0-SNAPSHOT you get an exception (relevant part of the stack trace).

Caused by: java.lang.UnsupportedOperationException
    at java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)
    at java.util.ImmutableCollections$AbstractImmutableCollection.removeIf(ImmutableCollections.java:152)
    at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.removeTarget(MavenProjectConverter.java:534)
2 Likes

Hi @mfriedenhagen,

Thanks for reporting this issue. I believe it is similar to the one we logged into this ticket.

Work on Maven 4 support is planned for this fall.

Cheers,

Dorian

1 Like

Hi,

Same issue here. Is it still planned to be fixed?

4.0.0-rc-4 is available and distributed on more platform (Including DockerHub: https://hub.docker.com/_/maven/tags?name=4.0.0-rc-4)

I would be great to have the plugin working so people can already prepare their project to be compatible with Maven 4

Regards,

Same issue, Maven 4 is about to be released: https://lists.apache.org/thread/jnb3snhdm4b564gz8hbctp9rfk8fc67n
and Sonar Scanner is not yet compatible :frowning:

1 Like

Hey folks,

We just released version 5.3 of the scanner that should fix the issue. Would you mind giving it a try and letting us know if you the issue is resolved on your end?

Cheers,

Dorian

1 Like

I confirm I can run scan with 4.0.0-rc-4 and Sonar Maven plugin 5.3.0.6276

Thanks the fix

2 Likes