Delaying SonarQube Scanner to the end of multi-module project and nothing else

Hi to everyone.
I use sonar-maven-plugin (

So I have a multi module maven project and my goal is to analyze code of every module separately and see it on server as individual project.

Ок, what am I doing… I put properties of my sonar confguration at maven specific profile (“sonar”) and plugin configuration to plugin management section of this profile. In one module (I choose it randomly) I activate the plugin, so I run the build process and expect that some analyze will be perform and some stuff wii be send to sonar server but in build output i see only this

[INFO] — sonar-maven-plugin: (default) @ %my_module_name% —
[INFO] Delaying SonarQube Scanner to the end of multi-module project

What i do wrong?

I clone sonar-maven-plugin sources and find interesting things, for example this some piece of code…

    class org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter {

         Map<String, String> configure(List<MavenProject> mavenProjects, MavenProject root, Properties userProperties) throws MojoExecutionException {
    this.userProperties = userProperties;
    this.specifiedProjectKey = specifiedProjectKey(userProperties, root);
    Map<MavenProject, Map<String, String>> propsByModule = new LinkedHashMap<>();

    try {
      configureModules(mavenProjects, propsByModule);
      Map<String, String> props = new HashMap<>();
      props.put(ScanProperties.PROJECT_KEY, getArtifactKey(root));
      Path topLevelDir = rebuildModuleHierarchy(props, propsByModule, root, "");
      props.put(ScanProperties.PROJECT_BASEDIR, topLevelDir.toString());
      if (!propsByModule.isEmpty()) {
          + propsByModule.keySet().iterator().next().getName() + "\" is orphan");
      return props;
    } catch (IOException e) {
      throw new IllegalStateException("Cannot configure project", e);

I suppose that sonar maven plugin can’t do things that i talked above, cause it start his work from root context every time. I do not understand why you have done it this way? It is unconvinient on my look. Could you explain? Thnx

Hi @jCat77,

There is a workaround that should allow your specific case.

I assume you currently run the sonar maven goal in the root of your project, one thing you can do is execute the goal specific for the module you want.

I don’t know the specifics of your project setup, but lets assume the following as example:

 - root
  |- module-1
  |- module-2
  | |- module-2.1
  | \ module-2.2
  \ module-3

To run the scanner for a single module, you could limit the build context of maven by only running the scanner a specific module. Lets say you only want to scan module-2.1 then you can execute the goal from the root of the module by executing

cd module-2/module-2.1
mvn sonar:sonar

Alternatively you can also execute it from the root context using the project selector by artifactId

mvn -pl :module-2.1 sonar:sonar

or select the project by its directory.

mvn -pl module-2/module-2.1 sonar:sonar

Hope this helps.