Versions Compared

Key

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

Prerequisites

Checkout Sources

Setup GIT

If you have never used git before, you need to do some setup first. Run the following commands so that GIT knows your name and email.

Code Block
git config --global user.name "Your Name"
git config --global user.email "your@email.com"

Setup line endings preferences :

  • For Unix/Mac users :

    Code Block
    git config --global core.autocrlf input
    git config --global core.safecrlf true
    
  • For Windows users :

    Code Block
    git config --global core.autocrlf true
    git config --global core.safecrlf true
    

Clone GIT repository

Sources can be checked out anonymously from GitHub :

Code Block
git clone git://github.com/SonarSource/sonar.git

Committers must configure their SSH key (see GitHub documentation for Windows and Mac) and clone repository with the following URL :

Code Block
git clone git@github.com:SonarSource/sonar.git

Build Sources

Increase the memory allocated to Maven (replace 'export' by 'set' on Windows) :

Code Block
export MAVEN_OPTS='-Xmx256m'

Some artifacts used by Sonar are not in Central repository (e.g. fikin-ant), so you should ensure that Sonar repository ( defined in pom.xml ) will be used :

Code Block
http://repository.sonarsource.org/content/repositories/sonar

To run a complete build, execute "mvn clean install" in the root of the project directory. To quickly build in development environments, the script "quick-build.sh" does not execute unit tests and compile GWT components for Firefox only.

The distribution is generated in the directory sonar-application/target.

Profiles

Profile identifierActivationDescription
devDeactivated by default. Can be activated with -Pdev 
releaseDeactivated by default. Can be activated with -Prelease 
javadocDeactivated by default. Can be activated with -Pjavadoc 
m2eActivated in Eclipse. 

IDE support

The following guidelines must be applied to sonar and to the plugins that are hosted at Codehaus.

Eclipse

  1. Install Anyedit Eclipse Plugin
  2. Optional: if Maven projects do not define the profile ‘m2e’, then install the M2E error disabler plugin
  3. Restart Eclipse
  4. Windows → Preferences
    • General
      • Workspace
        • Text file encoding: UTF-8
      • Editors → AnyEdit Tools
        • Remove trailing whitespace
        • Create new line at the end of file
        • Convert tabs – spaces
        • Default convert mode on save: Tabs to spaces
    • Java → Code Style
    • XML → XML Files → Editor
      • Indent using spaces
      • Indentation size: 2
  5. Open the Maven project: File → Import → Maven → Existing Maven Projects → select the root directory containing the file pom.xml

IntelliJ IDEA

  1. Download sonar-codestyle.xml to
    • ~/Library/Preferences/IntellijIdea/codestyles/ on Mac OS
    • ~/.IntellijIdea/config/codeStyles/ on Linux
    • ~\.IntellijIdea\config\codeStyles\ on Windows
  2. (Re)start IntellIJ IDEA
  3. Open the Maven project: File → Open Project → select the file pom.xml
  4. Use UTF-8 encoding: Project Settings → File Encodings → IDE Encoding: UTF-8
  5. Change the code style: Project Settings → Code Style → Scheme: sonar