sonar-maven-plugin: extending sonar.sources in multi-module project : <p>I want to extend <code>sonar.sources</code>, which by default is <code>pom.xml,src/main/java</code>, by <code>src/main/resources</code> in order to check XML files that are located there.</p>

<p>This seemingly simple task turned out to be difficult since I have a multi-module maven project (> 100 modules, nested) with a lot of them don't have a <code>src/main/resources</code> folder and most of them not even a <code>src</code> folder (e.g. for packaging=pom). This leads to a build error if I set <code>sonar.sources</code> to <code>pom.xml,src/main/java,src/main/resources</code> or <code>pom.xml,src/main</code>:</p>

<pre><code>[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project xyz-parent: The directory 'C:\...\submodule\src\main\resources' does not exist for Maven module ... Please check the property sonar.sources -&gt; [Help 1]
</code></pre>

<p>The sonar-maven-plugin itself uses <code>${project.build.sourceDirectory}</code> to do it right in every module.</p>

<p>I tried to use regular expressions to set <code>sonar.sources</code> to <code>src/main</code> by cutting off <code>/java</code> (or <code>\java</code> on Windows) via</p>

<pre><code>&lt;plugin&gt;
  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
  &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;1.7&lt;/version&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;id&gt;regex-property&lt;/id&gt;
      &lt;goals&gt;
        &lt;goal&gt;regex-property&lt;/goal&gt;
      &lt;/goals&gt;
      &lt;configuration&gt;
        &lt;name&gt;sonar.sources&lt;/name&gt;
        &lt;value&gt;${project.build.sourceDirectory}&lt;/value&gt;
        &lt;regex&gt;[/\\]+java$&lt;/regex&gt;
        &lt;replacement&gt;&lt;/replacement&gt;
        &lt;failIfNoMatch&gt;false&lt;/failIfNoMatch&gt;
      &lt;/configuration&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;
</code></pre>

<p>But this does nothing and I have no idea to which lifecycle phase I should bind it to have it executed.</p>

<p>Or is there a way to avoid the error due to missing directory in <code>sonar.sources</code>? According to <a href="https://github.com/SonarSource/sonar-maven/blob/master/src/main/java/org/sonarsource/scanner/maven/bootstrap/MavenProjectConverter.java#L433" rel="noreferrer">current sonar-maven source</a> missing directories are only ignored if the POM has <code>pom</code> packaging but not for <code>ear</code> or <code>jar</code> modules without resources.</p>

<p>Or should I ensure <code>src/main</code> exists before sonar start? What hook may I use for that?</p>
