因项目使用 ant 进行编译,因此代码检查也是用 sonar runner 进行,于是有了如下的配置文件:
<project basedir="." name="ESOP" default="sonar" xmlns:sonar="antlib:org.sonar.ant"> <property name="root" value="${basedir}/../" /> <property name="name" value="appstore_ec" /> <property name="esop_lib_home" value="${root}/lib/" /> <property name="sonar.jdbc.url" value="jdbc:mysql://10.204.1.237:3306/sonar" /> <property name="sonar.jdbc.username" value="sonar" /> <property name="sonar.jdbc.password" value="sonar" /> <property name="sonar.projectKey" value="org.codehaus.sonar:${name}" /> <property name="sonar.projectName" value="${name}" /> <!-- 由 jenkins 中的任务制定该参数 <property name="sonar.projectVersion" value="0.1" /> --> <property name="sonar.projectVersion" value="0.1" /> <property name="sonar.language" value="java" /> <property name="sonar.sources" value="${root}appstore_ap/src,${root}appstore_common/src,${root}appstore_ec/src,${root}appstore_op/src,${root}appstore_service/src,${root}appstore_ws/src" /> <property name="sonar.binaries" value="${esop_lib_home}/*.war" /> <property name="sonar.exclusions" value="**/UserConnection.java,**/RecThread.java" /> <target name="sonar"> <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"> <classpath path="${esop_lib_home}sonar/sonar-ant-task-2.0.jar" /> </taskdef> <sonar:sonar /> </target> </project>
参数说明:
http://blog.csdn.net/alonesword/article/details/9981521
http://docs.codehaus.org/display/SONAR/Analysis+Parameters