changeset 42:f1144aa0c01b

CM-127: Improve sonar target to handle java projects and optionally use 'build breaker' to fail builds
author smith@nwoca.org
date Tue, 07 Jun 2011 21:44:14 -0400
parents 139a3611ae99
children c1619b87800e
files sonar-ant.xml
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sonar-ant.xml	Tue Jun 07 18:08:47 2011 -0400
+++ b/sonar-ant.xml	Tue Jun 07 21:44:14 2011 -0400
@@ -40,16 +40,19 @@
 
     <target name="sonar" depends="project.init,-check-sonar,ivy-info,coverage.xml" if="sonar.enabled">
         <fail unless="sonar.active" message="Sonar has not been initialized"/>
+        <property name="sonar.projectname" value="${ivy.project.module}"/>
         <sonar:sonar
             workDir="${build.dir}/sonar"
-            key="${ivy.project.organisation}:${ivy.project.module}"
-            version="${project.version}" >
+            key="${ivy.project.organisation}:${sonar.projectname}"
+            version="${project.version}"  >
             <sources>
                 <path location="${src.dir}" />
             </sources>
             <property key="sonar.core.codeCoveragePlugin" value="jacoco"/>
-            <property key="sonar.projectName" value="${ivy.project.module}"/>
+            <property key="sonar.projectName" value="${sonar.projectname}"/>
             <property key="sonar.language" value="${sonar.language}" />
+            <property key="sonar.java.source" value="${javac.source}" />
+            <property key="sonar.java.target" value="${java.target}" />                     
             <property key="sonar.dynamicAnalysis" value="reuseReports" />
             <property key="sonar.surefire.reportsPath" value="${build.test.results.dir}"/>
             <property key="sonar.jacoco.reportPath" value="${jacoco.data.file}"/>
@@ -58,10 +61,10 @@
                 <path location="${test.src.dir}" />
             </tests>
             <binaries>
-                <path location="${build.dir}/classes" />
+                <path location="${build.classes.dir}" />
             </binaries>
         </sonar:sonar>
-        <fail if="tests.failed">Some tests failed; see details above. (sonar)</fail>
+        <fail if="tests.failed" unless="sonar.use.build.breaker">Some tests failed; see details above. (sonar)</fail>
     </target>
 
 </project>