Maven 4.0.0-rc-3 throws UnsupportedOperationException

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension)
    • current lts-community
  • how is SonarQube deployed: zip, Docker, Helm
    • Docker
  • what are you trying to achieve
    • analyze java code with latest Maven 4 release (rc3)
  • what have you tried so far to achieve this
    • Identified and reported issues in Maven Jira and here
❯ docker run -d \
    --name sonarqube \
    -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true \
    -p 9000:9000 \
    sonarqube:lts-community
❯ cat pom.xml
<project>
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.mycompany.app</groupId>
	<artifactId>my-app</artifactId>
	<version>1</version>
</project>
❯ /opt/maven/apache-maven-4.0.0-rc-2/bin/mvn -q \
  org.sonarsource.scanner.maven:sonar-maven-plugin:5.0.0.4389:sonar \
    -Dsonar.login=admin \
    -Dsonar.password=admin \
    -Dsonar.host.url=http://localhost:9000/
❯ /opt/maven/apache-maven-4.0.0-rc-3/bin/mvn -q \
  org.sonarsource.scanner.maven:sonar-maven-plugin:5.0.0.4389:sonar \
    -Dsonar.login=admin \
    -Dsonar.password=admin \
    -Dsonar.host.url=http://localhost:9000/
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:5.0.0.4389:sonar (default-cli) on project my-app: null: MojoExecutionException: UnsupportedOperationException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the '-e' switch
[ERROR] Re-run Maven using the '-X' switch to enable verbose output
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

The sonar maven plugin needs to be adapted to not modify the collection directly, but rather use the addTestCompileSourceRoot instead.

Thanks for the report, indeed the new Maven API returns an immutable list now, and we were removing items from this collection, which now breaks if you are running with mvn 4.0.0-rc-3.

I created a ticket to fix this problem.