Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Download and install Maven:

  • 2.2.x or 3.0.x compatible with any version of SonarQube
  • 3.1.x + compatible with SonarQube 3.7+

Check compatibility matrix for more details.

Global Settings

Edit the settings.xml file, located in $MAVEN_HOME/conf or ~/.m2, to set the database parameters to be used as well as the SonarQube server URL.

...

Code Block
langxml
<settings>
    <profiles>
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Example for MySQL-->
                <sonar.jdbc.url>
                  jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8
                </sonar.jdbc.url>
                <sonar.jdbc.username>sonar</sonar.jdbc.username>
                <sonar.jdbc.password>sonar</sonar.jdbc.password>

                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                  http://myserver:9000
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>

...

Troobleshooting

Note

If you get an java.lang.OutOfMemoryError, you can set the MAVEN_OPTS environment variable, like this in *nix environments:

Code Block
languagenone
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"

On Windows environments, avoid the double-quotes, since they get misinterpreted and combine the two parameters into a single one.

Code Block
languagenone
set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m

 

You are now ready to analyze a project with Maven.