Sonar lite 机制现在似乎已在 Sonar 2.6 中被弃用。
将 Sonar 与非 Maven 构建集成的两种新方法:
ANT 任务是为结合 ivy 对构建和运行时类路径的控制而量身定制的(使用配置):
<!--
  Uses ivy to download dependencies
  -->
  <target name="dependencies" description="Resolve project dependencies and set classpaths">
    <ivy:resolve/>
    <ivy:cachepath pathid="compile.path"  conf="compile"/>
    <ivy:cachepath pathid="runtime.path"  conf="runtime"/>
    <ivy:cachepath pathid="test.path"     conf="test"/>
    <ivy:cachepath pathid="anttasks.path" conf="anttasks"/>
  </target>
  <!--
  Perform source code analysis
  -->
  <target name="sonar-init" description="Declare sonar ant task">
    <taskdef uri="antlib:org.sonar.ant" 
             resource="org/sonar/ant/antlib.xml" 
             classpathref="anttasks.path"/>
  </target>
  <target name="sonar" depends="test,sonar-init" description="Run the Sonar code analysis tool">
    <ivy:info/>
    <sonar:sonar workDir="${sonar.workDir}" key="${ivy.organisation}:${ivy.module}" version="${ivy.revision}">
      <!-- Project layout -->
      <sources>
        <path location="${build.srcDir}"/>
      </sources>
      <tests>
        <path location="${build.testDir}"/>
      </tests>
      <binaries>
        <path location="${build.outputDir}"/>
        <path location="${build.testOutputDir}"/>
      </binaries>
      <libraries>
        <path refid="test.path"/>
      </libraries>
      <!-- Additional Sonar configuration -->
      <property key="sonar.java.source" value="1.5"/>
      <property key="sonar.java.target" value="1.5"/>
    </sonar:sonar>
  </target>
另外请注意如何使用 ivy info任务来设置 Sonar 密钥和版本。