Sonar steps for maven projects:
Below are the steps to configure the sonar in local machine (with jboss server),
1. place the cliet folder of jar files into jboss client folder
2. Install sonar server http://dist.sonar.codehaus.org/sonar-3.0.zip
3. Extract it in at your choice of directory
4. Create database called "sonar" in mysql
5. Open sonar-3.0\conf\sonar.properties
6. change the sonar.properties file(d:\sonar-3.0\conf)
--> #----- Credentials
# Permissions to create tables and indexes must be granted to JDBC user.
# The schema must be created first.
#sonar.jdbc.username: sonar
sonar.jdbc.username: root
#sonar.jdbc.password: sonar
sonar.jdbc.password: root
# Comment the following line to deactivate the default embedded database.
#sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.validationQuery: values(1)
#----- MySQL 5.x/6.x
# Comment the embedded database and uncomment the following line to use MySQL
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true& characterEncoding=utf8&rewriteBatchedStatements=true
#Optional properties
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
sonar.jdbc.validationQuery: select 1
7. start the server it creates db in mysql first time(D:\sonar-3.0\bin\windows-x86-32\StartSonar)
8. change the pom.xml of project and give the jboss home (make sure that set the Maven path in the system variable)
9. start the sonar server
10. Run the following command in cmd
D:\WorkSpace\ProjectName>mvn sonar:sonar -Dmy.first.property=true -Dmy.second.property=true
11. type the following url in the browser
http://localhost:9000
Note: If not started the sonar properly place the sonar-project.properties in the D:\sonar-3.0\conf
sonar-project.properties:
# required metadata
sonar.projectKey=my:project
sonar.projectName=D:/Workspace/ProjectName
sonar.projectVersion=1.0
# path to source directories (required)
sources=SourceName
# path to test source directories (optional)
#tests=testDir1,testDir2
# path to project binaries (optional), for example directory of Java bytecode
#binaries=binDir
# optional comma-separated list of paths to libraries. Only path to JAR file and path to directory of classes are supported.
#libraries=path/to/library.jar,path/to/classes/dir
# Uncomment those lines if some features of java 5 or java 6 like annotations, enum, ...
# are used in the source code to be analysed
#sonar.java.source=1.5
#sonar.java.target=1.5
# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
#sonar.language=cobol
# Advanced parameters
#my.property=value
------------------------------------------------------------------------
plugins
http://subclipse.tigris.org/update_1.6.x
http://m2eclipse.sonatype.org/sites/m2e
http://m2eclipse.sonatype.org/sites/m2e-extras
http://ecobertura.johoop.de/update/
______________________________________________________________________________________________________________
Sonar steps for non maven projects
To run sonar report, first we have to install maven & sonar in our local machine.For Non maven based project also we require maven because sonar require maven.
1 Download and extract Maven in your C drive from http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.4-bin.zip
2 Install Jdk
3 Download and extract Sonar in your D drive from http://dist.sonar.codehaus.org/sonar-3.0.zip
4 Now go to D:\sonar-3.0\bin\windows-x86-32 and double click on StartSonar.bat Now sonar server will start locally on http://localhost:9000
5 Here maven require pom.xml for the project for which sonar report is to be generated, but non maven based project will not have any pom.xml.
but we have to create a pom.xml in its project's parent folder as below.
6 <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>[YOUR.ORGANIZATION]</groupId>
<artifactId>[YOUR.PROJECT]</artifactId>
<name>[YOUR PROJECT NAME]</name>
<version>[YOUR PROJECT VERSION]</version>
<build>
<sourceDirectory>[YOUR SOURCE DIRECTORY]</sourceDirectory>
<outputDirectory>[YOUR CLASSES/BIN DIRECTORY</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<excludes>
<exclude>**/*.*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
</properties>
</project>
7 Replace the parameters :
Description Example
[YOUR.ORGANIZATION] the id of your organization (no space) com.myorganization
[YOUR.PROJECT] the id of your project (no space) my.project
[YOUR PROJECT NAME] the name displayed into sonar (spaces allowed) My Project
[YOUR PROJECT VERSION] the version. Set 1.0 if no specific version. 1.0
[YOUR SOURCE DIRECTORY] the relative path to the sources directory src/java
[YOUR CLASSES/BIN DIRECTORY] the relative path to the compiled java classes directory bin
8 Go to parent folder of your project, and run following command
mvn sonar:sonar
9 After its completion, browse http://localhost:9000/
Below are the steps to configure the sonar in local machine (with jboss server),
1. place the cliet folder of jar files into jboss client folder
2. Install sonar server http://dist.sonar.codehaus.org/sonar-3.0.zip
3. Extract it in at your choice of directory
4. Create database called "sonar" in mysql
5. Open sonar-3.0\conf\sonar.properties
6. change the sonar.properties file(d:\sonar-3.0\conf)
--> #----- Credentials
# Permissions to create tables and indexes must be granted to JDBC user.
# The schema must be created first.
#sonar.jdbc.username: sonar
sonar.jdbc.username: root
#sonar.jdbc.password: sonar
sonar.jdbc.password: root
# Comment the following line to deactivate the default embedded database.
#sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.validationQuery: values(1)
#----- MySQL 5.x/6.x
# Comment the embedded database and uncomment the following line to use MySQL
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true& characterEncoding=utf8&rewriteBatchedStatements=true
#Optional properties
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
sonar.jdbc.validationQuery: select 1
7. start the server it creates db in mysql first time(D:\sonar-3.0\bin\windows-x86-32\StartSonar)
8. change the pom.xml of project and give the jboss home (make sure that set the Maven path in the system variable)
9. start the sonar server
10. Run the following command in cmd
D:\WorkSpace\ProjectName>mvn sonar:sonar -Dmy.first.property=true -Dmy.second.property=true
11. type the following url in the browser
http://localhost:9000
Note: If not started the sonar properly place the sonar-project.properties in the D:\sonar-3.0\conf
sonar-project.properties:
# required metadata
sonar.projectKey=my:project
sonar.projectName=D:/Workspace/ProjectName
sonar.projectVersion=1.0
# path to source directories (required)
sources=SourceName
# path to test source directories (optional)
#tests=testDir1,testDir2
# path to project binaries (optional), for example directory of Java bytecode
#binaries=binDir
# optional comma-separated list of paths to libraries. Only path to JAR file and path to directory of classes are supported.
#libraries=path/to/library.jar,path/to/classes/dir
# Uncomment those lines if some features of java 5 or java 6 like annotations, enum, ...
# are used in the source code to be analysed
#sonar.java.source=1.5
#sonar.java.target=1.5
# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
#sonar.language=cobol
# Advanced parameters
#my.property=value
------------------------------------------------------------------------
plugins
http://subclipse.tigris.org/update_1.6.x
http://m2eclipse.sonatype.org/sites/m2e
http://m2eclipse.sonatype.org/sites/m2e-extras
http://ecobertura.johoop.de/update/
______________________________________________________________________________________________________________
Sonar steps for non maven projects
To run sonar report, first we have to install maven & sonar in our local machine.For Non maven based project also we require maven because sonar require maven.
1 Download and extract Maven in your C drive from http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.4-bin.zip
2 Install Jdk
3 Download and extract Sonar in your D drive from http://dist.sonar.codehaus.org/sonar-3.0.zip
4 Now go to D:\sonar-3.0\bin\windows-x86-32 and double click on StartSonar.bat Now sonar server will start locally on http://localhost:9000
5 Here maven require pom.xml for the project for which sonar report is to be generated, but non maven based project will not have any pom.xml.
but we have to create a pom.xml in its project's parent folder as below.
6 <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>[YOUR.ORGANIZATION]</groupId>
<artifactId>[YOUR.PROJECT]</artifactId>
<name>[YOUR PROJECT NAME]</name>
<version>[YOUR PROJECT VERSION]</version>
<build>
<sourceDirectory>[YOUR SOURCE DIRECTORY]</sourceDirectory>
<outputDirectory>[YOUR CLASSES/BIN DIRECTORY</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<excludes>
<exclude>**/*.*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
</properties>
</project>
7 Replace the parameters :
Description Example
[YOUR.ORGANIZATION] the id of your organization (no space) com.myorganization
[YOUR.PROJECT] the id of your project (no space) my.project
[YOUR PROJECT NAME] the name displayed into sonar (spaces allowed) My Project
[YOUR PROJECT VERSION] the version. Set 1.0 if no specific version. 1.0
[YOUR SOURCE DIRECTORY] the relative path to the sources directory src/java
[YOUR CLASSES/BIN DIRECTORY] the relative path to the compiled java classes directory bin
8 Go to parent folder of your project, and run following command
mvn sonar:sonar
9 After its completion, browse http://localhost:9000/
No comments:
Post a Comment