Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <project name="Example Ant Build with JaCoCo" default="rebuild" xmlns:jacoco="antlib:org.jacoco.ant">
  4.  
  5. <description>
  6. Example Ant build file that demonstrates how a JaCoCo coverage report
  7. can be itegrated into an existing build in three simple steps.
  8. </description>
  9.  
  10. <property name="src.dir" location="./src/main/java" />
  11. <property name="result.dir" location="./target" />
  12. <property name="result.classes.dir" location="${result.dir}/classes" />
  13. <property name="result.report.dir" location="${result.dir}/site/jacoco" />
  14. <property name="result.exec.file" location="${result.dir}/jacoco.exec" />
  15.  
  16. <path id="JUnit 4.libraryclasspath">
  17. <pathelement location="C:/Users/caioc_000/Desktop/Daniel/caraio/apache-ant-1.9.7/lib/junit-4.12.jar"/>
  18. <pathelement location="C:/Users/caioc_000/Desktop/Daniel/caraio/apache-ant-1.9.7/lib/hamcrest-core-1.3.jar"/>
  19. </path>
  20.  
  21.  
  22. <!-- Step 1: Import JaCoCo Ant tasks -->
  23. <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
  24. <classpath path="../jacoco-0.7.8-20160926.183251-20/lib/jacocoant.jar" />
  25. </taskdef>
  26.  
  27. <target name="clean">
  28. <delete dir="${result.dir}" />
  29. </target>
  30.  
  31. <target name="compile">
  32. <mkdir dir="${result.classes.dir}" />
  33. <javac srcdir="${src.dir}" destdir="${result.classes.dir}" debug="true" includeantruntime="false" />
  34. </target>
  35.  
  36. <jacoco:coverage>
  37. <java classname="Balde" fork="true">
  38. <classpath>
  39. <pathelement location="../bin"/>
  40. </classpath>
  41. </java>
  42. </jacoco:coverage>
  43.  
  44.  
  45. <jacoco:coverage>
  46. <junit fork="true" forkmode="once" includeAntRuntime="true" >
  47. <test name="TesteBaldeCobertura"/>
  48. <classpath>
  49. <pathelement location="../bin"/>
  50. </classpath>
  51. </junit>
  52. </jacoco:coverage>
  53.  
  54. <target name="test" depends="compile">
  55. <!-- Step 2: Wrap test execution with the JaCoCo coverage task -->
  56. <jacoco:coverage destfile="${result.exec.file}">
  57. <java classname="org.jacoco.examples.parser.Main" fork="true">
  58. <classpath path="${result.classes.dir}" />
  59. <arg value="2 * 3 + 4"/>
  60. <arg value="2 + 3 * 4"/>
  61. <arg value="(2 + 3) * 4"/>
  62. <arg value="2 * 2 * 2 * 2"/>
  63. <arg value="1 + 2 + 3 + 4"/>
  64. <arg value="2 * 3 + 2 * 5"/>
  65. </java>
  66. </jacoco:coverage>
  67. </target>
  68.  
  69.  
  70. <target name="report" depends="test">
  71. <!-- Step 3: Create coverage report -->
  72. <jacoco:report>
  73.  
  74. <!-- This task needs qthe collected execution data and ... -->
  75. <executiondata>
  76. <file file="${result.exec.file}" />
  77. </executiondata>
  78.  
  79. <!-- the class files and optional source files ... -->
  80. <structure name="JaCoCo Ant Example">
  81. <classfiles>
  82. <fileset dir="${result.classes.dir}" />
  83. </classfiles>
  84. <sourcefiles encoding="UTF-8">
  85. <fileset dir="${src.dir}" />
  86. </sourcefiles>
  87. </structure>
  88.  
  89. <!-- to produce reports in different formats. -->
  90. <html destdir="${result.report.dir}" />
  91. <csv destfile="${result.report.dir}/report.csv" />
  92. <xml destfile="${result.report.dir}/report.xml" />
  93. </jacoco:report>
  94. </target>
  95.  
  96. <target name="rebuild" depends="clean,compile,test,report" />
  97.  
  98. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement