Installing Maven, Sonar and MySQL on Mac OS X 10.6

If you program a lot, then these tools should at least be pretty familiar to you.  If not, then you’ve probably never heard of Test Driven Development and Software Quality either (I’ll accept that you’ve heard of MySQL and OS X no matter what :)).  These tools help create a process to program and release code along with analyzing the structure of your code.  MySQL, of course, is used as the back end for Sonar.  I recently decided since I was doing a lot of coding on my PhD work that it’d be fun to setup the tools that I use at work and see just how good (or bad) my code for my PhD is.  So, I set about downloading and installing the various tools.  Find them was very simple since they are all open source projects.  You can find them at these places:

Once these are all downloaded, the installation of all three is very straight forward and the documents can guide you them with ease.  The only problem I had was getting Sonar to work with MySQL correctly.  When Sonar first runs, it is supposed to create a Sonar DB inside of MySQL (once you set the Sonar config file to use MySQL).  In my case however, it wasn’t doing that at all.  So I had to manually create a database within MySQL called ‘sonar’ and then start Sonar running, at which point, it created all of the tables it needed and began running flawlessly.

The next step is to convert existing projects to build with Maven (or make new projects using Maven).  This also requires some modification of the pom.xml files to hook into Sonar.  I had to place the Sonar profile section that is normally inside the settings.xml for Maven into the POM for the project which I was working on.  This fixed the issue of Sonar not being able to connect to the MySQL database.

With this I was able to get all the tools working on my machine with no real issues (other than seeing how bad static analysis thought my code was).  Using this I’m hoping that I’ll be able to write some nice clean code and have it all working brilliantly so when I need to modify it, the code will make complete sense and be easy to extend and modify in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *