Maven -Dsonar.projectName has no effect

Hi,

I would like to change the project name. Unfortunately it has no effect. I found the following here in the community:

The following command is executed in a GitHub action and can also do it in the log so that the parameters are set correctly:

mvn -X -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
  -Dsonar.projectName=MyProject \ 
  -Dsonar.projectKey=my-project-key \
  -Dsonar.branch.name=dev

You can also see here in the log that the value is taken over:

[DEBUG] sonar.projectName: MyProject

Thanks for the support.

Hey there.

The project name only takes affect when being set for the main branch. dev is probably not your main branch (the branch you land on when you view your main branch in SonarCloud)

Hi,

That is not so clear from the documentary. But it makes sense. I hadn’t thought of it.

sonar.projectName

  • Name of the project that will be displayed on the web interface.
  • Default: For Maven projects, <name>, otherwise, the project key. If not provided and there is already a name in the DB, it will not be overwritten.

I have it on the main branch now and it works.

Thanks for the support

I’ll flag this for our docs team! Thanks for the feedback.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.