1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="UTF-8"?>
<project name="sonar" basedir=".">   
    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
        <classpath path="lib/sonar/sonar-ant-task-1.2.jar" />
    </taskdef>
    
    <!-- where to look for sonar jar files -->
    <property name="lib.dir.1" value="lib/sonar"/>
    <property name="lib.dir.2" value="lib/sonar/core-plugins"/>
    
    <path id="sonar.classpath">
      <fileset dir="${lib.dir.1}" includes="**/*.jar"/>
      <fileset dir="${lib.dir.2}" includes="**/*.jar"/>
    </path>

    <target name="sonar">            
        <!-- to use Clover -->
        <property name="sonar.core.codeCoveragePlugin" value="clover" />
        
        <property name="sonar.projectName" value="Some Project Name" />

        <!-- compiled classes location -->
        <property name="sonar.binaries" value="${build.dir}" />
            
        <!-- unit test source location -->
        <property name="sonar.tests" value="src/test/unit/" />
        
        <property name="sonar.dynamicAnalysis" value="true" />                        
        
        <!-- comma separated package names to be excluded from -->
        <property name="sonar.exclusions" 
            value="com/some.package/**/*.java,com/other.package/*.java"/>
        
        <!-- sonar host URL if not default one -->
        <property name="sonar.host.url" value="http://some.url" />
        
        <!-- DB configuration if not default ones -->
        <property name="sonar.jdbc.username" value="some.user" />
        <property name="sonar.jdbc.password" value="some.password" />
        <property name="sonar.jdbc.url" value="some.jdbc.url" />
        <!-- here is for SQL Server -->
        <property name="sonar.jdbc.driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
                
        <sonar:sonar key="some.key" version="1.0-SNAPSHOT" xmlns:sonar="antlib:org.sonar.ant"   >        
            <sources>
                <!-- source location -->
                <path location="some.source.location"/>
            </sources>
            <libraries>
                <path refid="sonar.classpath" />
            </libraries>
        </sonar:sonar>
    </target>
</project>