当我尝试通过jenkins对我的项目进行声纳代码覆盖时,我收到以下错误: 无法从资源org / jacoco / ant / antlib.xml加载定义。它无法找到。
但是当我通过eclipse执行它时它没有显示任何错误。代码在两种情况下是相同的,我已经检查过,如果包含jenkins jacocoant.jar。
这是我的代码:
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="../monet-main/lib/dev/sonar/jacocoant.jar" />
</taskdef>
<property name="sonar.tests" value="test" />
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.surefire.reportsPath" value="output/site/jacoco" />
<property name="sonar.java.coveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="output/jacoco.exec" />
<target name="test">
<mkdir dir="output/report/junit" />
<javac debug="true" includeantruntime="false" nowarn="true" debuglevel="${debuglevel}" destdir="bin"
encoding="UTF-8" source="1.6" target="1.6" srcdir="test">
<classpath refid="monet-service.classpath" />
</javac>
<jacoco:coverage destfile="${result.exec.file}">
<junit haltonfailure="yes" fork="true">
<classpath>
<path refid="monet-service.classpath" />
<pathelement path="bin" />
</classpath>
<formatter type="plain" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="output/report/junit">
<fileset dir="test">
<include name="**/CommonTest.java" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
</target>
<target name="testReport" depends="test">
<!-- Step 3: Create coverage report -->
<jacoco:report>
<executiondata>
<file file="${result.exec.file}" />
</executiondata>
<!-- the class files and optional source files ... -->
<structure name="JaCoCo Ant Example">
<classfiles>
<fileset dir="${result.dir}" />
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}" />
</sourcefiles>
</structure>
<!-- to produce reports in different formats. -->
<html destdir="${result.report.dir}" />
<csv destfile="${result.report.dir}/report.csv" />
<xml destfile="${result.report.dir}/report.xml" />
</jacoco:report>
</target>
<!-- Define the SonarQube target -->
<target name="sonar" depends="testReport">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<!-- Update the following line, or put the "sonar-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
<classpath path="../monet-main/lib/dev/sonar/sonar-ant-task-2.2.jar" />
</taskdef>
<!-- Execute the SonarQube analysis -->
<sonar:sonar/>
</target>
有什么问题..