title: How to configure Maven to run a SonarQube project analysis with two different quality profiles?
body: <p>We run SonarQube analyses for our Java projects via Maven. Maven somehow does this automagically; all we did was add the <code>sonar-maven-plugin</code> to our <em>pom.xml</em>:</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;pluginManagement&gt;
      &lt;plugins&gt;
          ...
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;sonar-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/pluginManagement&gt;
  </code></pre>
  
  <p>This works fine.</p>
  
  <p>But now we need to run the SonarQube analysis <em>twice</em>, with different quality profiles. Since you can't easily change the project key from Maven, we use SonarQube's <code>branch</code> property to differentiate the SonarQube projects, like this (again from <em>pom.xml</em>):</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;properties&gt;
      &lt;sonar.profile&gt;MyQualityProfile1&lt;/sonar.profile&gt;
      &lt;sonar.branch&gt;Dev_${sonar.profile}&lt;/sonar.branch&gt;
      ...
  &lt;/properties&gt;
  </code></pre>
  
  <p>This way, we end up with two project entries in the SonarQube UI, both of which contain the exact same code, but have different issues depending on their quality profile (one used quality profile 1, and the other used quality profile 2).</p>
  
  <p>Problem: In order to achieve this, I must manually change the <em>pom.xml</em> properties and run the entire build twice.</p>
  
  <p><strong>Question:</strong> How can I configure maven to simply run the <code>sonar:sonar</code> goal twice with different properties?</p>
  
  <p>This would save us a lot of time on our builds. I already found <a href="https://stackoverflow.com/q/19159785/1005481">this similar question</a>, but no answers so far. Thanks!</p>