Friday, January 27, 2012

Sonar and Maven with an overriden derby port

The Sonar server uses a derby database by default that listens on port 1527. This conflicted with another process on our server so we edited the conf/sonar.properties file and set the properties sonar.jdbc.url and sonar.derby.drda.portNumber to use say 1528 instead. Uncomment the sonar.derby.drda.host parameter to allow remote connections. Restart sonar.

To run the maven sonar plugin on a project is simple, you don't even need a reference to it in the pom.xml.

mvn sonar:sonar

However, the sonar maven plugin needs to know where the server is and also the jdbc url for the server (I guess it interacts directly with the sonar database). So add two properties to your pom.xml (we added it to our parent pom.xml so all child projects would inherit it):
<properties>
  <sonar.host.url>http://YOUR_SERVER:9000</sonar.host.url>
  <sonar.jdbc.url>jdbc:derby://localhost:1528/sonar</sonar.jdbc.url> 
</properties>

No comments: